Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8324553: Shenandoah: Move periodic tasks closer to their collaborators #17540

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp
Original file line number Diff line number Diff line change
@@ -788,7 +788,6 @@ 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();
}

22 changes: 11 additions & 11 deletions src/hotspot/share/gc/shenandoah/shenandoahMonitoringSupport.cpp
Original file line number Diff line number Diff line change
@@ -59,7 +59,7 @@ class ShenandoahGenerationCounters : public GenerationCounters {
ShenandoahMonitoringSupport::ShenandoahMonitoringSupport(ShenandoahHeap* heap) :
_partial_counters(nullptr),
_full_counters(nullptr),
_counters_update(this)
_counters_update_task(this)
{
// Collection counters do not fit Shenandoah very well.
// We record partial cycles as "young", and full cycles (including full STW GC) as "old".
@@ -73,7 +73,7 @@ ShenandoahMonitoringSupport::ShenandoahMonitoringSupport(ShenandoahHeap* heap) :

_heap_region_counters = new ShenandoahHeapRegionCounters();

_counters_update.enroll();
_counters_update_task.enroll();
}

CollectorCounters* ShenandoahMonitoringSupport::stw_collection_counters() {
@@ -108,42 +108,42 @@ void ShenandoahMonitoringSupport::update_counters() {
}

void ShenandoahMonitoringSupport::notify_heap_changed() {
_counters_update.notify_heap_changed();
_counters_update_task.notify_heap_changed();
}

void ShenandoahMonitoringSupport::set_forced_counters_update(bool value) {
_counters_update.set_forced_counters_update(value);
_counters_update_task.set_forced_counters_update(value);
}

void ShenandoahMonitoringSupport::handle_force_counters_update() {
_counters_update.handle_force_counters_update();
_counters_update_task.handle_force_counters_update();
}

void ShenandoahPeriodicCountersUpdate::task() {
void ShenandoahPeriodicCountersUpdateTask::task() {
handle_force_counters_update();
handle_counters_update();
}

void ShenandoahPeriodicCountersUpdate::handle_counters_update() {
void ShenandoahPeriodicCountersUpdateTask::handle_counters_update() {
if (_do_counters_update.is_set()) {
_do_counters_update.unset();
_monitoring_support->update_counters();
}
}

void ShenandoahPeriodicCountersUpdate::handle_force_counters_update() {
void ShenandoahPeriodicCountersUpdateTask::handle_force_counters_update() {
if (_force_counters_update.is_set()) {
_do_counters_update.unset(); // reset these too, we do update now!
_monitoring_support->update_counters();
}
}

void ShenandoahPeriodicCountersUpdate::notify_heap_changed() {
void ShenandoahPeriodicCountersUpdateTask::notify_heap_changed() {
if (_do_counters_update.is_unset()) {
_do_counters_update.set();
}
}

void ShenandoahPeriodicCountersUpdate::set_forced_counters_update(bool value) {
void ShenandoahPeriodicCountersUpdateTask::set_forced_counters_update(bool value) {
_force_counters_update.set_cond(value);
}
}
Original file line number Diff line number Diff line change
@@ -36,14 +36,14 @@ class CollectorCounters;
class ShenandoahHeapRegionCounters;
class ShenandoahMonitoringSupport;

class ShenandoahPeriodicCountersUpdate : public PeriodicTask {
class ShenandoahPeriodicCountersUpdateTask : public PeriodicTask {
private:
ShenandoahSharedFlag _do_counters_update;
ShenandoahSharedFlag _force_counters_update;
ShenandoahMonitoringSupport* _monitoring_support;
ShenandoahMonitoringSupport* const _monitoring_support;

public:
explicit ShenandoahPeriodicCountersUpdate(ShenandoahMonitoringSupport* monitoring_support) :
explicit ShenandoahPeriodicCountersUpdateTask(ShenandoahMonitoringSupport* monitoring_support) :
PeriodicTask(100),
_monitoring_support(monitoring_support) { }

@@ -66,7 +66,7 @@ class ShenandoahMonitoringSupport : public CHeapObj<mtGC> {
HSpaceCounters* _space_counters;

ShenandoahHeapRegionCounters* _heap_region_counters;
ShenandoahPeriodicCountersUpdate _counters_update;
ShenandoahPeriodicCountersUpdateTask _counters_update_task;

public:
explicit ShenandoahMonitoringSupport(ShenandoahHeap* heap);
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/shenandoah/shenandoahPacer.cpp
Original file line number Diff line number Diff line change
@@ -339,7 +339,7 @@ void ShenandoahPacer::print_cycle_on(outputStream* out) {
out->cr();
}

void ShenandoahPeriodicPacerNotify::task() {
void ShenandoahPeriodicPacerNotifyTask::task() {
assert(ShenandoahPacing, "Should not be here otherwise");
_pacer->notify_waiters();
}
16 changes: 8 additions & 8 deletions src/hotspot/share/gc/shenandoah/shenandoahPacer.hpp
Original file line number Diff line number Diff line change
@@ -36,15 +36,15 @@ class ShenandoahPacer;


// Periodic task to notify blocked paced waiters.
class ShenandoahPeriodicPacerNotify : public PeriodicTask {
class ShenandoahPeriodicPacerNotifyTask : public PeriodicTask {
private:
ShenandoahPacer* const _pacer;
public:
explicit ShenandoahPeriodicPacerNotify(ShenandoahPacer* pacer) :
explicit ShenandoahPeriodicPacerNotifyTask(ShenandoahPacer* pacer) :
PeriodicTask(PeriodicTask::min_interval),
_pacer(pacer) { }

void task() override;
private:
ShenandoahPacer* _pacer;
};


@@ -64,7 +64,7 @@ class ShenandoahPacer : public CHeapObj<mtGC> {
TruncatedSeq* _progress_history;
Monitor* _wait_monitor;
ShenandoahSharedFlag _need_notify_waiters;
ShenandoahPeriodicPacerNotify _notify_waiters;
ShenandoahPeriodicPacerNotifyTask _notify_waiters_task;

// Set once per phase
volatile intptr_t _epoch;
@@ -81,17 +81,17 @@ class ShenandoahPacer : public CHeapObj<mtGC> {
shenandoah_padding(3);

public:
ShenandoahPacer(ShenandoahHeap* heap) :
explicit ShenandoahPacer(ShenandoahHeap* heap) :
_heap(heap),
_last_time(os::elapsedTime()),
_progress_history(new TruncatedSeq(5)),
_wait_monitor(new Monitor(Mutex::safepoint-1, "ShenandoahWaitMonitor_lock", true)),
_notify_waiters(this),
_notify_waiters_task(this),
_epoch(0),
_tax_rate(1),
_budget(0),
_progress(PACING_PROGRESS_UNINIT) {
_notify_waiters.enroll();
_notify_waiters_task.enroll();
}

void setup_for_idle();