[arch-projects] [mkinitcpio][PATCH] 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 as /usr/bin/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 <teg@jklm.no> --- init | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/init b/init index 8e9ad90..98328ce 100644 --- a/init +++ b/init @@ -1,6 +1,10 @@ #!/usr/bin/ash PATH=/usr/bin +if [ -x /usr/bin/timestamp ]; then + RD_TIMESTAMP=$(/usr/bin/timestamp) +fi + . /init_functions mount -t proc proc /proc -o nosuid,noexec,nodev @@ -109,6 +113,6 @@ if [ "${udevd_running}" -eq 1 ]; then udevadm info --cleanup-db fi -exec env -i "TERM=$TERM" /sbin/switch_root /new_root $init "$@" +exec env -i "TERM=$TERM" "RD_TIMESTAMP=$RD_TIMESTAMP" /sbin/switch_root /new_root $init "$@" # vim: set ft=sh ts=4 sw=4 et: -- 1.7.10.1
On Sun, May 6, 2012 at 4:54 PM, Tom Gundersen <teg@jklm.no> wrote:
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 this is accepted, I suggest adding the following install hook (call it "timestamp" or something like that) to the systemd package: #!/bin/bash build() { add_binary /usr/lib/systemd/systemd-timestamp /usr/bin/timestamp } help() { cat <<HELPEOF When booted with systemd this allows systemd-analyze to tell how much time was spent in the initramfs. HELPEOF } # vim: set ft=sh ts=4 sw=4 et:
On Sun, May 6, 2012 at 9:59 AM, Tom Gundersen <teg@jklm.no> wrote:
On Sun, May 6, 2012 at 4:54 PM, Tom Gundersen <teg@jklm.no> wrote:
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 this is accepted, I suggest adding the following install hook (call it "timestamp" or something like that) to the systemd package:
#!/bin/bash
build() { add_binary /usr/lib/systemd/systemd-timestamp /usr/bin/timestamp I'm very confused as to why we would call the binary something different in the initramfs. Shouldn't we not screw around with the name?
}
help() { cat <<HELPEOF When booted with systemd this allows systemd-analyze to tell how much time was spent in the initramfs. HELPEOF }
# vim: set ft=sh ts=4 sw=4 et:
On Sun, May 06, 2012 at 05:37:11PM -0500, Dan McGee wrote:
On Sun, May 6, 2012 at 9:59 AM, Tom Gundersen <teg@jklm.no> wrote:
On Sun, May 6, 2012 at 4:54 PM, Tom Gundersen <teg@jklm.no> wrote:
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 this is accepted, I suggest adding the following install hook (call it "timestamp" or something like that) to the systemd package:
I'd call it systemd. It's unclear what's going to happen with early userspace a year from now wrt systemd possibly invading it in some way. We may as well start now with something more generically named to avoid having to possibly rename it at some point down the road.
#!/bin/bash
build() { add_binary /usr/lib/systemd/systemd-timestamp /usr/bin/timestamp
I'm very confused as to why we would call the binary something different in the initramfs. Shouldn't we not screw around with the name?
I'm inclined to agree with this. The namespacing should stay.
}
help() { cat <<HELPEOF When booted with systemd this allows systemd-analyze to tell how much time was spent in the initramfs. HELPEOF }
# vim: set ft=sh ts=4 sw=4 et:
On Mon, May 7, 2012 at 1:23 AM, Dave Reisner <d@falconindy.com> wrote:
On Sun, May 06, 2012 at 05:37:11PM -0500, Dan McGee wrote:
On Sun, May 6, 2012 at 9:59 AM, Tom Gundersen <teg@jklm.no> wrote:
On Sun, May 6, 2012 at 4:54 PM, Tom Gundersen <teg@jklm.no> wrote:
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 this is accepted, I suggest adding the following install hook (call it "timestamp" or something like that) to the systemd package:
I'd call it systemd. It's unclear what's going to happen with early userspace a year from now wrt systemd possibly invading it in some way. We may as well start now with something more generically named to avoid having to possibly rename it at some point down the road.
#!/bin/bash
build() { add_binary /usr/lib/systemd/systemd-timestamp /usr/bin/timestamp
I'm very confused as to why we would call the binary something different in the initramfs. Shouldn't we not screw around with the name?
I'm inclined to agree with this. The namespacing should stay.
If you want to think of this as "a hook that does systemd related things", then keeping the name makes the most sense. I was thinking it would be "a hook that records the timestamp, we just happen to use the systemd implementation" and that we'd add other hooks if we wanted more systemd features in the future. I'm fine with the way you and Dan suggest though. Do you want me to resubmit, or will you just change it when you apply it? -t
On May 6, 2012 7:29 PM, "Tom Gundersen" <teg@jklm.no> wrote:
On Mon, May 7, 2012 at 1:23 AM, Dave Reisner <d@falconindy.com> wrote:
On Sun, May 06, 2012 at 05:37:11PM -0500, Dan McGee wrote:
On Sun, May 6, 2012 at 9:59 AM, Tom Gundersen <teg@jklm.no> wrote:
On Sun, May 6, 2012 at 4:54 PM, Tom Gundersen <teg@jklm.no> wrote:
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 this is accepted, I suggest adding the following install hook
(call
it "timestamp" or something like that) to the systemd package:
I'd call it systemd. It's unclear what's going to happen with early userspace a year from now wrt systemd possibly invading it in some way. We may as well start now with something more generically named to avoid having to possibly rename it at some point down the road.
#!/bin/bash
build() { add_binary /usr/lib/systemd/systemd-timestamp /usr/bin/timestamp
I'm very confused as to why we would call the binary something different in the initramfs. Shouldn't we not screw around with the name?
I'm inclined to agree with this. The namespacing should stay.
If you want to think of this as "a hook that does systemd related things", then keeping the name makes the most sense. I was thinking it would be "a hook that records the timestamp, we just happen to use the systemd implementation" and that we'd add other hooks if we wanted more systemd features in the future.
I'm fine with the way you and Dan suggest though. Do you want me to resubmit, or will you just change it when you apply it?
-t
I'll fix it up when I apply it. I've got a few other minor nits to fix as well. Just out of curiosity, is there anything else that reads RD_TIMESTAMP (like Auke's boot chart)? That's part of why I'm hesistant to generalize it as a timestamp hook. d
On Mon, May 7, 2012 at 12:42 PM, Dave Reisner <d@falconindy.com> wrote:
Just out of curiosity, is there anything else that reads RD_TIMESTAMP (like Auke's boot chart)? That's part of why I'm hesistant to generalize it as a timestamp hook.
Not that I know of. As far as I know, the RD_* interface is only implemented by dracut and systemd, but it is meant to be generic[0] so anyone could in principle start using it. Btw, once we have a systemd-tools package I'll probably also add this (optionally) to initscripts so we can measure bootuptime there in the same way as systemd currently does. -t [0] hence the RamDisk prefix, rather than "dracut" or "systemd"
On Mon, May 07, 2012 at 01:28:41AM +0200, Tom Gundersen wrote:
On Mon, May 7, 2012 at 1:23 AM, Dave Reisner <d@falconindy.com> wrote:
On Sun, May 06, 2012 at 05:37:11PM -0500, Dan McGee wrote:
On Sun, May 6, 2012 at 9:59 AM, Tom Gundersen <teg@jklm.no> wrote:
On Sun, May 6, 2012 at 4:54 PM, Tom Gundersen <teg@jklm.no> wrote:
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 this is accepted, I suggest adding the following install hook (call it "timestamp" or something like that) to the systemd package:
I'd call it systemd. It's unclear what's going to happen with early userspace a year from now wrt systemd possibly invading it in some way. We may as well start now with something more generically named to avoid having to possibly rename it at some point down the road.
#!/bin/bash
build() { add_binary /usr/lib/systemd/systemd-timestamp /usr/bin/timestamp
I'm very confused as to why we would call the binary something different in the initramfs. Shouldn't we not screw around with the name?
I'm inclined to agree with this. The namespacing should stay.
If you want to think of this as "a hook that does systemd related things", then keeping the name makes the most sense. I was thinking it would be "a hook that records the timestamp, we just happen to use the systemd implementation" and that we'd add other hooks if we wanted more systemd features in the future.
I'm fine with the way you and Dan suggest though. Do you want me to resubmit, or will you just change it when you apply it?
-t
So, just to dig up this aging thread -- was revisiting this for applying. Based on how systemd has declared how it's invading early userspace, I'd say that this is better off being called timestamp. Stuffing everything needed into a single 'systemd' hook won't work out. Huzzah. d
participants (3)
-
Dan McGee
-
Dave Reisner
-
Tom Gundersen