From: Michal Marek <mmarek@suse.com>
To: Alexey Dobriyan <adobriyan@gmail.com>
Cc: akpm@linux-foundation.org, linux-kbuild@vger.kernel.org
Subject: Re: [PATCH] fixdep: faster CONFIG_ search
Date: Tue, 23 Aug 2016 23:29:37 +0200 [thread overview]
Message-ID: <57BCC041.8060204@suse.com> (raw)
In-Reply-To: <20160823184724.GA11707@p183.telecom.by>
Dne 23.8.2016 v 20:47 Alexey Dobriyan napsal(a):
> Do you think kernel build is 100% dominated by gcc? You are wrong!
> One small utility called "fixdep" consistently manages to sneak into
> profile's first page (unless you have small monitor of course).
>
> The choke point is this clever code:
>
> for (; m < end; m++) {
> if (*m == INT_CONF) { p = (char *) m ; goto conf; }
> if (*m == INT_ONFI) { p = (char *) m-1; goto conf; }
> if (*m == INT_NFIG) { p = (char *) m-2; goto conf; }
> if (*m == INT_FIG_) { p = (char *) m-3; goto conf; }
>
> 4 branches per 4 characters is not fast.
>
> Use strstr(3), so that SSE2 etc can be used.
It should be noted that the previous code also matched nested CONFIG_*
strings, like CONFIG_PROC inside CONFIG_IKCONFIG_PROC. But these are
pointless, so your patch is removing a few false matches.
> With this patch, fixdep is so deep at the bottom, it is hard to find it.
Nice.
> - if (*m == INT_CONF) { p = (char *) m ; goto conf; }
> - if (*m == INT_ONFI) { p = (char *) m-1; goto conf; }
> - if (*m == INT_NFIG) { p = (char *) m-2; goto conf; }
> - if (*m == INT_FIG_) { p = (char *) m-3; goto conf; }
Please also remove the INT_* definitions and the test at startup.
> + map = malloc(st.st_size + 1);
> + if (!map) {
> + perror("fixdep: malloc");
> close(fd);
> return;
> }
> + if (read(fd, map, st.st_size) != st.st_size) {
> + perror("fixdep: read");
> + close(fd);
> + return;
> + }
I wanted to suggest memmem() instead of strstr() to avoid the extra
copy, but that would make use depend on glibc (this _might_ have been
the reason to use the manual string search, in fact). So let's leave
this as.
Michal
next prev parent reply other threads:[~2016-08-23 21:29 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-23 18:47 [PATCH] fixdep: faster CONFIG_ search Alexey Dobriyan
2016-08-23 21:29 ` Michal Marek [this message]
2016-08-24 5:01 ` Sam Ravnborg
2016-08-24 7:19 ` Alexey Dobriyan
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=57BCC041.8060204@suse.com \
--to=mmarek@suse.com \
--cc=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kbuild@vger.kernel.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.