Re: [patch 00/2] improve .text size on gcc 4.0 and newer compilers

From: Ingo Molnar
Date: Thu Jan 05 2006 - 19:57:11 EST



* Linus Torvalds <torvalds@xxxxxxxx> wrote:

> > Especially if there enough profiling hits, it's usually a quick glance
> > to figure out the hotpath:
>
> Ehh. What's a "quick glance" to a human can be quite hard to automate.
> That's my point.
>
> If we do the "human quick glances", we won't be seeing much come out
> of this. That's what we've already been doing, for several years.
>
> I thought the discussion was about trying to automate this..

i think it could be automated reasonably well. An 80% effective "which
condition is judged incorrectly" decision could be made based on:

branch instruction with more than 10% of the average per-instruction
cycle count, followed by an at least 4-instruction sequence of
non-branch (and non-jump) instructions that have exactly zero
profiling hits. ('few hits' we are not interested in - those are not
likely/unlikely candidates)

another part is to feed this back into .c, automatically. I've done
DEBUG_INFO, gdb vmlinux and list *0x12341234 based scripts before, but
they are not always reliable. They could probably do something like: "if
the resulting source code contains a clear 'if (' sequence, modify it to
'if __unlikely (', or something like that.

i'd expect such a method to catch ~50-60% of the interesting cases, not
more. (the rest would be stuff the heuristics doesnt catch, and it would
also be stuff like 'while' or 'break' or 'goto', which are much harder
to rewrite automatically.

but it does feel quite a bit fragile.

Ingo
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/