8325516: Shenandoah: Move heap change tracking into ShenandoahHeap

Reviewed-by: shade, kdnilsen, ysr
This commit is contained in:
William Kemper 2024-02-09 07:42:57 +00:00 committed by Aleksey Shipilev
parent 8d9ad97c29
commit cc276ff0df
4 changed files with 13 additions and 13 deletions

View File

@ -295,7 +295,7 @@ void ShenandoahControlThread::run_service() {
// Wait before performing the next action. If allocation happened during this wait,
// we exit sooner, to let heuristics re-evaluate new conditions. If we are at idle,
// back off exponentially.
if (_heap_changed.try_unset()) {
if (heap->has_changed()) {
sleep = ShenandoahControlIntervalMin;
} else if ((current - last_sleep_adjust_time) * 1000 > ShenandoahControlIntervalAdjustPeriod){
sleep = MIN2<int>(ShenandoahControlIntervalMax, MAX2(1, sleep * 2));
@ -512,14 +512,6 @@ void ShenandoahControlThread::notify_gc_waiters() {
ml.notify_all();
}
void ShenandoahControlThread::notify_heap_changed() {
// This is called from allocation path, and thus should be fast.
// Notify that something had changed.
if (_heap_changed.is_unset()) {
_heap_changed.set();
}
}
void ShenandoahControlThread::pacing_notify_alloc(size_t words) {
assert(ShenandoahPacing, "should only call when pacing is enabled");
Atomic::add(&_allocs_seen, words, memory_order_relaxed);

View File

@ -58,7 +58,6 @@ private:
ShenandoahSharedFlag _gc_requested;
ShenandoahSharedFlag _alloc_failure_gc;
ShenandoahSharedFlag _graceful_shutdown;
ShenandoahSharedFlag _heap_changed;
GCCause::Cause _requested_gc_cause;
ShenandoahGC::ShenandoahDegenPoint _degen_point;
@ -104,8 +103,6 @@ public:
void request_gc(GCCause::Cause cause);
void notify_heap_changed();
void pacing_notify_alloc(size_t words);
void start();

View File

@ -832,7 +832,9 @@ void ShenandoahHeap::notify_heap_changed() {
// Update monitoring counters when we took a new region. This amortizes the
// update costs on slow path.
monitoring_support()->notify_heap_changed();
control_thread()->notify_heap_changed();
// This is called from allocation path, and thus should be fast.
_heap_changed.try_set();
}
void ShenandoahHeap::set_forced_counters_update(bool value) {

View File

@ -295,6 +295,9 @@ public:
private:
bool _gc_state_changed;
ShenandoahSharedBitmap _gc_state;
// tracks if new regions have been allocated or retired since last check
ShenandoahSharedFlag _heap_changed;
ShenandoahSharedFlag _degenerated_gc_in_progress;
ShenandoahSharedFlag _full_gc_in_progress;
ShenandoahSharedFlag _full_gc_move_in_progress;
@ -316,6 +319,12 @@ public:
// a safepoint and that any changes were propagated to java threads after the safepoint.
bool has_gc_state_changed() const { return _gc_state_changed; }
// Returns true if allocations have occurred in new regions or if regions have been
// uncommitted since the previous calls. This call will reset the flag to false.
bool has_changed() {
return _heap_changed.try_unset();
}
void set_concurrent_mark_in_progress(bool in_progress);
void set_evacuation_in_progress(bool in_progress);
void set_update_refs_in_progress(bool in_progress);