LWN.net Logo

OLS: On how user space sucks

OLS: On how user space sucks

Posted Jul 21, 2006 6:50 UTC (Fri) by ekj (subscriber, #1524)
Parent article: OLS: On how user space sucks

The startup-scripts also have tons of stupidity. Many of them are like literally hundreds of lines of shell-script containing dozens of checks, even in the case where they ultimately do nothing.

Case in point: Fedora, Mandriva and Ubuntu all install pcmcia by default, even in the case where the computer is a stationary that does not even have a pcmcia-slot. They also enable the pcmcia startup-script in the normal runlevels. The script is over 300 lines long. It contains 57 conditinals (ifs, elses, cases) and among other things, calls a script named laptop-detect that tries to guesstimate if we're on a laptop. (by messing around in proc looking for a batteries-file, among other things)

Now, most computers don't turn into laptops overnigth. It would be perfectly possible to do this detection *once* on installation, and thereafter simply not install pcmcia-stuff if we don't actually have that hardware. It would even be reasonable.

Yes, it's "convenient" to have new/changed hardware autodetected and auto-working on first boot after installation. I'm not sure it's worth it though. You could skip a *LOT* of startup if you simply assumed this boot was going to be exactly like the last one. There could be a big fat option in the boot-menu saying: "Configure new hardware" which would do what the bootup-scripts do *every* time now.


(Log in to post comments)

Profiling before you optimize

Posted Jul 21, 2006 8:41 UTC (Fri) by Thalience (subscriber, #4217) [Link]

Do you have profiles to support the idea that hardware autodetection is a big component of the startup time? It could be, but watch out for optimizing blind.

I'd take reliable hardware auto-dectection over a static configuration at any reasonable cost, just as a matter of personal preference.

Profiling before you optimize

Posted Jul 27, 2006 7:54 UTC (Thu) by ekj (subscriber, #1524) [Link]

Not scientifically valid profiles, no.

But bootup-time (measured from GRUB loads the kernel until the last startup-script finishes) improved from 1:48 to 1:32 simply by disabling kudzu (which does detection of new hardware).

Uninstalling packages that where auto-installed without question, and that support hardware I don't have shaved another 10 seconds off that to aproximately 1:23.

1:23 and 1:48 ain't that hugely different, but it *does* mean a 30% increase in bootup-time for trying to detect hardware I don't have on every bootup.

Some hardware is regularily plugged in an out. It's reasonable (and good) to try to detect such. But that should happen on the fly, and not as part of a bootup-script. Afterall, the user may very well plug in a usb-stick or whatever *after* logging in.

Other hardware (like for example a pcmcia-slot) is rather unlikely to suddenly appear. I'm guessing that 99.9% of the computers that don't have it when the distro is installed, will *never* have it.

Profiling before you optimize

Posted Jul 27, 2006 17:26 UTC (Thu) by Thalience (subscriber, #4217) [Link]

Ok. Those are reasonable numbers to work with. Thanks for making the effort!

I still think, however, that ditching auto-detection would be to throw the baby out with the bathwater. By focusing more attention on hot-plug style auto-detection, we can have both fast startup and reliable, effortless hardware support.

As an aside, I've always thought that Kudzu was a very appropriate name for that particular peice of software. :)

OLS: On how user space sucks

Posted Jul 21, 2006 10:06 UTC (Fri) by kleptog (subscriber, #1183) [Link]

Last time I installed Debian, at the end of the installtion it noticed I didn't have a laptop and offered to remove pcmcia-cs for me.

Nowadays most of the pcmcia stuff has been subsumed into udev so this may not even be relevent anymore...

OLS: On how user space sucks

Posted Jul 24, 2006 23:27 UTC (Mon) by cjwatson (subscriber, #7322) [Link]

On Ubuntu, pcmciautils is installed by default because - aside from its init script - it's pretty small and lightweight (compared to the monster that was pcmcia-cs/cardmgr) and it simplifies the installer, debugging the resulting system, etc. if we just install it all the time.

Per Olofsson simplified that init script a fair bit in Debian; Edgy has that simplification, and e.g. no longer calls laptop-detect.

It's also worth noting that 'case' in shell scripts doesn't spawn a subprocess, unlike 'if [ ... ]', so simply counting conditionals doesn't always give you a fair picture.

Test, with "test" vs /usr/bin/test

Posted Jul 25, 2006 3:59 UTC (Tue) by Richard_J_Neill (subscriber, #23093) [Link]

"if [ a = b ] " and "if test a = b " are both shell-builtins. If you want the other one, you have to call /usr/bin/test

$ date; for ((i=0; i<10000; i++)) ; do if [ a = b ] ; then c=d ; fi ; done ;date
Tue Jul 25 04:51:16 BST 2006
Tue Jul 25 04:51:16 BST 2006

$ date; for ((i=0; i<10000; i++)) ; do if test a = b ; then c=d ; fi ; done ;date
Tue Jul 25 04:51:27 BST 2006
Tue Jul 25 04:51:27 BST 2006

$ date; for ((i=0; i<10000; i++)) ; do if /usr/bin/test a = b ; then c=d ; fi ; done ;date
Tue Jul 25 04:51:33 BST 2006
Tue Jul 25 04:51:50 BST 2006

It's a huge difference! The script with the builtins runs 60 times faster.

Test, with "test" vs /usr/bin/test

Posted Jul 29, 2006 15:43 UTC (Sat) by kreutzm (subscriber, #4700) [Link]

Where do you see that "60x"? ALso I'd advise you to use time(1) next time ;-)

Copyright © 2012, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds