From: "Mikko Rapeli" <mikko.rapeli@bmw.de>
To: <ross@burtonini.com>
Cc: <yocto@lists.yoctoproject.org>
Subject: Re: [yocto] What are the key factors for yocto build speed?
Date: Thu, 19 Mar 2020 08:05:15 +0000 [thread overview]
Message-ID: <20200319080514.GR104502@korppu> (raw)
In-Reply-To: <8032ed75-802c-9dd3-2d76-f468159b90af@burtonini.com>
On Wed, Mar 18, 2020 at 10:56:50PM +0000, Ross Burton wrote:
> On 18/03/2020 14:09, Mike Looijmans wrote:
> > Harddisk speed has very little impact on your build time. It helps with
> > the "setscene" parts, but doesn't affect actual compile time at all. I
> > recall someone did a build from RAM disks only on a rig, and it was only
> > about 1 minute faster on a one hour build compared to rotating disks.
>
> My build machine has lots of RAM and I do builds in a 32GB tmpfs with
> rm_work (and no, I don't build webkit, which would make this impractical).
>
> As you say, with sufficient RAM the build speed is practically the same as
> on disks due to the caching (especially if you tune the mount options), so
> I'd definitely spend money on more RAM instead of super-fast disks. I just
> prefer doing tmpfs builds because it saves my spinning rust. :)
Alternative for tmpfs with hard size limit is to keep file system caches in
memory as long as possible and only start writes to disks when page cache gets
too full. This scales but still uses all the RAM available. Here's how to do this:
$ cat /etc/sysctl.d/99-build_server_fs_ops_to_memory.conf
# fs cache can use 90% of memory before system starts io to disk,
# keep as much as possible in RAM
vm.dirty_background_bytes = 0
vm.dirty_background_ratio = 90
# keep stuff for 12h in memory before writing to disk,
# allows reusing data as much as possible between builds
vm.dirty_expire_centisecs = 4320000
vm.dirtytime_expire_seconds = 432000
# allow single process to use 60% of system RAM for file caches, e.g. image build
vm.dirty_bytes = 0
vm.dirty_ratio = 60
# disable periodic background writes, only write when running out of RAM
vm.dirty_writeback_centisecs = 0
Once this is done, IO still happens when anything calls sync() and fsync()
and worst offenders are package management tools. In yocto builds, package
manager actions to flush to disk are always useless since rootfs images
are going to be compressed and original ones wiped by rm_work anyway.
I've tried to hook eatmydata library into the build which makes sync() and fsync()
calls no-ops but I've still failed to fix all the tools and processes called
during build from python code. For shell based tasks this does it:
$ export LD_LIBRARY_PATH=/usr/lib/libeatmydata
$ export LD_PRELOAD=libeatmydata.so
$ grep -rn LD_PRELOAD conf/local.conf
conf/local.conf:305:BB_HASHBASE_WHITELIST_append = " LD_PRELOAD"
conf/local.conf:306:BB_HASHCONFIG_WHITELIST_append = " LD_PRELOAD"
The effect is clearly visible during build time using Performance Co-Pilot (pcp)
or similar tools to monitor CPU, memory, IO and network IO. The usage of RAM
as page cache grows until limits are hit and only then writes to disk
start, except for the python image classes... Hints to fix this are welcome!
To my knowledge of monitoring our builds, there is a lot of optimization
potential to better build times. CPU are under utilized during bitbake recipe
parsing, fetch, configure, package and rootfs tasks. Memory is not fully utilized
either since IO through sync()/fsync() happens everywhere, and due to background
writes by default on ext4 etc file systems. Only do_compile() tasks are saturating
all CPUs and when linking lots of C++ also all of RAM. Then dependencies between
various recipes and tasks leaves large gaps in CPU utilization too.
-Mikko
next prev parent reply other threads:[~2020-03-19 8:05 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-18 12:52 What are the key factors for yocto build speed? Oliver Westermann
2020-03-18 13:01 ` [yocto] " Mikko Rapeli
2020-03-18 13:29 ` Paul Barker
2020-03-18 14:12 ` Jean-Marie Lemetayer
2020-03-18 14:30 ` Alexander Kanavin
2020-03-18 14:49 ` Adrian Bunk
2020-03-18 15:09 ` Mike Looijmans
2020-03-18 15:51 ` Mikko Rapeli
2020-03-18 17:13 ` <EXT> " Srini
2020-03-18 17:47 ` David Stewart
2020-03-18 18:12 ` Yann Dirson
2020-03-18 18:15 ` Srini
2020-03-20 16:32 ` Philip Balister
2020-03-19 6:27 ` Mike Looijmans
2020-03-21 18:43 ` Oliver Westermann
2020-03-18 14:09 ` [yocto] " Mike Looijmans
2020-03-18 22:56 ` Ross Burton
2020-03-19 8:05 ` Mikko Rapeli [this message]
2020-03-19 11:04 ` Richard Purdie
2020-03-19 11:43 ` Mikko Rapeli
2020-03-19 11:48 ` Richard Purdie
2020-03-19 16:07 ` Mike Looijmans
2020-03-19 16:29 ` Yann Dirson
2020-03-19 17:04 ` Richard Purdie
2020-03-19 18:09 ` Yann Dirson
2020-03-19 17:21 ` Adrian Bunk
2020-03-19 17:26 ` Richard Purdie
2020-03-20 14:58 ` Mike Looijmans
2020-03-20 17:24 ` Adrian Bunk
2020-03-19 18:23 ` Khem Raj
[not found] ` <15FD6B43E957AFDB.13190@lists.yoctoproject.org>
2020-03-18 14:36 ` Mike Looijmans
2020-03-18 15:38 ` Martin Jansa
2020-03-21 18:39 ` Oliver Westermann
2020-03-21 18:58 ` [yocto] " Martin Jansa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200319080514.GR104502@korppu \
--to=mikko.rapeli@bmw.de \
--cc=ross@burtonini.com \
--cc=yocto@lists.yoctoproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.