JDK-8315884 : New Object to ObjectMonitor mapping
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 22
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2023-09-07
  • Updated: 2024-08-27
  • Resolved: 2024-08-16
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 24
24 b12Fixed
Related Reports
Blocks :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Sub Tasks
JDK-8338539 :  
JDK-8338658 :  
JDK-8338995 :  
Description
When an object has inflated a monitor, the locking system stores the address of the monitor in the markWord and displaces the hash code and other flags.  With Lilliput, the klass pointer is also kept in the markWord, so the displacement makes it error prone to access the class.  Now [~eosterlund] words:

The Concurrent Hash Table idea for object → objectMonitor mapping would solve the Klass accessing problem

Yes. There are two problems, relating to interactions between GC, concurrent deflation, and Liliput. To understand it, let’s remind ourselves the basic idea of concurrent deflation:

1) Reach linearization point that the OM is deflating
2) Unlink the OM from the markWord
3) Rendezvous all threads using the OM
4) Delete the OM

== Problem One ==
The first problem is that step 3) so far is implemented with a thread-local handshake with all JavaThreads, because surely only JavaThreads use the OM right?!
Well suddenly anyone reading the klass(), size() or doing oop_iterate() also uses the OM because with Liliput, the klass pointer doesn’t fit into the object when the monitor is inflated. So any concurrent GC needs to hook in to the rendezvous operation somehow.
That’s doable for generational ZGC because it uses the STS mechanism when processing objects. But it is not possible in original ZGC without major rewrites.

== Problem Two ==
I believe there is also at least a second problem impacting original ZGC and generational ZGC, and probably Shenandoah.
The unlinking in step 2) only applies to the to-space object. The OM looks up the object through a WeakHandle, which gives you the to-space object. There will however still be a link to the OM left behind in the from-space object, which isn’t visible to the application.
The OM link of the from-space object is visible from the GC, and it will crash when it tries to for example read the size() of the from-space object. In fact Roman has a crash with generational ZGC during relocation, and I think this is why.
Comments
Changeset: bd4160ce Branch: master Author: Axel Boldt-Christmas <aboldtch@openjdk.org> Date: 2024-08-16 06:20:17 +0000 URL: https://git.openjdk.org/jdk/commit/bd4160cea8b6b0fcf0507199ed76a12f5d0aaba9
16-08-2024

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/20067 Date: 2024-07-08 08:18:42 +0000
09-07-2024

I'm assigning this to Axel because he's the one who is driving the implementation work of our approach.
13-09-2023

[~rkennke] Yes, feel free to work on other things for the moment. We are currently evaluating the performance and stability of our implementation and looking into how to slot it in nicely with the rest of the code.
13-09-2023

Oh, ok :-) Does it make sense that I pause my effort for now, then?
13-09-2023

This is my version https://github.com/openjdk/jdk/pull/15605 but Erik, Stefan and Axel are taking this over and my version has deflation races. I did run some benchmarks on this and dacapo h2 with --size large was 20% slower. The rest weren't terrible.
13-09-2023

FWIW, I am working on something like this in the Lilliput project (very WIP, but kinda-works for some workloads, good enough to give some ideas about the direction of it): https://github.com/openjdk/lilliput/pull/106
13-09-2023

There are a number of performance concerns with using an explicit mapping between objects and their monitors. The basic lookup costs is of course a primary concern, but there are issues about footprint and "pauses" introduced when the map needs to grow (and shrink?).
11-09-2023