From 7eb40daaae07520557d20fd41941026108faddfa Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Thu, 17 May 2012 22:18:47 -0400 Subject: init: add timestamp at start of initramfs if binary exists This will allow us to tell how much time was spent in the initramfs, which might be good for working on optimizations and making sure we don't regress. If a binary able to produce the timestamp is not installed this is a noop. I'll post separately an install hook to the systemd package that will install systemd-timestamp. However, it would be trivial to replace this by an independent implementation if people want to use this without systemd. With this patch I get the following on my (ancient) laptop: $ systemd-analyze Startup finished in 294ms (kernel) + 2684ms (initramfs) + 15741ms (userspace) = 18720ms FWIW, 1 second is spent on inserting the needed modules, and 1.5 seconds on mounting the rootfs (mounting btrfs is slow!). Signed-off-by: Tom Gundersen Signed-off-by: Dave Reisner --- init | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/init b/init index c4b318a..d77c545 100644 --- a/init +++ b/init @@ -2,6 +2,10 @@ PATH=/usr/bin udevd_running=0 +if [ -x /usr/bin/systemd-timestamp ]; then + RD_TIMESTAMP=$(systemd-timestamp) +fi + . /init_functions mount -t proc proc /proc -o nosuid,noexec,nodev @@ -72,6 +76,9 @@ if [ "${break}" = "postmount" ]; then launch_interactive_shell fi -exec env -i "TERM=$TERM" /sbin/switch_root /new_root $init "$@" +exec env -i \ + "TERM=$TERM" \ + "RD_TIMESTAMP=$RD_TIMESTAMP" \ + /usr/bin/switch_root /new_root $init "$@" # vim: set ft=sh ts=4 sw=4 et: -- cgit v1.2.3-24-g4f1b