You are not logged in.

#1 2009-01-07 22:50:19

vh22
Member
Registered: 2009-01-07
Posts: 10

A faster default

Hello,

Recently I've been playing around with getting Arch to boot as fast as possible. Most of the changes I made make the boot process specific to my machine (turning off autodetect, loading modules manually...etc). But there was one change that I believe introduced no instability and I wonder why its not included by default.

In /etc/rc.sysinit starting on line 119 of a vanilla file

/sbin/udevadm trigger
/sbin/udevadm settle

These lines occur many lines after the udev daemon has been loaded. My question is why not move the trigger line to right after the udev deamon is loaded and run it in the background by default?

So the settle line stays in the same spot it is, but move the trigger line up and make make it run in the background:
(line 77)

 /sbin/udevd --daemon
/sbin/udevadm trigger &

This sped my system up by about 5 seconds and there doesn't seem to be any instability ( I don't see why there would be). So is it possible this could be made the default?

Last edited by vh22 (2009-01-07 22:50:52)

Offline

#2 2009-01-07 23:03:53

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: A faster default

Submit a feature request on the bugtracker.

Offline

#3 2009-01-07 23:16:02

vh22
Member
Registered: 2009-01-07
Posts: 10

Re: A faster default

Thanks for the suggestion. I just submitted the request.

Offline

#4 2009-01-07 23:25:34

fwojciec
Member
Registered: 2007-05-20
Posts: 1,411

Re: A faster default

What do you mean by reduce the time by 5 seconds?  Because on my system the udev load time that's displayed during startup  is apparently reduced, but the overall boot time (checked with bootchart) remains exactly the same.

Offline

#5 2009-01-07 23:30:48

vh22
Member
Registered: 2009-01-07
Posts: 10

Re: A faster default

Yes the the udev load time is definitely reduced, but it slows down the loading of the modules since udevadm trigger is running in the background now. I suppose on your system, they balanced out. On my system, I got a net -5 seconds on the boot time. I haven't tested this out on many systems (don't have that many systems to test it on) but I would be happy if other people could try it and see if it helps them.

If it turns out not to help people, I could always retract the request.

Offline

#6 2009-01-07 23:37:00

kevin89
Arch Linux f@h Team Member
From: Netherlands
Registered: 2007-03-14
Posts: 218

Re: A faster default

It took down my udev processing time from 700ms to 1ms ! yikes

Offline

#7 2009-01-07 23:40:49

vh22
Member
Registered: 2009-01-07
Posts: 10

Re: A faster default

Your time was already fast to begin with. My udev processing time was originally 4000-5000ms.

Offline

#8 2009-01-07 23:42:12

fwojciec
Member
Registered: 2007-05-20
Posts: 1,411

Re: A faster default

kevin89 wrote:

It took down my udev processing time from 700ms to 1ms ! yikes

It does that, but on two different systems here it gives no improvement as far as overall boot time is concerned. 

@vh22: Don't let my results discourage you -- if it makes a difference on some systems then it should definitely be considered by the devs.  Both systems I've tried this tweak on boot pretty fast as is -- 22 and 15 seconds -- so I'm not sure how much more room for improvement there is in my case.

Offline

#9 2009-01-08 00:31:36

Duologic
Member
From: Belgium
Registered: 2007-11-11
Posts: 249

Re: A faster default

I'm using vh22 suggestion for a few months already and included in my latest installation too: see here

I think there are more modifications possible to /etc/rc.sysinit to speed it up, also for any system.
vh22, Can you post your /etc/rc.sysinit, just to compare.

Offline

#10 2009-01-08 00:48:22

vh22
Member
Registered: 2009-01-07
Posts: 10

Re: A faster default

I haven't been using Linux for that long so I probably didn't make as many modifications as you. All I really did was rip most of the stuff I didn't need out.

#!/bin/bash
#
# /etc/rc.sysinit
#

. /etc/rc.conf
. /etc/rc.d/functions

echo " "
printhl "Arch Linux\n"
printhl "${C_H2}http://www.archlinux.org"
printhl "Copyright 2002-2007 Judd Vinet"
printhl "Copyright 2007-2008 Aaron Griffin"
printhl "Distributed under the GNU General Public License (GPL)"
printsep

# mount /proc, /sys and our RAM /dev
/bin/mount -n -t ramfs none /dev
/bin/mount -n -t proc none /proc
/bin/mount -n -t sysfs none /sys

# Create our default nodes that minilogd may need
/bin/mknod /dev/null c 1 3
/bin/mknod /dev/zero c 1 5
/bin/mknod /dev/console c 5 1

# More initial /dev setup that udev doesn't do
/bin/ln -snf /proc/self/fd /dev/fd
/bin/ln -snf /proc/self/fd/0 /dev/stdin
/bin/ln -snf /proc/self/fd/1 /dev/stdout
/bin/ln -snf /proc/self/fd/2 /dev/stderr
/bin/ln -snf /proc/kcore /dev/core
/bin/mkdir /dev/pts
/bin/mkdir /dev/shm

# start up our mini logger until syslog takes over
/sbin/minilogd

# anything more serious than KERN_WARNING goes to the console
# 'verbose' cmdline parameter enables more messages
if /bin/grep -q " verbose" /proc/cmdline; then
    /bin/dmesg -n 8
else
    /bin/dmesg -n 3
fi

# enable rtc access
/sbin/modprobe rtc-cmos >/dev/null 2>&1
RTC_MAJOR=$(/bin/grep -w rtc /proc/devices 2>/dev/null); RTC_MAJOR="${RTC_MAJOR%% *}"
if [ -n "$RTC_MAJOR" ]; then
    /bin/mkdir /dev/misc/
    /bin/mknod /dev/misc/rtc0 c $RTC_MAJOR 0
    /bin/ln -s /dev/misc/rtc0 /dev/rtc
fi

HWCLOCK_PARAMS="--hctosys"

# Set clock early to fix some bugs with filesystem checks
# Clock is set again later to match rc.conf
if [ -f /etc/localtime ]; then
    /sbin/hwclock $HWCLOCK_PARAMS --noadjfile
fi

echo > /proc/sys/kernel/hotplug

if [ -x /sbin/udevadm -a -d /sys/block ]; then
    # We have udev and /sys appears to be mounted, use UDev
    stat_busy "Starting UDev Daemon"
    /sbin/udevd --daemon
    /sbin/udevadm trigger &
    stat_done
else
    # Static /dev, our last resort
    status "Using static /dev filesystem" true
fi

# Load modules from the MODULES array defined in rc.conf
if ! [ "$load_modules" = "off" ]; then
    if [ -f /proc/modules ]; then
        stat_busy "Loading Modules"
        for mod in "${MODULES[@]}"; do
            if [ "$mod" = "${mod#!}" ]; then
                /sbin/modprobe $mod
            fi
        done
        stat_done
    fi
    if [ -d /proc/acpi ]; then
        stat_busy "Loading standard ACPI modules"
        ACPI_MODULES="ac battery button fan processor thermal"
        k="$(echo $BLACKLIST ${MOD_BLACKLIST[@]} | /bin/sed 's|-|_|g')"
        j="$(echo ${MODULES[@]} | /bin/sed 's|-|_|g')"
        #add disabled MODULES (!) to blacklist - much requested feature
        for m in ${j}; do
                [ "$m" != "${m#!}" ] && k="${k} ${m#!}"
        done
        # add disablemodules= from commandline to blacklist
        k="${k} $(echo ${disablemodules} | /bin/sed 's|-|_|g' | /bin/sed 's|,| |g')"
        for n in ${ACPI_MODULES}; do
            if ! echo ${k} | /bin/grep "\<$n\>" 2>&1 >/dev/null; then
                /sbin/modprobe $n > /dev/null 2>&1
            fi
        done
        stat_done
    fi
fi

# run udev uevents
if /bin/pidof -o %PPID /sbin/udevd >/dev/null; then
    stat_busy "Loading UDev uevents"
    udevstart="$(/bin/date +%s%0N)"
    /sbin/udevadm settle
    stat_done
    udevend="$(/bin/date +%s%0N)"
    printhl "   UDev uevent processing time: $((($udevend-$udevstart)/1000000))ms"
fi

# bring up the loopback interface
if [ -d /sys/class/net/lo ]; then
    stat_busy "Bringing up loopback interface"
    /sbin/ifconfig lo 127.0.0.1 up
    if [ $? -ne 0 ]; then
        stat_fail
    else
        stat_done
    fi
fi


status "Mounting Root Read-only" /bin/mount -n -o remount,ro /

FORCEFSCK=
[ -f /forcefsck ] && FORCEFSCK="-- -f"
NETFS="nonfs,nonfs4,nosmbfs,nocifs,nocodafs,noncpfs,nosysfs,noshfs,nofuse,nofuseblk"

if [ -x /sbin/fsck ]; then
    stat_busy "Checking Filesystems"
    if /bin/grep -qw quiet /proc/cmdline; then
        /sbin/fsck -A -T -C -a -t $NETFS $FORCEFSCK >/dev/null 2>&1
    else
        /sbin/fsck -A -T -C -a -t $NETFS $FORCEFSCK 2>/dev/null
    fi
    fsckret=$?
    if [ ${fsckret} -gt 1 ]; then
        stat_fail
        if [ $((${fsckret}&2)) -eq 2 ]; then
            echo
            echo "********************** REBOOT REQUIRED *********************"
            echo "*                                                          *"
            echo "* The system will be rebooted automatically in 15 seconds. *"
            echo "*                                                          *"
            echo "************************************************************"
            echo
            /bin/sleep 15
        else
            echo
            echo "*****************  FILESYSTEM CHECK FAILED  ****************"
            echo "*                                                          *"
            echo "*  Please repair manually and reboot. Note that the root   *"
            echo "*  file system is currently mounted read-only. To remount  *"
            echo "*  it read-write type: mount -n -o remount,rw /            *"
            echo "*  When you exit the maintenance shell the system will     *"
            echo "*  reboot automatically.                                   *"
            echo "*                                                          *"
            echo "************************************************************"
            echo
            /sbin/sulogin -p
        fi
        echo "Automatic reboot in progress..."
        /bin/umount -a
        /bin/mount -n -o remount,ro /
        /sbin/reboot -f
        exit 0
    fi
    stat_done
fi

stat_busy "Mounting Local Filesystems"
/bin/mount -F -n -o remount,rw /
/bin/rm -f /etc/mtab*
# make sure / gets written to /etc/mtab
/bin/mount -o remount,rw /
# Write /proc, /sys and /dev to /etc/mtab
if [ -e /proc/mounts ]; then
    /bin/grep -e "/proc " -e "/sys " -e "/dev " /proc/mounts >> /etc/mtab
fi
# now mount all the local filesystems
/bin/mount -a -t $NETFS
stat_done

status "Activating Swap" /sbin/swapon -a

stat_busy "Configuring System Clock"
if [ ! -f /var/lib/hwclock/adjtime ]; then
    echo "0.0 0 0.0" > /var/lib/hwclock/adjtime
fi
if [ "$TIMEZONE" != "" -a -e "/usr/share/zoneinfo/$TIMEZONE" ]; then
    /bin/rm -f /etc/localtime
    /bin/cp "/usr/share/zoneinfo/$TIMEZONE" /etc/localtime
fi

/sbin/hwclock $HWCLOCK_PARAMS
stat_done

if [ -f /var/run/random-seed ]; then
    stat_busy "Initializing Random Seed"
    /bin/cat /var/run/random-seed >/dev/urandom
    stat_done
fi

stat_busy "Removing Leftover Files"
/bin/rm -f /etc/nologin &>/dev/null &
/bin/rm -f /etc/shutdownpid &>/dev/null &
/bin/rm -f /var/lock/* &>/dev/null &
/bin/rm -rf /tmp/* /tmp/.* &>/dev/null &
/bin/rm -f /forcefsck &>/dev/null &
(cd /var/run && /usr/bin/find . ! -type d -exec /bin/rm -f -- {} \; )
: > /var/run/utmp &
# Keep {x,k,g}dm happy with xorg
/bin/mkdir /tmp/.ICE-unix && /bin/chmod 1777 /tmp/.ICE-unix
/bin/mkdir /tmp/.X11-unix && /bin/chmod 1777 /tmp/.X11-unix
stat_done

#status "Updating Shared Library Links" /sbin/ldconfig

if [ "$HOSTNAME" != "" ]; then
    status "Setting Hostname: $HOSTNAME" /bin/hostname $HOSTNAME
fi

# Set the NIS domain name, if necessary
[ -f /etc/conf.d/nisdomainname ] && . /etc/conf.d/nisdomainname
if [ "$NISDOMAINNAME" != "" ]; then
    status "Setting NIS Domain Name: $NISDOMAINNAME" /bin/nisdomainname $NISDOMAINNAME
fi

status "Updating Module Dependencies" /sbin/depmod -A

# Flush old locale settings
: >/etc/profile.d/locale.sh
/bin/chmod 755 /etc/profile.d/locale.sh
# Set user defined locale
[ -z "$LOCALE" ] && LOCALE="en_US"
stat_busy "Setting Locale: $LOCALE"
echo "export LANG=$LOCALE" >>/etc/profile.d/locale.sh
stat_done


if [ -n "$CONSOLEFONT" ]; then
    stat_busy "Loading Console Font: $CONSOLEFONT"
    #CONSOLEMAP in UTF-8 shouldn't be used
    if [ -n "$CONSOLEMAP" ] && echo "$LOCALE" | /bin/grep -qi utf ; then
        CONSOLEMAP=""
    fi
    for i in $(/usr/bin/seq 0 63); do
        if [ -n "$CONSOLEMAP" ]; then
            /usr/bin/setfont -m $CONSOLEMAP $CONSOLEFONT -C /dev/vc/${i} >/dev/null 2>&1
        else
            /usr/bin/setfont $CONSOLEFONT -C /dev/vc/${i} >/dev/null 2>&1
        fi
    done
    if [ $? -ne 0 ]; then
        stat_fail
    else
        for i in $(/usr/bin/seq 0 63); do
            printf "\e(K" > /dev/vc/${i}
        done
        # the $CONSOLE check helps us avoid this when running scripts from cron
        echo 'if [ "$CONSOLE" = "" -a "$TERM" = "linux" -a -t 1 ]; then printf "\e(K"; fi' >>/etc/profile.d/locale.sh
        stat_done
    fi
fi

# Adding persistent network/cdrom generated rules
if [ -f "/dev/.udev/tmp-rules--70-persistent-cd.rules" ]; then
    stat_busy "Adding persistent cdrom udev rules"
    /bin/cat /dev/.udev/tmp-rules--70-persistent-cd.rules >> /etc/udev/rules.d/70-persistent-cd.rules
    stat_done
fi
if [ -f "/dev/.udev/tmp-rules--70-persistent-net.rules" ]; then
    stat_busy "Adding persistent network udev rules"
    /bin/cat /dev/.udev/tmp-rules--70-persistent-net.rules >> /etc/udev/rules.d/70-persistent-net.rules
    stat_done
fi

# Save our dmesg output from this boot
if [ -f /var/log/dmesg.log ]; then
    /bin/rm /var/log/dmesg.log
fi
/bin/dmesg > /var/log/dmesg.log

# End of file

Offline

#11 2009-01-08 01:00:43

Duologic
Member
From: Belgium
Registered: 2007-11-11
Posts: 249

Re: A faster default

I gues putting following in background would help a bit too. It didn't gave me any problems.
And yes you can strip out some other stuff but not that it would make a signicantly difference, just for the kick :-D

/sbin/modprobe $mod &
/sbin/modprobe $n > /dev/null 2>&1 &
/sbin/udevadm settle &
status "Activating Swap" /sbin/swapon -a &

Although, I got one thing, but only 2 times or so, that my filesystems didn't mount.
Someone an idea? Did I put too much into background?

Offline

#12 2009-01-08 01:05:36

vh22
Member
Registered: 2009-01-07
Posts: 10

Re: A faster default

You have to take the background off of the settle command. If you don't a race condition is formed and the crashes will only happen if settle is not done before the filesystem check.

As for those modifications you just posted, right after I posted my file above, I looked through the file again and made those changes. It didn't speed it up past 15 seconds though.

Offline

#13 2009-01-08 01:23:33

Duologic
Member
From: Belgium
Registered: 2007-11-11
Posts: 249

Re: A faster default

uhm, first I thought strange that it didn't go faster but than I reminded that you load modules manualy.

I removed the ampersand of '/sbin/udevadm settled', I didn't slow my boot off, so that's a keep! Thanks.

Offline

#14 2009-01-09 16:51:25

jpe30
Member
Registered: 2009-01-02
Posts: 24

Re: A faster default

This was a great suggestion!  It decreased my udev event time by 2 seconds from 2*** down to 6**.

Offline

#15 2009-01-10 10:29:03

sm4tik
Member
From: Finland, Jyväskylä
Registered: 2006-11-05
Posts: 248
Website

Re: A faster default

Thanks for the tip. Not that I care too much about boot times, but I've nothing against booting ~5sec faster as my old thinkpad does now. No problems here so far.

Offline

#16 2009-01-10 13:18:12

baze
Member
Registered: 2005-10-30
Posts: 393

Re: A faster default

is this really completely safe or are there possible problems like race conditions or whatnot?

Offline

#17 2009-01-10 13:48:52

EVRAMP
Member
From: Czech Republic
Registered: 2008-10-03
Posts: 173
Website

Re: A faster default

As fwojciec said, this will show you much smaller number in ms, however real time is the same smile
Look at Duologic's topic, where he disables LVM, RAID, encrypted filesystems detection, cosnsole font etc. (he doesn't use these), which really speeds boot.

Last edited by EVRAMP (2009-01-10 13:49:41)

Offline

#18 2009-01-12 20:27:04

vh22
Member
Registered: 2009-01-07
Posts: 10

Re: A faster default

baze wrote:

is this really completely safe or are there possible problems like race conditions or whatnot?

There is no race condition. If you had set settle to the background to, then a race condition would be there, but since settle is still in the foreground, the boot process will wait for the queue to clear before proceeding so it is really no different than a regular boot from there on.


As fwojciec said, this will show you much smaller number in ms, however real time is the same smile
Look at Duologic's topic, where he disables LVM, RAID, encrypted filesystems detection, cosnsole font etc. (he doesn't use these), which really speeds boot.

Yes this will definately increase your udev processing time, but it may or may not increase overall boot time. Your best bet is to time it before and after to see if you gained anything. But I don't think removing the LVM, RAID and encrypted filesystem from the rc.sysinit really speeds up boot. It removes at most 3 if checks, which, if you don't need those parts anyway, will always fail so its pretty quick already. i could be wrong about this though.

Offline

#19 2009-01-17 15:51:54

Duologic
Member
From: Belgium
Registered: 2007-11-11
Posts: 249

Re: A faster default

Removing RAID, LVM and Encrypted does speed up, At least 3 instructions are kept from sending to the processor. And lesser lines means lesser reading/writing and memory usage.

Offline

#20 2009-01-17 15:55:54

andre.ramaciotti
Member
From: Brazil
Registered: 2007-04-06
Posts: 649

Re: A faster default

The question isn't if it speeds up, but if it's perceptible.


(lambda ())

Offline

#21 2009-01-22 20:37:02

sfauzia
Member
Registered: 2009-01-11
Posts: 88

Re: A faster default

Thank you so much! Boot up was perceptibly faster. 23 seconds instead of 28 big_smile

Correction: 22s! And I haven't even done anything else to improve boot speed, other than booting straight into X (without having to startx from the console) and using a lightweight install of Openbox smile

Last edited by sfauzia (2009-01-23 02:58:19)

Offline

#22 2009-01-22 23:17:27

Zariel
Member
Registered: 2008-10-07
Posts: 446

Re: A faster default

compile all modules into kernel for < 1ms udev ! big_smile

Offline

#23 2009-01-25 13:06:35

krum
Member
From: Grenoble - FR
Registered: 2008-04-10
Posts: 32

Re: A faster default

Hi guy,

It could be very helpfull to create a WIKI page on tuning archlinux to boot faster.
With this kind of advice and link to fastboot project and so on.

vh22, Duologic, everyone else, you find a new job wink

Edit:
Woops, I didn't see http://wiki.archlinux.org/index.php/Twe … _boot_time
Good job! wink

Next steep: a 5sec boot + get a SSD big_smile
http://www.youtube.com/watch?v=s7NxCM8ryF8

Last edited by krum (2009-01-25 13:15:55)

Offline

#24 2009-01-25 23:04:08

dyscoria
Member
Registered: 2008-01-10
Posts: 1,007

Re: A faster default

Duologic wrote:

Removing RAID, LVM and Encrypted does speed up, At least 3 instructions are kept from sending to the processor. And lesser lines means lesser reading/writing and memory usage.

Just tested it with bootchart and bootspeed remained exactly 18 seconds before and after changing rc.sysinit


flack 2.0.6: menu-driven BASH script to easily tag FLAC files (AUR)
knock-once 1.2: BASH script to easily create/send one-time sequences for knockd (forum/AUR)

Offline

#25 2009-01-26 07:55:05

Army
Member
Registered: 2007-12-07
Posts: 1,784

Re: A faster default

I tried this and had problems! I do network with wicd, which is started as daemon. On standard configuration it connects to my wireless and wired networks without any problems. When I did this change, the boot was really a bit faster, but no internet at all, even restarting wicd daemon didn't help. So in my opinion this shouldn't become standard in Archlinux!!!

I'll try it again, maybe something else was the culprit, but I'm 98,54% sure

Offline

Board footer

Powered by FluxBB