[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: better init.d/* : who carres ?

#include <hallo.h>
* Henrique de Moraes Holschuh [Thu, Aug 25 2005, 12:17:56PM]:

> Well, as long as you don't start using stuff that breaks often, or that
> loads a ton of crap dynamically, or (even worse) is in /usr instead of /bin
> or /sbin...
> Note that using dash is probably MUCH faster than perl.  I don't know about
> zsh.

Well, I made some tests and can proof your claim. I have just tried a
simple version of the skeleton script with /bin/true as the daemon, a
simple config file to be read and optionaly a grep call in the script.
The perl version was a straight-forward port of the script with internal
grep method. Shell compatible config file reader was stolen from apt-cacher.
Tests run with a loop like:
time for x in `seq 1000` ; do perl skeleton.pl start ; perl skeleton.pl stop; done

The results reflected my expectations, speed order:
dash < ... < perl < zsh < bash;
Perl is a lot faster than what some perl hatters try to make us believe.

With external program calls, everything became really slow while usage
of the internal Perl implementation demonstraged its advantage.
perl < ... < dash < ... < zsh < bash

Conclusion: usage of many (even simple) external programs is evil, though
it may improve readability for "some people". Replacing setting /bin/sh
link to dash instead of bash and having more than 100 init scripts I can
assume the whole boot would be 3s faster (1900Mhz box).

Personaly, I would write all init scripts in Perl but unfortunately
compatibility considerations force us to do things that suck.


simple skeleton:


real	0m6.538s
user	0m1.924s
sys	0m3.880s


real	0m30.406s
user	0m18.101s
sys	0m8.197s


real	0m15.195s
user	0m7.388s
sys	0m7.324s


real	0m19.458s
user	0m8.773s
sys	0m9.429s

with external program (grep in the defaults file):


real	0m23.050s
user	0m14.409s
sys	0m6.664s

real	0m18.820s
user	0m7.452s
sys	0m7.560s


real	0m46.683s
user	0m32.754s
sys	0m13.105s

more external programs (grep ... | cut ... | wc ...):


real	0m40.917s
user	0m30.058s
sys	0m10.089s


real	1m2.397s
user	0m43.911s
sys	0m16.525s

Perl: (equivalent internal code)

real	0m15.604s
user	0m7.760s
sys	0m7.444s

<youam> nach duesseldorf zu freenet schaffe ich in einer verbindung auch
	~5mb/s, ansonsten nur ziehend z.b. ftp.de.debian.org (dresden) ~4mb/s
<Zomb> unglaublich... die Bandbreitensäue
<youam> Zomb: hey, _du_ schickst doch für jeden einzelnen umlaut zwei byte über
	die leitung...

Reply to: