8386992: Shenandoah: Pad hot atomic counters to avoid false sharing on the allocation path

Reviewed-by: shade, ruili
This commit is contained in:
Xiaolong Peng 2026-06-23 17:40:17 +00:00
parent d3d560f756
commit b06aa89c60
2 changed files with 6 additions and 0 deletions

View File

@ -25,6 +25,7 @@
#ifndef SHARE_GC_SHENANDOAH_SHENANDOAHALLOCRATE_HPP
#define SHARE_GC_SHENANDOAH_SHENANDOAHALLOCRATE_HPP
#include "gc/shenandoah/shenandoahPadding.hpp"
#include "gc/shenandoah/shenandoahWeightedSeq.hpp"
#include "runtime/atomic.hpp"
#include "runtime/mutex.hpp"
@ -110,7 +111,9 @@ class ShenandoahAllocRate {
static constexpr size_t ALLOC_SAMPLE_MAX = G;
PaddedMonitor _sample_lock;
shenandoah_padding(0);
Atomic<size_t> _allocated_bytes_since_last_sample;
shenandoah_padding(1);
Atomic<size_t> _minimum_sample_size; // bytes, read by mutator, updated by gc
jlong _last_sample_time;

View File

@ -29,6 +29,7 @@
#include "gc/shenandoah/shenandoahAllocRequest.hpp"
#include "gc/shenandoah/shenandoahGeneration.hpp"
#include "gc/shenandoah/shenandoahGenerationalHeap.hpp"
#include "gc/shenandoah/shenandoahPadding.hpp"
#include "gc/shenandoah/shenandoahScanRemembered.hpp"
#include "gc/shenandoah/shenandoahSharedVariables.hpp"
@ -64,7 +65,9 @@ private:
// is therefore always accessed through atomic operations. This is increased when a
// PLAB is allocated for promotions. The value is decreased by the amount of memory
// remaining in a PLAB when it is retired.
shenandoah_padding(0);
Atomic<size_t> _promoted_expended;
shenandoah_padding(1);
// Represents the quantity of live bytes we expect to promote during the next GC cycle, either by
// evacuation or by promote-in-place. This value is used by the young heuristic to trigger mixed collections.