Richard W.M. Jones
2016-Mar-17 10:08 UTC
[Libguestfs] [PATCH 0/3] appliance: Pass "quiet" option to kernel when !verbose.
Using the quiet option (when not in verbose mode) improves boot speeds by rather a lot, by avoiding sending messages over the slow emulated UART. Rich.
Richard W.M. Jones
2016-Mar-17 10:08 UTC
[Libguestfs] [PATCH 1/3] appliance: Pass "quiet" option to kernel when !verbose.
The quiet option suppresses kernel messages. On my laptop it improves appliance boot times by about 40% (3.5s -> 2.5s). The emulated UART is slow and has a fixed, small FIFO (16 bytes). But it has the advantage of being a simple ISA device which is available very early in boot, thus enabling us to diagnose early boot problems. So the aim is to reduce our usage of this UART on fast paths. Of course when we are in verbose mode, we should not add this flag because we want to see all the messages. This change is not entirely invisible: (1) Progress messages use the "Linux version ..." string from kernel output in order to determine part of where we are in the boot process. This string will no longer be detected. We should probably use a BIOS message or maybe drop this altogether. I have added a comment to the code. (2) It is possible for programs to be listening for GUESTFS_EVENT_APPLIANCE events, and they will see fewer messages now (although what kernel messages programs see is never defined). --- src/launch.c | 4 ++-- src/proto.c | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/launch.c b/src/launch.c index 958d4b3..074ac6f 100644 --- a/src/launch.c +++ b/src/launch.c @@ -351,7 +351,7 @@ guestfs_int_appliance_command_line (guestfs_h *g, const char *appliance_dev, " cgroup_disable=memory" /* saves us about 5 MB of RAM */ "%s" /* root=appliance_dev */ " %s" /* selinux */ - "%s" /* verbose */ + " %s" /* quiet/verbose */ "%s" /* network */ " TERM=%s" /* TERM environment variable */ "%s%s" /* handle identifier */ @@ -362,7 +362,7 @@ guestfs_int_appliance_command_line (guestfs_h *g, const char *appliance_dev, lpj_s, root, g->selinux ? "selinux=1 enforcing=0" : "selinux=0", - g->verbose ? " guestfs_verbose=1" : "", + g->verbose ? "guestfs_verbose=1" : "quiet", g->enable_network ? " guestfs_network=1" : "", term ? term : "linux", STRNEQ (g->identifier, "") ? " guestfs_identifier=" : "", diff --git a/src/proto.c b/src/proto.c index 5213856..df7be89 100644 --- a/src/proto.c +++ b/src/proto.c @@ -129,6 +129,9 @@ guestfs_int_log_message_callback (guestfs_h *g, const char *buf, size_t len) const char *sentinel; size_t slen; + /* Since 2016-03, if !verbose, then we add the "quiet" flag to the + * kernel, so the following sentinel will never be produced. XXX + */ sentinel = "Linux version"; /* kernel up */ slen = strlen (sentinel); if (memmem (buf, len, sentinel, slen) != NULL) -- 2.5.0
Richard W.M. Jones
2016-Mar-17 10:08 UTC
[Libguestfs] [PATCH 2/3] appliance: Make it clear that the init script is a bash script.
We have used /bin/sh here since 2009. However this is a bash script and probably won't work well with other shells. --- appliance/init | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appliance/init b/appliance/init index ee8c60e..21e7ab8 100755 --- a/appliance/init +++ b/appliance/init @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash echo Starting /init script ... -- 2.5.0
Richard W.M. Jones
2016-Mar-17 10:08 UTC
[Libguestfs] [PATCH 3/3] appliance: Quiet some warnings about missing files.
Try to make the appliance script as quiet as possible along the fast path. --- appliance/init | 2 ++ 1 file changed, 2 insertions(+) diff --git a/appliance/init b/appliance/init index 21e7ab8..f6fe9b9 100755 --- a/appliance/init +++ b/appliance/init @@ -81,9 +81,11 @@ fi # Disk optimizations. # Increase the SCSI timeout so we can read remote images. +shopt -s nullglob for f in /sys/block/sd*/device/timeout; do echo 300 > $f; done # https://access.redhat.com/site/solutions/5427 for f in /sys/block/{h,s,ub,v}d*/queue/scheduler; do echo noop > $f; done +shopt -u nullglob # Update the system clock. hwclock -u -s -- 2.5.0
Pino Toscano
2016-Mar-18 12:54 UTC
Re: [Libguestfs] [PATCH 1/3] appliance: Pass "quiet" option to kernel when !verbose.
On Thursday 17 March 2016 10:08:41 Richard W.M. Jones wrote:> The quiet option suppresses kernel messages. On my laptop it improves > appliance boot times by about 40% (3.5s -> 2.5s). > > The emulated UART is slow and has a fixed, small FIFO (16 bytes). But > it has the advantage of being a simple ISA device which is available > very early in boot, thus enabling us to diagnose early boot problems. > So the aim is to reduce our usage of this UART on fast paths. > > Of course when we are in verbose mode, we should not add this flag > because we want to see all the messages. > > This change is not entirely invisible: > > (1) Progress messages use the "Linux version ..." string from kernel > output in order to determine part of where we are in the boot process. > This string will no longer be detected. We should probably use a BIOS > message or maybe drop this altogether. I have added a comment to the > code. > > (2) It is possible for programs to be listening for > GUESTFS_EVENT_APPLIANCE events, and they will see fewer messages now > (although what kernel messages programs see is never defined).From what I see, these events were sent only after 5 seconds from the launch, so users of the library should (theoretically of course) be already prepared to not receive them. I guess that this could be mentioned in the commit message. -- Pino Toscano
Pino Toscano
2016-Mar-18 13:01 UTC
Re: [Libguestfs] [PATCH 0/3] appliance: Pass "quiet" option to kernel when !verbose.
On Thursday 17 March 2016 10:08:40 Richard W.M. Jones wrote:> Using the quiet option (when not in verbose mode) improves boot speeds > by rather a lot, by avoiding sending messages over the slow emulated > UART.The series LGTM. Thanks, -- Pino Toscano
Seemingly Similar Threads
- [PATCH 1/3] appliance: Pass "quiet" option to kernel when !verbose.
- [PATCH v3 0/11] tests/qemu: Add program for tracing and analyzing boot times.
- [PATCH 0/3] protocol: Abstract out socket operations.
- [PATCH v4 0/6] tests/qemu: Add program for tracing and analyzing boot times.
- [PATCH v2 0/7] tests/qemu: Add program for tracing and analyzing boot times.