Thread (12 messages) flat view 12 messages, 4 authors, 2008-02-20

Re: [PATCH 1/3] Fix Unlikely(x) == y

From: Willy Tarreau <w@1wt.eu>
Date: 2008-02-20 07:33:17
Also in: lkml

On Tue, Feb 19, 2008 at 10:28:46AM +0100, Andi Kleen wrote:
quoted
Sometimes, for performance critical paths, I would like gcc to be dumb and
follow *my* code and not its hard-coded probabilities. 
If you really want that, simple: just disable optimization @)
already tried. It fixed some difficulties, but create new expected issues
with data being reloaded often from memory instead of being passed along
a few registers. Don't forget that optimizing for x86 requires a lot of
smartness from the compiler because of the very small number of registers!
quoted
Maybe one thing we would need would be the ability to assign probabilities
to each branch based on what we expect, so that gcc could build a better
tree keeping most frequently used code tight.
Just use profile feedback then for user space. I don't think it's a good
idea for kernel code though because it leads to unreproducible binaries
which would wreck the development model.
I never found this to be practically usable in fact, because you have to
use it on the *exact* same source. End of game for cross-compilation. It
would be good to be able to use a few pragmas in the code to say "hey, I
want this block optimized like this". This is what I understood the
__builtin_expect() was for, except that it tends to throw unpredicted
branches too far away.
quoted
Hmm I've just noticed -fno-guess-branch-probability in the man, I never tried
it.
Or -fno-reorder-blocks
Thanks for the hint, I will try it.

Willy
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help