FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.

» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian Kernel

LinkBack Thread Tools
Old 12-18-2011, 07:00 AM
Josh Triplett
Default Bug#652525: Make initramfs-tools faster by avoiding forks in the per-module hot path

On Sat, Dec 17, 2011 at 10:37:29PM -0800, Josh Triplett wrote:
> In the last few versions of initramfs-tools, update-initramfs started
> taking an excessively long time to generate the initramfs:
> ~$ time sudo update-initramfs -u
> update-initramfs: Generating /boot/initrd.img-3.1.0-1-amd64
> real 0m26.197s
> user 0m14.785s
> sys 0m1.196s
> This results in a long delay every time I upgrade either a kernel or any
> package with an update-initramfs hook.
> As far as I can tell, a large part of this processing time seems to
> consist of the per-module processing for the ~500 kernel modules copied
> into the initramfs, forking off a pile of programs for each one. I
> tried optimizing the per-module hot path to eliminate as many forks as
> possible, and managed to speed it up considerably:
> ~$ time sudo update-initramfs -u
> update-initramfs: Generating /boot/initrd.img-3.1.0-1-amd64
> real 0m21.385s
> user 0m14.393s
> sys 0m0.740s
> I've attached a patch implementing these optimizations.
> A few other possible improvements:
> - Generate a list of modules and processing them all in batch at the
> end of update-initramfs, to allow calling modprobe and modinfo only
> once. Likely to make a huge difference.
> - In the absence of the above, make manual_add_modules take a list of
> modules and process them all, and make the various hooks pass a list
> of modules to manual_add_modules rather than calling it repeatedly.

I implemented this addition, making manual_add_modules take multiple
arguments, and it provided another significant performance improvement:

~$ time sudo update-initramfs -u
update-initramfs: Generating /boot/initrd.img-3.1.0-1-amd64

real 0m18.763s
user 0m14.569s
sys 0m0.720s

The difference between the original and patched versions in terms of
executed programs:

~$ grep -c 'execve' /tmp/update-initramfs.orig.strace
~$ grep -c 'execve' /tmp/update-initramfs.patched.strace

And more specifically the calls to modprobe:

~$ grep -c 'execve.*modprobe' /tmp/update-initramfs.orig.strace
~$ grep -c 'execve.*modprobe' /tmp/update-initramfs.patched.strace

Implementing full batching would reduce the modprobe calls down to 1,
but 34 still represents a significant improvement with relatively little

Patch attached. (This subsumes the original patch.)

- Josh Triplett

Thread Tools

All times are GMT. The time now is 07:56 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org