RFR (S): JEP-142: Reduce Cache Contention on Specified Fields (original) (raw)

Martijn Verburg martijnverburg at gmail.com
Fri Nov 23 02:19:34 PST 2012


Hi Aleksey,

Hi Martijn,

On 11/23/2012 01:55 AM, Martijn Verburg wrote: > Is this based on detecting the size of the cache line of the CPU the > JVM is running on and multiplying by two? Not yet. We use the constant 128 bytes, overridable with -XX:FieldPaddingWidth. The cache line detection is there in Hotspot, and I still need to wire this up into the patch. The really sad part is that we can not detect the presence of hardware prefetcher running without reading the MSRs, which might in the end require superuser privileges.

OK, that's fair - We have a Java tool that reads MSRs and graphs lots of interesting data. It has similar supreruser requirements under Linux (and don't even get me started on having to patch in Mac Hardware kernel drivers) :-). I'll get one of our engineers to jump in if they have a brainwave on this.

As an extra aside - I'm wondering if the IDE vendors could pick up > on this and actually visualise for you how your class will be laid > out. Would be useful when applying @Contented and making sure it's > padding as you'd want it to.

Yup, as soon as class is loaded by the VM, it is actually pretty easy to do, see: https://github.com/shipilev/java-field-layout

Awesome! I'm hoping that there's a lot of education and visualisation around this as marking fields, classes and groups as @Contended will have side effects that a day to day developer may not fully understand (like me!).

Thanks again on working on this, it certainly will help with performance as numbers of cores grows.

Cheers, Martijn



More information about the hotspot-dev mailing list