3 simple steps to make booting/shutdown faster...

Arjan van de Ven arjan at infradead.org
Sun Feb 17 02:40:46 UTC 2008

So I got a tad annoyed by why the initscript processing is (in my impatient perception) slow;
most initscripts (in timing) only take like 0.1 second themselves after all.
Turns out.. the rest of the initscript system had quite a bit of overhead.
(More so on F7 than on F8, but still).

Now... I made a bunch of tweaks to the 3 key files and this made things quite
a bit faster; F8 is 50% slower than the new situation 
(for a specific test, new code takes 0.275 seconds, F8 code takes 0.41 seconds).

What I changed:
* if you do if [ -f FOO -o -f BAR ] in bash, bash will look to see if BOTH files exist,
  and then decides that since FOO exits, everything is fine and executes the if body. Looking for non-existing files
  (first time) is expensive.. so splitting this kind of "if" in two reduces disk seeks and IO.
  [this kind of split I had to do in a few places]
* Don't let the initscripts change the VGA font; after all, this is done during early boot already.
  Programming the VGA fonts is SLOW. (Note: in F7 this was done for each init script, in F8 things were
  a tad, but not much, smarter than that)
* Cache the information from /bin/consoletype. this info is used (and calculated with an exec!) all over the place;
  the new code just sticks it in an environment variable. (well it was in one before, just it STILl got recalculated)
* Check if the service is running before deciding if it's a good service; the common case for "telinit' is that it is and then
  no further file IO on the service needs to be done. (and if it's not we need to check that regardless)
* cache the value of "the user wants me to ask"; that's not changing so just stick that in a variable rather than looking at
  the file every time. We still do look at the file IF the var is set, because the user might hit continue
* don't call into "rhgb" if rhgb isn't on the kernel commandline (I have that off on all machines to make them boot faster).
  rhgb got called several times, and isn't cheap, because each time it has to realize rhgb is really not there ;)
* don't grep each script just to see how to pretty print it; assume a fedora quality script and if not, it's only a tad less pretty

Attached are the new files that implement these tweaks:

I hope others who are as impatient as I am find these tweaks as useful as I do :)

   Arjan van de Ven

If you want to reach me at my work email, use arjan at linux.intel.com
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: functions
Type: application/octet-stream
Size: 14419 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/fedora-devel-list/attachments/20080216/07153491/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lang.sh
Type: application/x-shellscript
Size: 3427 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/fedora-devel-list/attachments/20080216/07153491/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rc
Type: application/octet-stream
Size: 2616 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/fedora-devel-list/attachments/20080216/07153491/attachment-0001.obj>

More information about the fedora-devel-list mailing list