On Wed, 2 Sep 2026 14:18:29 GMT, Fredrik Bredberg <[email protected]> wrote:

>> `_metadata`, formerly known as `_header`, was a hot field and
>> `_owner` was a hot field. More than a decade ago we added padding
>> between `_header` and `_owner` and we had targeted microbenchmarks
>> that proved the padding prevented false sharing on X64 (and SPARC64).
>> I don't remember testing aarch64 back then. For the more general
>> benchmarks, I think there were minor improvements at most.
>> 
>> `_object` was not a hot field and we put it adjacent to `_header` as a 
>> lightly
>> used field. I believe `_object` is still lightly used. With the removal of 
>> `_header`
>> AKA `_metadata`, we no longer need this padding:
>> 
>> 
>> DEFINE_PAD_MINUS_SIZE(0, OM_CACHE_LINE_SIZE, sizeof(_object));
>
> Yes `_metadata` contained the old (displaced) header for all locking modes 
> except lightweight for which it contained the hash code. The header was hot, 
> the hash was not. Anyhow now since I removed `_metadata`, `_object` kind of 
> floated up and though it's not really hot, it's not totally cold either. It's 
> read in the `ObjectMonitorTable` lookup code, both from C2 and from the slow 
> path. So you can theorize and claim that if you need to do linear probing to 
> find your monitor in the OMT (because of hash-collisions), you should 
> (theoretically) benefit from having the `_object` and the `_owner` in 
> separate cashe lines. Because you might read the `_object` pointer from a 
> monitor which is not the monitor you're looking for at the same time as the 
> `_owner` is changed by someone else using CAS. Hence the comment about 
> __object does not change, but it's frequently read during ObjectMonitorTable 
> lookups_. But after David's comment I ran some performance tests with, and 
> without the padding,
 and even though having padding was overall slightly better, it was really 
nothing to write home about. However removing the padding did improve the 
performance of the Xalan test on linux-aarch64 by 16%. We (runtime team)  had a 
meeting and decided that `_object` is not hot enough to justify the need for 
padding, so I will remove it.

Removed the padding, and the comment.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/32573#discussion_r3915521539

Reply via email to