JDK-8315924 : G1: Races in CHT growing cause memory waste in hash tables
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: gc
  • Affected Version: 22
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2023-09-08
  • Updated: 2025-11-14
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.
Other
tbdUnresolved
Related Reports
Relates :  
Description
Element insertion in CHT with G1 is typically  structured as follows:

_table.insert(..., &grow_hint);
[...]
if (grow_hint) {
  _table.grow();
}

The problem is that in the time between insertion and growing additional threads can queue up to grow the table.

E.g.
Thread A: insert(... , grow_hint = true);
Thread B: insert(... , grow_hint = true);
Thread A: grow()
Thread B: grow()

There is some simplistic mechanism to cancel table growing in CHT's grow() call, but it does not seem sufficient.

This is particularly apparent after use of a CHT with the same structure for code roots in JDK-8315503, but can also be seen with the card set to a lesser degree.
Comments
Here's a particularly bad case for Code Roots with JDK-8315503: `CodeRootSet CHT table size 1048576 entries 76268` I.e. the table has 1M buckets, with 76k entries in it after some time...
08-09-2023