All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Reiser <jreiser-Po6cBsTGB2ZWk0Htik3J/w@public.gmane.org>
To: initramfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: build initramfs: logging is slow
Date: Tue, 06 Sep 2011 09:55:50 -0700	[thread overview]
Message-ID: <4E665096.3080308@bitwagon.com> (raw)

Commenting out this line from inst_simple:
    ddebug "Installing $_src"
saves me about 10% real time (not counting final gzip) in build initramfs.

The low-level culprit is the extra _process_ [fork or clone] for $(_lvl2char ...) in:
----- dracut-logger
_do_dlog() {
    [ -z "$maxloglvl" ] && return 0
    local lvl="$1"; shift
    local lvlc=$(_lvl2char "$lvl") || return 0    ### SLOW!

    [ $lvl -le $maxloglvl ] || return 0
-----

Instead, the level translation should be done using an indexed array
(after an arithmetic check for index-out-of-range.)

Even better, the level comparison should be hoisted into the definition
of ddebug and dtrace, such as:
-----
ddebug() {
    [ 5 -le $maxloglvl ] || return 0
    set +x
    dlog 5 "$@"
}
-----

If bash could conditionally re-define a function, then dlog_init might:
    [ 5 -le $maxloglvl ]  ||  eval "function ddebug() {}"
but that did not work for me.

-- 

                 reply	other threads:[~2011-09-06 16:55 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E665096.3080308@bitwagon.com \
    --to=jreiser-po6cbstgb2zwk0htik3j/w@public.gmane.org \
    --cc=initramfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.