FS#20006 - [initscripts] Bashification of initscripts for moderate speedup

Attached to Project: Arch Linux
Opened by Victor Lowther (victor.lowther) - Monday, 28 June 2010, 11:32 GMT
Last edited by Tom Gundersen (tomegun) - Sunday, 27 March 2011, 17:37 GMT
Task Type Feature Request
Category Initscripts
Status Closed
Assigned To Thomas Bächler (brain0)
Tom Gundersen (tomegun)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 9
Private No

Details

I have spent some time over the last month or so rewriting the Arch initscripts in idiomatic bash -- since they rely on bash-specific features, trying to keep them fairly POSIX is rather a waste of time and a net performance loss -- using bash-style conditionals is about 30% faster when nothing needs to be touched on the filesystem and about 200% easier to read, and you can use bash regexps in place of most trivial uses of sed, grep, and awk when mangling parameters or variables -- the fewer short-lived processes we fork the better.

You can browse changes I have made in the git repo @ http://git.fnordovax.org/arch-initscripts/log/?h=bashification and you can checkout my changes to play around with from git://fnordovax.org/~victor/arch-initscripts

There is a gigantic whitespace fixup patch at the end, all it does is fix all the whitespace errors I introduced while hacking and reformat everything to a consistent indentation style (emacs shell-script mode, if you are interested).

I have tested these changes on a VM and on my local laptop. I inlcuded a PKGBUILD that will build an initscripts-git package, but be sure to backup and restore your rc.*local, inittab, and rc.conf files because they will get nuked the first time you install it.

Overall, this series of patches trims about 100 lines out of the initscripts, mainly by refactoring common code.
This task depends upon

Closed by  Tom Gundersen (tomegun)
Sunday, 27 March 2011, 17:37 GMT
Reason for closing:  Implemented
Comment by Thomas Dziedzic (tomd123) - Monday, 28 June 2010, 15:48 GMT
I don't doubt that it does provide a speed up, but could you possibly provide a bootchart of the before and after :)
Comment by Victor Lowther (victor.lowther) - Monday, 28 June 2010, 22:24 GMT
Times measured from the start of rc.sysinit to the end of rc.multi. The large offsets and variablility at the beginning are me typing in my passphrase -- I use dracut to generate my initramfs'es and have everything but boot on ext4 on LVM on dm_crypt

System is a Dell Studio 1555 with a 7200 RPM 500 GB SATA drive.

Bashified:
1: 11s - 26s - approx 15 secs
2: 10s - 26s - approx. 16 secs
3: 11s - 26s - approx 15 secs

Normal:
1: 10s - 25s - approx 15 secs
2: 12s - 28s - approx 16 secs
3: 12s - 28s - approx 16 secs

Bashified is slightly faster, but well wihtin the range that it could just as easily be statistical noise. IO and certian busywait processes dominate my boot -- running these with an SSD based system would be a better set of tests.
Comment by Daniel Mills (e36freak) - Wednesday, 05 January 2011, 20:24 GMT
I have actually been doing the same thing. I also noticed a lot of "command; if [ $? -ne 0 ]; then" when "if command, then" would do nicely. I think everything could definitely be a lot more efficient than it is now
Comment by Tom Gundersen (tomegun) - Sunday, 27 March 2011, 17:37 GMT
I think this has all been pulled now. If there are still patches pending, please post to <arch-projects@archlinux.org>.

Loading...