[arch-projects] [mkinitcpio][PATCH 0/4] performance improvements

Dave Reisner d at falconindy.com
Fri Jun 3 14:13:05 EDT 2011


Hi all,

Sharing some wisdom from my adventures with geninit[1] -- the attached patches
refactor some of the more critical pieces of module discovery: all_modules,
checked_modules, and auto_modules. The last patch is just another bit of low
hanging froot I thought I'd knock off.

Using HOOKS="base udev autodetect sata usbinput filesystems" with gzip
compression for a single image:

Before:
real    0m3.461s
user    0m1.815s
sys     0m0.748s


After:
real    0m2.841s
user    0m1.592s
sys     0m0.671s

Mind you, this is on a SATA2 SSD with /tmp on tmpfs so I expect something more
pronounced on a rotating disk and/or non tmpfs /tmp. Times for a non-autodetect
build are roughly unchanged, as expected.

There is a much larger gain to be had here, but it requries touching a large
amount of code. The major bottleneck in mkinitcpio is the constant calls to
grep to check module existance prior to adding it to the image list. The
alternative is to use the method presented in the gentoo wiki, which can be
summarized as dropping the files into a temporary directory and creating the
cpio archive using find|(bsd)cpio. The existance check then becomes a simple
shell test which is several orders of magnitude faster than grep, matches with
a higher degree of confidence, and removes the tedium of checking parent
directory instance (as order is crucial with gen_init_cpio). I'd like to
eventually do this, but it may be a little while before I get to it. Laying it
out here now in case anyone wants to beat me to it, or tell me it's a silly
idea.

regards,
dave

[1] http://github.com/falconindy/geninit


More information about the arch-projects mailing list