From owner-freebsd-bugs@FreeBSD.ORG Tue Sep 1 20:10:05 2009 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 36ED1106566C for ; Tue, 1 Sep 2009 20:10:05 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 1481A8FC19 for ; Tue, 1 Sep 2009 20:10:05 +0000 (UTC) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id n81KA4Ub006841 for ; Tue, 1 Sep 2009 20:10:04 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id n81KA4Hk006840; Tue, 1 Sep 2009 20:10:04 GMT (envelope-from gnats) Resent-Date: Tue, 1 Sep 2009 20:10:04 GMT Resent-Message-Id: <200909012010.n81KA4Hk006840@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, alberto villa Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 36DE41065676 for ; Tue, 1 Sep 2009 20:09:58 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id 0CDA58FC0C for ; Tue, 1 Sep 2009 20:09:58 +0000 (UTC) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id n81K9veY028673 for ; Tue, 1 Sep 2009 20:09:57 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id n81K9vG0028672; Tue, 1 Sep 2009 20:09:57 GMT (envelope-from nobody) Message-Id: <200909012009.n81K9vG0028672@www.freebsd.org> Date: Tue, 1 Sep 2009 20:09:57 GMT From: alberto villa To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: conf/138460: [patch] start local rc scripts in background X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Sep 2009 20:10:05 -0000 >Number: 138460 >Category: conf >Synopsis: [patch] start local rc scripts in background >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Tue Sep 01 20:10:04 UTC 2009 >Closed-Date: >Last-Modified: >Originator: alberto villa >Release: FreeBSD 8-STABLE >Organization: >Environment: FreeBSD echo.hoth 8.0-BETA2 FreeBSD 8.0-BETA2 #11: Sat Aug 15 17:55:03 CEST 2009 root@echo.hoth:/usr/obj/usr/src/sys/TPR60 i386 >Description: starting every rc script in sequence makes long boot times. the only option to control this is background_dhclient, which can save up to 20 seconds, but local services take more than half the boot time >How-To-Repeat: >Fix: the attached patch (/etc/rc) checks for local scripts which don't have to start BEFORE other scripts: it should be safe to start them in background, unless they depend on other local scripts (this shouldn't happen, but it should be handled anyway) being able to control the behaviour with a rcvar (something like background_daemons=YES|NO) would be nice, but i wasn't able to get its value (for some reason, it resulted empty if read with load_rc_config 'background_daemons') a /sbin/rcorder modification would be also needed to handle local scripts which depend on other local scripts... with rcorder listing background able scripts at the end, it would be easy Patch attached with submission follows: --- /etc/rc.orig 2009-09-01 15:20:23.231449039 +0200 +++ /etc/rc 2009-09-01 19:01:23.412933856 +0200 @@ -92,7 +92,7 @@ esac done -unset files local_rc +unset files late_files local_rc # Now that disks are mounted, for each dir in $local_startup # search for init scripts that use the new rc.d semantics. @@ -113,7 +113,20 @@ ;; esac - run_rc_script ${_rc_elem} ${_boot} + case "$_rc_elem" in + /etc/rc.d/*) _skip_late=0 ;; + *) _skip_late=`grep --quiet '# BEFORE:' ${_rc_elem} 2>/dev/null; echo $?` ;; + esac + + if [ ${_skip_late} -eq 1 ]; then + late_files="$late_files $_rc_elem" + else + run_rc_script ${_rc_elem} ${_boot} + fi +done + +for _rc_elem in `echo ${late_files}`; do + run_rc_script ${_rc_elem} ${_boot} & done echo '' >Release-Note: >Audit-Trail: >Unformatted: