Package: hotplug Version: 0.0.20040329-22 Severity: wishlist Tags: patch
Attached is a patch for '/etc/hotplug.d/default/default.hotplug'. It replaces some loop code, (which on my system causes nine 'basename' piped to 'sed' calls), with equivalent code that uses built-in POSIX shell parameter substitutions; substitutions work in 'ash', 'dash', 'bash', and so forth -- all the Debian boot shells. The benefit is that there's no need to make pipes or spawn shells, since the parsing functions are already in memory. Note: I wrote this tweak after reading about 'hotplug-perl': http://opensource.idealcorp.com/hotplug-perl/ ...where its author reports that on his system "hotplug-perl reduced the boot time by 53 seconds making the init to X Window time approximately 47 seconds". It got me wondering, "what can perl do that's so much faster?", so I looked at some 'hotplug' code, and this is the first obvious tweak I noticed. Mabye other similar tweaks can be done... Another thing -- in theory the shell script 'hotplug' might be made faster than the 'perl' version; all other things being equal, any shell interpreter needs less RAM than 'perl'; so any CPU would cache it better. Hope this helps... -- System Information: Debian Release: 3.1 APT prefers unstable APT policy: (500, 'unstable'), (1, 'experimental') Architecture: i386 (i686) Shell: /bin/sh linked to /bin/dash Kernel: Linux 2.6.11-1-686 Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968) (ignored: LC_ALL set to C) Versions of packages hotplug depends on: ii bash 3.0-14 The GNU Bourne Again SHell ii debconf 1.4.49 Debian configuration management sy ii grep 2.5.1.ds1-4 GNU grep, egrep and fgrep ii module-init-tools 3.2-pre1-2 tools for managing Linux kernel mo ii modutils 2.4.27.0-3 Linux module utilities ii procps 1:3.2.5-1 /proc file system utilities ii sed 4.1.4-2 The GNU sed stream editor -- debconf information excluded
--- /etc/hotplug.d/default/default.hotplug 2005-02-16 12:15:46.000000000 -0500 +++ /tmp/default.hotplug 2005-05-18 01:44:00.000000000 -0400 @@ -47,12 +47,12 @@ AGENTS="" for AGENT in /etc/hotplug/*.agent ; do - TYPE=`basename $AGENT | sed s/.agent//` - if [ -x $AGENT ]; then - AGENTS="$AGENTS $TYPE" - else - AGENTS="$AGENTS ($TYPE)" + TYPE=${AGENT##*/} # chop off path (like 'basename', but cheaper) + TYPE=${TYPE%%.agent} # chop off extension + if [ ! -x $AGENT ]; then # not an exec? + TYPE="($TYPE)" # add parenthesis fi + AGENTS="$AGENTS $TYPE" done echo "AgentName values on this system: $AGENTS" else