I've been looking at the boot and shutdown timing of our boot scripts.
For boot, it seems that most of the time is taken with 'udevadm settle'.
When I instrumented the scripts, over half the boot time was waiting
for settle to complete.
When I commented out the settle instruction, the speedup was evident:
Oct 05 03:01:15.899727477 Starting mountvirtfs
...
Oct 05 03:01:19.779770827 Starting SSH Server... OK
That's 3.9 seconds for all the bootscripts I run. From dmesg, the
scripts start running a about 4.5 seconds after the kernel messages
start. That compares to 9.1 (+4.5) seconds with the settle instruction
in both udev and udev_retry.
I'm hesitant to remove the settle instructions, but I'm also not sure
they do anything for us. Even without settle, it takes about 2 seconds
to check/mount the file systems (I mount 6) and I don't think udev
affects that. I don't really see anything after udev_retry that would
be affected either. It's possible there might be something though.
The question here is: should the 'udevadm settle' commands be removed
from the udev and udev_retry scripts?
------
On shutdown, most of the time is in the killproc script. We send a
termination signal to each process and then wait for it to die. There
are a couple of sleep instructions there.
There are a couple of ways to shutdown the system. The simplest is to
just call reboot or poweroff as root. These programs send init's
programs (agetty, etc) a TERM signal, wait 3 seconds, and send anything
left a KILL signal. They then run the rc script which, in turn, runs
the other scripts at runlevel 0 or 6.
The delays can be eliminated if the command '/sbin/telinit -t0 6' is
used for reboot (or a 0 parameter for halt). We also have the same
logic in /etc/init.d/sendsignals script. The delay time there can
controlled by setting the KILLDELAY variable in /etc/sysconfig/rc.site.
With both settings at 0, the time for me to shut down is about 6.4
seconds. This could be improved by tweaking the delays in killproc.
kill "${signal}" "${pid}"
while [ "${delay}" -ne "0" ]; do
kill -0 "${pid}" 2> /dev/null || piddead="1"
if [ "${piddead}" = "1" ]; then break; fi
sleep 0.1
delay="$(( ${delay} - 1 ))"
done
The $delay is 30, so the wait here in each process can be up to 3
seconds. Instrumenting, the only process I have that waits at all
appears to be klogd which takes about a second to die.
There is one instruction in killproc at the end that does:
if [ -n "${fallback}" -a "${piddead}" != "1" ]; then
kill "${fallback}" "${pid}" 2> /dev/null
sleep 1
# Check again, and fail if still running
kill -0 "${pid}" 2> /dev/null && return 1
else
# just check one last time and if still alive, fail
sleep 1
kill -0 "${pid}" 2> /dev/null && return 1
fi
The second sleep does not seem to needed. Usually $piddead will be set
to 1 and $fallback to '-KILL'. Removing the sleep in the else clause
speeds up the shutdown a lot. My best case for shutdown time is now
about 1.4 seconds and 1 second of that is for klogd.
Perhaps the else clause should be removed completely.
Any thoughts?
--------
I think the startup and shutdown timing discussion should be in LFS.
Perhaps a section named "Startup and shutdown timing" immediately after
Section 7.12 - The rc.site File.
Does this seem useful?
-- Bruce
--
http://linuxfromscratch.org/mailman/listinfo/lfs-dev
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page