JDK-8309627 : Incorrect sorting of DirtyCardQueue buffers
  • Type: Bug
  • Component: hotspot
  • Sub-Component: gc
  • Affected Version: 21
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2023-06-07
  • Updated: 2023-06-15
  • Resolved: 2023-06-10
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 22
22 b02Fixed
Related Reports
Relates :  
Relates :  
Description
When refining a buffer of cards, the buffer is first sorted, to improve locality.  However, the sort function's return type is wrong.  G1RefineBufferedCards::compare_card uses the difference between the cards as the result (negative -> lt, zero -> eq, positive -> gt).  But it returns an int, so discards all but the low 32 bits of that difference.  This renders the "sort" potentially more of a "randomizer".  However, since the pointers being compared are in the card table, the range of the results probably fit in 32bits.  Only for really large heaps or small card sizes (after JDK-8272773 made GCCardSizeInBytes configurable) are we likely to lose any bits from the narrowing conversion.

Comments
Changeset: b94b679e Author: Kim Barrett <kbarrett@openjdk.org> Date: 2023-06-10 17:08:46 +0000 URL: https://git.openjdk.org/jdk/commit/b94b679e9a82ff2ee6daee9631ce707e9b9eaf6b
10-06-2023

Gauging impact: This impacts sorter when ptrdiff_t narrows to int, losing precision. This happens when ptrdiff_t is larger than 2 gigapointers, which means the card table is larger than 16GB. With default card size of 512 bytes, this means a heap larger than 8TB. Even with lowest card size of 128 bytes, this still requires 2TB heap. This is within reach of current workloads, although rare.
08-06-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/14365 Date: 2023-06-07 18:02:37 +0000
07-06-2023