Skip to content

Commit

Permalink
8325516: Shenandoah: Move heap change tracking into ShenandoahHeap
Browse files Browse the repository at this point in the history
Reviewed-by: shade, kdnilsen, ysr
  • Loading branch information
William Kemper authored and shipilev committed Feb 9, 2024
1 parent 8d9ad97 commit cc276ff
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
10 changes: 1 addition & 9 deletions src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 0 additions & 3 deletions src/hotspot/share/gc/shenandoah/shenandoahControlThread.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ class ShenandoahControlThread: public ConcurrentGCThread {
ShenandoahSharedFlag _gc_requested;
ShenandoahSharedFlag _alloc_failure_gc;
ShenandoahSharedFlag _graceful_shutdown;
ShenandoahSharedFlag _heap_changed;
GCCause::Cause _requested_gc_cause;
ShenandoahGC::ShenandoahDegenPoint _degen_point;

Expand Down Expand Up @@ -104,8 +103,6 @@ class ShenandoahControlThread: public ConcurrentGCThread {

void request_gc(GCCause::Cause cause);

void notify_heap_changed();

void pacing_notify_alloc(size_t words);

void start();
Expand Down
4 changes: 3 additions & 1 deletion src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
9 changes: 9 additions & 0 deletions src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,9 @@ class ShenandoahHeap : public CollectedHeap, public ShenandoahSpaceInfo {
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;
Expand All @@ -316,6 +319,12 @@ class ShenandoahHeap : public CollectedHeap, public ShenandoahSpaceInfo {
// 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);
Expand Down

1 comment on commit cc276ff

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.