Commit 77e1ccbe authored by Rick Parrish's avatar Rick Parrish Committed by Baptiste Daroussin
Browse files

rc: implement parallel boot

take advantage of the rcorder -p argument to implement parallel
booting in rc.

According to the author non scientific tests:
on a Core 2 Duo with spinning disk:

| Services enabled | before | after | saving |
| 0                | 8s     | 8s    | 0      |
| 1                | 13s    | 13s   | 0      |
| 2                | 17s    | 13s   | 5      |
| 3                | 23s    | 13s   | 10     |
| 4                | 28s    | 13s   | 15     |
| 5                | 33s    | 13s   | 20     |

PR:		249192
MFC after:	3 weeks
parent f3f7b0dc
...@@ -91,19 +91,31 @@ if ! [ -e ${firstboot_sentinel} ]; then ...@@ -91,19 +91,31 @@ if ! [ -e ${firstboot_sentinel} ]; then
skip_firstboot="-s firstboot" skip_firstboot="-s firstboot"
fi fi
# rc_parallel_start default is "NO"
rc_parallel_start=${rc_parallel_start:-NO}
_rc_parallel=''
# enable rcorder -p if /etc/rc.conf rc_parallel_start is "YES"
checkyesno rc_parallel_start && _rc_parallel='-p'
# Do a first pass to get everything up to $early_late_divider so that # Do a first pass to get everything up to $early_late_divider so that
# we can do a second pass that includes $local_startup directories # we can do a second pass that includes $local_startup directories
# #
files=`rcorder ${skip} ${skip_firstboot} /etc/rc.d/* 2>/dev/null` files=`rcorder ${skip} ${skip_firstboot} ${_rc_parallel} /etc/rc.d/* 2>/dev/null`
_rc_elem_done=' ' _rc_elem_done=' '
for _rc_elem in ${files}; do IFS=$'\n'
run_rc_script ${_rc_elem} ${_boot} for _rc_group in ${files}; do
_rc_elem_done="${_rc_elem_done}${_rc_elem} " IFS=$' '
for _rc_elem in ${_rc_group}; do
case "$_rc_elem" in run_rc_script ${_rc_elem} ${_boot} &
*/${early_late_divider}) break ;; _rc_elem_done="${_rc_elem_done}${_rc_elem} "
esac
case "$_rc_elem" in
*/${early_late_divider}) break ;;
esac
done
wait
IFS=$'\n'
done done
unset files local_rc unset files local_rc
...@@ -122,14 +134,21 @@ if [ -e ${firstboot_sentinel} ]; then ...@@ -122,14 +134,21 @@ if [ -e ${firstboot_sentinel} ]; then
skip_firstboot="" skip_firstboot=""
fi fi
files=`rcorder ${skip} ${skip_firstboot} /etc/rc.d/* ${local_rc} 2>/dev/null` files=`rcorder ${skip} ${skip_firstboot} /etc/rc.d/* ${local_rc} ${_rc_parallel} 2>/dev/null`
for _rc_elem in ${files}; do IFS=$'\n'
case "$_rc_elem_done" in for _rc_group in ${files}; do
*" $_rc_elem "*) continue ;; IFS=$' '
esac for _rc_elem in ${_rc_group}; do
case "$_rc_elem_done" in
run_rc_script ${_rc_elem} ${_boot} *" $_rc_elem "*) continue ;;
esac
run_rc_script ${_rc_elem} ${_boot} &
done
wait
IFS=$'\n'
done done
unset IFS
# Remove the firstboot sentinel, and reboot if it was requested. # Remove the firstboot sentinel, and reboot if it was requested.
# Be a bit paranoid about removing it to handle the common failure # Be a bit paranoid about removing it to handle the common failure
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment