From 08b4245d70c6d7bc01efed0ce83bcd0310a41f18 Mon Sep 17 00:00:00 2001 From: Xiaolong Peng Date: Thu, 9 Apr 2026 10:44:43 -0700 Subject: [PATCH] nit: comments to explain why mutator_allocator_remaining_bytes needs to be added back when reset bytes_allocated_since_gc_start --- src/hotspot/share/gc/shenandoah/shenandoahFreeSet.hpp | 1 + src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/src/hotspot/share/gc/shenandoah/shenandoahFreeSet.hpp b/src/hotspot/share/gc/shenandoah/shenandoahFreeSet.hpp index 5b198c96015..2d9b6f13d5a 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahFreeSet.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahFreeSet.hpp @@ -694,6 +694,7 @@ public: // Return an approximation of the bytes allocated since GC start. The value returned is monotonically non-decreasing // in time within each GC cycle. For certain GC cycles, the value returned may include some bytes allocated before // the start of the current GC cycle. + // Bytes allocated since gc start includes the total unused bytes in mutator allocator reserved for CAS allocation. inline size_t get_bytes_allocated_since_gc_start() const { return _mutator_bytes_allocated_since_gc_start; } diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp index fec24747efc..c5574393324 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp @@ -2293,6 +2293,7 @@ void ShenandoahHeap::reset_bytes_allocated_since_gc_start() { // Single-gen Shenandoah uses global heuristics. unaccounted_bytes = heuristics()->force_alloc_rate_sample(actual_allocated); } + // Bytes allocated since gc start includes the total unused bytes in mutator allocator reserved for CAS allocation. _free_set->reset_bytes_allocated_since_gc_start(unaccounted_bytes + mutator_allocator_remaining_bytes); }