Branch Prediction?

Christian Thalinger christian.thalinger at oracle.com
Tue Nov 18 18:41:28 UTC 2014


I’m not sure if the silence means nobody knows or nobody cares.  Speaking for myself, I don’t know of any history on this.

> On Nov 8, 2014, at 1:43 AM, Erik Österlund <erik.osterlund at lnu.se> wrote:
> 
> Hi,
> 
> Just out of curiosity, is there some good reason why we don't have a branch prediction macro?
> For every tight load a; cmpxchg(expect: a, addr: &x, new_val: b); loop, I feel a bit uneasy not telling the compiler that this is pretty likely to succeed, and relying on its guessing.
> 
> Has it been excluded because it's considered not nice or perhaps it was simply never introduced because nobody found it useful?
> 
> Could have some define like this for GCC, which for other compilers reduces to nothing:
> 
> #define VM_EXPECT_TRUE(A) __builtin_expect((A), true)
> #define VM_EXPECT_FALSE(A) __builtin_expect((A), false)
> 
> It might not lead to drastic performance improvements, but it feels weird not to tell the compiler what we know and keep secrets from it. And I think it's also nice for documentation purposes that people reading it also understand that this expression is gonna be true most of the time, and deal with it accordingly.
> 
> /Erik



More information about the hotspot-dev mailing list