Subject: Re: Proposed rc.d changes....
To: Luke Mewburn <lukem@wasabisystems.com>
From: Greywolf <greywolf@starwolf.com>
List: tech-userlevel
Date: 02/25/2001 19:58:23
On Mon, 26 Feb 2001, Luke Mewburn wrote:

# Date: Mon, 26 Feb 2001 10:51:34 +1100
# From: Luke Mewburn <lukem@wasabisystems.com>
# To: Greywolf <greywolf@starwolf.com>
# Cc: tech-userlevel@netbsd.org
# Subject: Re: Proposed rc.d changes....
#
# On Sat, Feb 24, 2001 at 11:25:34AM -0800, Greywolf wrote:
# > 'kay, I've tested this out; even on the SS5/170 I have, the difference is
# > noticeable between the a) and b) below; the difference between b) and c) is
# > measurable but not by as much, but it's still there.
# >
# > I like it.
#
# So, loading rc.conf once and other little optimisations help a lot?  Good!
# The rc_fast_and_loose stuff might only help on platforms where fork()
# is really bad.
#
# Can you give me some indicative numbers of the boot times of options
# a), b) and c)?

I would, but I'm running netatalk at start time (which takes about 20
seconds in and of itself), so I'm afraid it's not a very good benchmark in
the long run.

Let me see what I can do later on about ripping it out and giving you a time
output.

# >
# > On Fri, 23 Feb 2001, Luke Mewburn wrote:
# >
# > # From: Luke Mewburn <lukem@wasabisystems.com>
# > # To: tech-userlevel@netbsd.org
# > # Cc: Greywolf <greywolf@starwolf.com>
# > # Subject: Re: Proposed rc.d changes....
# > #
# > # On Tue, Feb 20, 2001 at 07:12:48PM +1100, Luke Mewburn wrote:
# > # > On Tue, Feb 20, 2001 at 02:36:04PM +1100, Luke Mewburn wrote:
# > # > > I've been meaning to ask for testing from users with much slower
# > # > > machines than my laptop (a PIII-700), because I didn't notice any
# > # > > difference with my laptop with the patch.
# > # > >
# > # > > Any takers? (Or should I just post it here and have people post their
# > # > > before & after results? :)
# > # >
# > # > here's a work in progress. use at your own risk, etc ...
# > # >
# > # > i'd be interested in the difference between:
# > # >
# > # > 	(a) the system as it stands now.
# > # >
# > # > 	(b) the following patch without rc_fast_and_loose set
# > # > 	    (it only loads rc.conf once, and has other speedups)
# > # >
# > # > 	(c) the following patch WITH rc_fast_and_loose set.
# > # >
# > # > the patch adds a call to `date' at the start of /etc/rc, so that could
# > # > be added to your /etc/rc before test (a) so you have an idea on when
# > # > it starts (date is already run at the end).
# > #
# > # So, I posted the patches a couple of days ago, and I haven't received
# > # any feedback yet.
# > #
# > # Does it take *that* long to reboot the slow boxen?
# > #
# > #
# > # Luke.
# > #
# > # >
# > # > enjoy,
# > # > luke.
# > # >
# > # > Index: rc
# > # > ===================================================================
# > # > RCS file: /cvsroot/basesrc/etc/rc,v
# > # > retrieving revision 1.154
# > # > diff -p -r1.154 rc
# > # > *** rc	2000/12/15 00:00:09	1.154
# > # > --- rc	2001/02/20 08:06:28
# > # > *************** export PATH=/sbin:/bin:/usr/sbin:/usr/bi
# > # > *** 14,20 ****
# > # > --- 14,29 ----
# > # >
# > # >   . /etc/rc.subr
# > # >   . /etc/rc.conf
# > # > + _rc_conf_loaded=YES
# > # >
# > # > + #	Uncomment the following to execute each /etc/rc.d script in
# > # > + #	the current shell rather than in a subshell.  This may be
# > # > + #	faster on slow machines.
# > # > + #	CAUTION: USE THIS AT YOUR OWN RISK; A BAD SCRIPT MAY
# > # > + #	INADVERTENTLY PREVENT BOOT TO MULTIUSER.
# > # > + #
# > # > + #rc_fast_and_loose=YES
# > # > +
# > # >   if ! checkyesno rc_configured; then
# > # >   	echo "/etc/rc.conf is not configured.  Multiuser boot aborted."
# > # >   	exit 1
# > # > *************** trap : 2
# > # > *** 34,42 ****
# > # >   trap "echo 'Boot interrupted.'; exit 1" 3
# > # >
# > # >   files=`rcorder -s nostart /etc/rc.d/*`
# > # >
# > # > ! for i in $files; do
# > # > ! 	run_rc_script $i start
# > # >   done
# > # >
# > # >   date
# > # > --- 43,53 ----
# > # >   trap "echo 'Boot interrupted.'; exit 1" 3
# > # >
# > # >   files=`rcorder -s nostart /etc/rc.d/*`
# > # > +
# > # > + date
# > # >
# > # > ! for _rc_elem in $files; do
# > # > ! 	run_rc_script $_rc_elem start
# > # >   done
# > # >
# > # >   date
# > # > Index: rc.subr
# > # > ===================================================================
# > # > RCS file: /cvsroot/basesrc/etc/rc.subr,v
# > # > retrieving revision 1.29
# > # > diff -p -r1.29 rc.subr
# > # > *** rc.subr	2000/11/17 03:47:43	1.29
# > # > --- rc.subr	2001/02/20 08:06:29
# > # > *************** check_pidfile()
# > # > *** 117,132 ****
# > # >   	fi
# > # >   	_procnamebn=${_procname##*/}
# > # >   	ps -p $_pid -o 'pid,command' | while read _npid _arg0 _argv; do
# > # > ! 		if [ "$_npid" = "PID" ]; then
# > # > ! 			continue
# > # > ! 		fi
# > # > ! 		if [   "$_arg0" = "$_procname" \
# > # > ! 		    -o "$_arg0" = "$_procnamebn" \
# > # > ! 		    -o "$_arg0" = "${_procnamebn}:" \
# > # > ! 		    -o "$_arg0" = "(${_procnamebn})" ]; then
# > # >   			echo $_npid
# > # >   			return
# > # > ! 		fi
# > # >   	done
# > # >   }
# > # >
# > # > --- 117,132 ----
# > # >   	fi
# > # >   	_procnamebn=${_procname##*/}
# > # >   	ps -p $_pid -o 'pid,command' | while read _npid _arg0 _argv; do
# > # > ! 		case "$_npid" in
# > # > ! 		    PID)
# > # > ! 			continue ;;
# > # > ! 		esac
# > # > ! 		case "$_arg0" in
# > # > ! 		    $_procname|$_procnamebn|${_procnamebn}:|"(${_procnamebn})")
# > # >   			echo $_npid
# > # >   			return
# > # > ! 			;;
# > # > ! 		esac
# > # >   	done
# > # >   }
# > # >
# > # > *************** check_process()
# > # > *** 144,159 ****
# > # >   	_procnamebn=${_procname##*/}
# > # >   	_pref=
# > # >   	ps -ax -o 'pid,command' | while read _npid _arg0 _argv; do
# > # > ! 		if [ "$_npid" = "PID" ]; then
# > # > ! 			continue
# > # > ! 		fi
# > # > ! 		if [   "$_arg0" = "$_procname" \
# > # > ! 		    -o "$_arg0" = "$_procnamebn" \
# > # > ! 		    -o "$_arg0" = "${_procnamebn}:" \
# > # > ! 		    -o "$_arg0" = "(${_procnamebn})" ]; then
# > # >   			echo -n "$_pref$_npid"
# > # >   			_pref=" "
# > # > ! 		fi
# > # >   	done
# > # >   }
# > # >
# > # > --- 144,159 ----
# > # >   	_procnamebn=${_procname##*/}
# > # >   	_pref=
# > # >   	ps -ax -o 'pid,command' | while read _npid _arg0 _argv; do
# > # > ! 		case "$_npid" in
# > # > ! 		    PID)
# > # > ! 			continue ;;
# > # > ! 		esac
# > # > ! 		case "$_arg0" in
# > # > ! 		    $_procname|$_procnamebn|${_procnamebn}:|"(${_procnamebn})")
# > # >   			echo -n "$_pref$_npid"
# > # >   			_pref=" "
# > # > ! 			;;
# > # > ! 		esac
# > # >   	done
# > # >   }
# > # >
# > # > *************** run_rc_command()
# > # > *** 256,262 ****
# > # >   {
# > # >   	_arg=$1
# > # >   	if [ -z "$name" ]; then
# > # > ! 		err 3 '$name is not set.'
# > # >   	fi
# > # >
# > # >   	case "$_arg" in
# > # > --- 256,262 ----
# > # >   {
# > # >   	_arg=$1
# > # >   	if [ -z "$name" ]; then
# > # > ! 		err 3 'run_rc_command: $name is not set.'
# > # >   	fi
# > # >
# > # >   	case "$_arg" in
# > # > *************** run_rc_command()
# > # > *** 297,314 ****
# > # >   	else
# > # >   		eval _flags=\$${name}_flags
# > # >   	fi
# > # > ! 	eval _chdir=\$${name}_chdir
# > # > ! 	eval _chroot=\$${name}_chroot
# > # > ! 	eval _nice=\$${name}_nice
# > # > ! 	eval _user=\$${name}_user
# > # > ! 	eval _group=\$${name}_group
# > # > ! 	eval _groups=\$${name}_groups
# > # >
# > # >   					# if ${rcvar} is set, and $1 is not
# > # >   					# "rcvar" or "status", then run
# > # >   					#	checkyesno ${rcvar}
# > # >   					# and return if that failed
# > # >   					#
# > # >   	if [ -n "${rcvar}" -a "$_arg" != "rcvar" -a "$_arg" != "status" ]; then
# > # >   		if ! checkyesno ${rcvar}; then
# > # >   			return 0
# > # > --- 297,312 ----
# > # >   	else
# > # >   		eval _flags=\$${name}_flags
# > # >   	fi
# > # > ! 	eval _chdir=\$${name}_chdir	_chroot=\$${name}_chroot \
# > # > ! 	    _nice=\$${name}_nice	_user=\$${name}_user \
# > # > ! 	    _group=\$${name}_group	_groups=\$${name}_groups
# > # >
# > # >   					# if ${rcvar} is set, and $1 is not
# > # >   					# "rcvar" or "status", then run
# > # >   					#	checkyesno ${rcvar}
# > # >   					# and return if that failed
# > # >   					#
# > # > + 	# XXXX use case?
# > # >   	if [ -n "${rcvar}" -a "$_arg" != "rcvar" -a "$_arg" != "status" ]; then
# > # >   		if ! checkyesno ${rcvar}; then
# > # >   			return 0
# > # > *************** run_rc_command()
# > # > *** 325,332 ****
# > # >   					# if there's a custom ${XXX_cmd},
# > # >   					# run that instead of the default
# > # >   					#
# > # > ! 		eval _cmd=\$${_arg}_cmd
# > # > ! 		eval _precmd=\$${_arg}_precmd
# > # >   		if [ -n "$_cmd" ]; then
# > # >   					# if the precmd failed and force
# > # >   					# isn't set, exit
# > # > --- 323,329 ----
# > # >   					# if there's a custom ${XXX_cmd},
# > # >   					# run that instead of the default
# > # >   					#
# > # > ! 		eval _cmd=\$${_arg}_cmd _precmd=\$${_arg}_precmd
# > # >   		if [ -n "$_cmd" ]; then
# > # >   					# if the precmd failed and force
# > # >   					# isn't set, exit
# > # > *************** run_rc_script()
# > # > *** 515,528 ****
# > # >   		err 3 'USAGE: run_rc_script file arg'
# > # >   	fi
# > # >
# > # > ! 	case "$_file" in
# > # > ! 	*.sh)				# run in current shell
# > # >   		set $_arg ; . $_file
# > # > ! 		;;
# > # > ! 	*)				# run in subshell
# > # > ! 		( set $_arg ; . $_file )
# > # > ! 		;;
# > # > ! 	esac
# > # >   }
# > # >
# > # >   #
# > # > --- 512,532 ----
# > # >   		err 3 'USAGE: run_rc_script file arg'
# > # >   	fi
# > # >
# > # > ! 	if [ -n "$rc_fast_and_loose" ]; then
# > # > ! 		unset name command command_args extra_commands pidfile rcvar
# > # > ! 		unset required_dirs required_files required_vars
# > # > ! 		eval unset ${_arg}_cmd ${_arg}_precmd
# > # >   		set $_arg ; . $_file
# > # > ! 	else
# > # > ! 		case "$_file" in
# > # > ! 		*.sh)				# run in current shell
# > # > ! 			set $_arg ; . $_file
# > # > ! 			;;
# > # > ! 		*)				# run in subshell
# > # > ! 			( set $_arg ; . $_file )
# > # > ! 			;;
# > # > ! 		esac
# > # > ! 	fi
# > # >   }
# > # >
# > # >   #
# > # > *************** load_rc_config()
# > # > *** 536,542 ****
# > # >   		err 3 'USAGE: load_rc_config command'
# > # >   	fi
# > # >
# > # > ! 	. /etc/rc.conf
# > # >   	if [ -f /etc/rc.conf.d/"$_command" ]; then
# > # >   		. /etc/rc.conf.d/"$_command"
# > # >   	fi
# > # > --- 540,549 ----
# > # >   		err 3 'USAGE: load_rc_config command'
# > # >   	fi
# > # >
# > # > ! 	if [ -z "$_rc_conf_loaded" ]; then
# > # > ! 		. /etc/rc.conf
# > # > ! 		_rc_conf_loaded=YES
# > # > ! 	fi
# > # >   	if [ -f /etc/rc.conf.d/"$_command" ]; then
# > # >   		. /etc/rc.conf.d/"$_command"
# > # >   	fi
# > #
# > # --
# > # Luke Mewburn  <lukem@wasabisystems.com>  http://www.wasabisystems.com
# > # Luke Mewburn     <lukem@netbsd.org>      http://www.netbsd.org
# > # Wasabi Systems - providing NetBSD sales, support and service.
# > #
# >
# >
# > 				--*greywolf;
# > --
# > *BSD:  For IQs higher than 120.
#
# --
# Luke Mewburn  <lukem@wasabisystems.com>  http://www.wasabisystems.com
# Luke Mewburn     <lukem@netbsd.org>      http://www.netbsd.org
# Wasabi Systems - providing NetBSD sales, support and service.
#


				--*greywolf;
--
*BSD: it'll be there when you're ready for it.