RFR: JDK-8283674: Pad ObjectMonitor allocation size to cache line size

Martin Doerr mdoerr at openjdk.java.net
Mon Mar 28 13:12:49 UTC 2022


On Fri, 25 Mar 2022 09:02:28 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:

> See discussion under [1].
> 
> Since the libc malloc allocator may place ObjectMonitor instances adjacent to each other, we should pad the size of ObjectMonitor to fill a whole cache line to prevent false sharing between adjacent OMs.
> 
> [1] https://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/2022-March/054187.html

I also believe that false sharing is problematic for ObjectMonitors. But I agree with that some performance data would be interesting.
Note that padding only avoids that the same fields of different ObjectMonitors can end up on the same cache line. The beginning of the next one can still fall into the same cache line as the previous one. We'd need alignment to fix that. Nevertheless, padding should at least improve the situation.

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

PR: https://git.openjdk.java.net/jdk/pull/7955


More information about the hotspot-runtime-dev mailing list