DragonFly BSD
DragonFly users List (threaded) for 2006-09
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: shutdown on BSD and Linux

From: Oliver Fromme <check+j58c2g00rs5txnmp@xxxxxxxxxx>
Date: 07 Sep 2006 16:46:47 GMT

Rahul Siddharthan wrote:
 > Joerg Sonnenberger wrote:
 > >
 > > If you use shutdown to reboot, it runs the scripts from /etc/rc.d as
 > > well, but most simply don't do anything.
 > Thanks Joerg (and Oliver) for your answers.  
 > I'm still puzzled because in the linux case, too, most scripts don't
 > do anything (or just send a signal).

In that case, you should rather ask on a Linux list why
Linux is so slow, instead of asking on a BSD list why BSD
is so fast.  :-)

 > If the fork/exec of a shell is what causes the overhead,
 > then---for a similar number of scripts---the systems should take
 > similar time to shutdown.

The fork/exec overhead of the shell executing the script
should be neglegible.  The BSD rc scripts also try to use
shell-builtin features as far as possible, so to avoid
the overhead of exec'ing external tools (e.g. using the
shell's arithmetic expansion and case/esac pattern matching
instead of calling expr(1) etc.).

Starting a daemon usually takes a _lot_ more time than
stopping it.  Many of them perform certain tasks before
even daemonizing itself.  For example, Apache reads and
parses all of its configuration, loads its modules etc.
_before_ going into the background, which can take
several seconds.  However, upon shutdown, the stop script
just sends it a signal via apachectl, and that's it.
Sending a signal almost takes zero time.

Also take into account that, after a reboot, the cache of
the VM system is empty.  My /usr/local/libexec/apache
directory contains 38 files (modules), totalling 2 MB,
and all of them have to be physically loaded from disk
when apache starts, plus the httpd binary itself, of course,
plus libperl if you're using mod_perl, plus a lot of other
things.  That certainly takes longer than zero time.  Upon
shutdown, nothing has to be loaded from disk, except maybe
the apachectl script, which is 5 KB.  Chances are that even
the kill(1) binary is still in the VM cache, so no disk
access is required for it.

Bottom line:  If Linux' shutdown is slow, then I wonder
what's wrong with Linux.

Best regards

PS:  By the way, recently someone suggested in a FreeBSD
mailing list that start scripts could be run in parallel
if they don't depend on each other (which rcorder(8) can
easily find out).  It would probably speed up booting.
However, I don't know if anyone is actually working on
implementing that.

Oliver Fromme,  secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing
Dienstleistungen mit Schwerpunkt FreeBSD: http://www.secnetix.de/bsd

Any opinions expressed in this message may be personal to the author
and may not necessarily reflect the opinions of secnetix in any way.

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