JDK-8170520 : Make Metaspace ChunkManager counters non-atomic
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 9
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2016-11-30
  • Updated: 2017-08-25
  • Resolved: 2017-04-04
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 10
10 b21Fixed
Related Reports
Relates :  
Relates :  
Description
In metaspace.cpp, ChunkManager keeps counters for the number of free chunks in all its free lists (_free_chunks_count) and combined size of all these chunks (_free_chunks_total). These counters are updated using Atomics. 

Supposedly because atomic updates are expensive, updates are delayed as much as possible. When returning chunks to the free list, instead of updating the counter for every returned chunk, the counter is updated for all chunks at once (~SpaceManager). This introduces time windows where the counters do not reflect the real state of the freelist, which makes it difficult to verify the internal state of the ChunkManager. 

The counters do not have to be updated atomically, because all accesses happen under lock protection. So the updates can be moved closer to the chunk return point and the window where counters are invalid almost disappears, making the code easier.