This is something I'd like to try this weekend. I'm putting it out here in case anyone sees an obvious flaw.
FreeBSD's RC init system manages services as a family of sh(1) scripts under /etc/rc.d/ and /usr/local/etc/rc.d/.
The /etc/rc script calls rcorder(8) to get the list of rc.d scripts to run in a safe order. The output of rcorder is one rc script name per line.
/etc/rc calls rcorder(8) here:
The stock /etc/rc script runs each RC service script one at a time. Very reliable but no concurrency.
The plan is to add very myopic parallel support by altering rc only. The altered rc will look at the PROVIDE: and REQUIRE: clauses to determine if two adjacent scripts can be run in parallel. Successive script names are added to a list called 'group' - up to a small limit is reached (say 5) - or until the next script cannot be run in parallel. This group of scripts is run in parallel. The 'wait' built-in waits for this script group to complete before going on to the next group. I'm looking to see what if any gain in start up time can be had with this lightweight amount of concurrency.
If this works, I'd look at modifying rcorder (a new flag like '-p 5' to keep backward compatibility) to return multiple rc script names on the same line to indicate they can be run in parallel.
My sh(1) scripting is horrid so this will be interesting.
Edit: updated to say working on /etc/rc (and not /etc/rc.resume).
FreeBSD's RC init system manages services as a family of sh(1) scripts under /etc/rc.d/ and /usr/local/etc/rc.d/.
The /etc/rc script calls rcorder(8) to get the list of rc.d scripts to run in a safe order. The output of rcorder is one rc script name per line.
/etc/rc calls rcorder(8) here:
Code:
files=`rcorder ${skip} ${skip_firstboot} /etc/rc.d/* ${local_rc} 2>/dev/null`
for _rc_elem in ${files}; do
case "$_rc_elem_done" in
*" $_rc_elem "*) continue ;;
esac
run_rc_script ${_rc_elem} ${_boot}
done
The stock /etc/rc script runs each RC service script one at a time. Very reliable but no concurrency.
The plan is to add very myopic parallel support by altering rc only. The altered rc will look at the PROVIDE: and REQUIRE: clauses to determine if two adjacent scripts can be run in parallel. Successive script names are added to a list called 'group' - up to a small limit is reached (say 5) - or until the next script cannot be run in parallel. This group of scripts is run in parallel. The 'wait' built-in waits for this script group to complete before going on to the next group. I'm looking to see what if any gain in start up time can be had with this lightweight amount of concurrency.
Code:
for _rc_elem in $group; do
case "$_rc_elem_done" in
*" $_rc_elem "*) continue ;;
esac
run_rc_script $_rc_elem resume &
done
wait
If this works, I'd look at modifying rcorder (a new flag like '-p 5' to keep backward compatibility) to return multiple rc script names on the same line to indicate they can be run in parallel.
My sh(1) scripting is horrid so this will be interesting.
Edit: updated to say working on /etc/rc (and not /etc/rc.resume).
Last edited: