Sunday, February 17, 2008

Fedora: 3 simple steps to make booting/shutdown faster

Arjan van de Ven, in his latest comment inside the fedora-devel have critics the initscripts processing is too damn slow inside Fedora 8. So he decided to make a quick fix on this matter. Quoting directly from the email:

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:
/etc/rc.d/rc
/etc/init.d/functions

/etc/profile.d/lang.sh

Tested it on my rawhide box and it works . Click here to download the corresponded tweak,

No comments: