TipsAndTricks/UseRamdisikToSpeedUpBuilds

From Yocto Project
Jump to: navigation, search

At some point your build system may become IO bound, when your hard disk(s) cannot keep up with CPUs running various tasks. This is frequently the case when your systems has numerous CPUs, but only a single hard drive. Providing you have plenty of RAM, it is possible to improve the build performance by using a ramdisk. It is probably a good idea not to keep DEPLOY_DIR in ramdisk. Placing something like the following:

TMPDIR="/tmp/ramdisk/build-ramdisk"
DEPLOY_DIR="/work/poky/build-ramdisk/tmp/deploy"

in your local.conf would keep the built images on your harddrive, everything else in a volatile ramdisk.

Some build times as observed on my system (in minutes), YMMV. Builds are clean builds, no SSTATE, with data already downloaded:

----------------------- HDD -------- RAMDISK ---
core-image-minimal      24            20
core-image-sato         47            39

If running multiple builds at the same time, the benefits become even more obvious.
Setting up a ramdisk is trivial, the following example creates 64G ramdisk:

$ sudo mkdir /tmp/ramdisk
$ sudo chmod 777 /tmp/ramdisk
$ sudo mount -t tmpfs -o size=64G ramdisk /tmp/ramdisk

If you want the ramdisk mounted automatically at boot time, add this into /etc/fstab:

ramdisk /tmp/ramdisk tmpfs defaults,size=64G,x-gvfs-show 0 0

(Another advantage of ramdisk is that it is much faster to delete the files.)

Personal tools