< prev index next >
src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp
Print this page
rev 59188 : 8244243: Shenandoah: Cleanup Shenandoah phase timing tracking and JFR event supporting
@@ -1341,10 +1341,11 @@
ShenandoahParallelHeapRegionTask(ShenandoahHeapRegionClosure* blk) :
AbstractGangTask("Parallel Region Task"),
_heap(ShenandoahHeap::heap()), _blk(blk), _index(0) {}
void work(uint worker_id) {
+ ShenandoahParallelWorkerSession worker_session(worker_id);
size_t stride = ShenandoahParallelRegionStride;
size_t max = _heap->num_regions();
while (_index < max) {
size_t cur = Atomic::fetch_and_add(&_index, stride);
@@ -1410,27 +1411,27 @@
}
set_concurrent_mark_in_progress(true);
// We need to reset all TLABs because we'd lose marks on all objects allocated in them.
{
- ShenandoahGCSubPhase phase(ShenandoahPhaseTimings::make_parsable);
+ ShenandoahGCPhase phase(ShenandoahPhaseTimings::make_parsable);
make_parsable(true);
}
{
- ShenandoahGCSubPhase phase(ShenandoahPhaseTimings::init_update_region_states);
+ ShenandoahGCPhase phase(ShenandoahPhaseTimings::init_update_region_states);
ShenandoahInitMarkUpdateRegionStateClosure cl;
parallel_heap_region_iterate(&cl);
}
// Make above changes visible to worker threads
OrderAccess::fence();
concurrent_mark()->mark_roots(ShenandoahPhaseTimings::scan_roots);
if (UseTLAB) {
- ShenandoahGCSubPhase phase(ShenandoahPhaseTimings::resize_tlabs);
+ ShenandoahGCPhase phase(ShenandoahPhaseTimings::resize_tlabs);
resize_tlabs();
}
if (ShenandoahPacing) {
pacer()->setup_for_mark();
@@ -1515,11 +1516,11 @@
if (ShenandoahVerify) {
verifier()->verify_roots_no_forwarded();
}
{
- ShenandoahGCSubPhase phase(ShenandoahPhaseTimings::final_update_region_states);
+ ShenandoahGCPhase phase(ShenandoahPhaseTimings::final_update_region_states);
ShenandoahFinalMarkUpdateRegionStateClosure cl;
parallel_heap_region_iterate(&cl);
assert_pinned_region_status();
}
@@ -1528,23 +1529,23 @@
// This is needed for two reasons. Strong one: new allocations would be with new freeset,
// which would be outside the collection set, so no cset writes would happen there.
// Weaker one: new allocations would happen past update watermark, and so less work would
// be needed for reference updates (would update the large filler instead).
{
- ShenandoahGCSubPhase phase(ShenandoahPhaseTimings::retire_tlabs);
+ ShenandoahGCPhase phase(ShenandoahPhaseTimings::retire_tlabs);
make_parsable(true);
}
{
- ShenandoahGCSubPhase phase(ShenandoahPhaseTimings::choose_cset);
+ ShenandoahGCPhase phase(ShenandoahPhaseTimings::choose_cset);
ShenandoahHeapLocker locker(lock());
_collection_set->clear();
heuristics()->choose_collection_set(_collection_set);
}
{
- ShenandoahGCSubPhase phase(ShenandoahPhaseTimings::final_rebuild_freeset);
+ ShenandoahGCPhase phase(ShenandoahPhaseTimings::final_rebuild_freeset);
ShenandoahHeapLocker locker(lock());
_free_set->rebuild();
}
if (!is_degenerated_gc_in_progress()) {
@@ -1553,11 +1554,11 @@
}
// If collection set has candidates, start evacuation.
// Otherwise, bypass the rest of the cycle.
if (!collection_set()->is_empty()) {
- ShenandoahGCSubPhase init_evac(ShenandoahPhaseTimings::init_evac);
+ ShenandoahGCPhase init_evac(ShenandoahPhaseTimings::init_evac);
if (ShenandoahVerify) {
verifier()->verify_before_evacuation();
}
@@ -1649,10 +1650,11 @@
AbstractGangTask("Shenandoah Evacuate/Update Concurrent Strong Roots Task"),
_vm_roots(phase),
_cld_roots(phase) {}
void work(uint worker_id) {
+ ShenandoahConcurrentWorkerSession worker_session(worker_id);
ShenandoahEvacOOMScope oom;
{
// vm_roots and weak_roots are OopStorage backed roots, concurrent iteration
// may race against OopStorage::release() calls.
ShenandoahEvacUpdateOopStorageRootsClosure cl;
@@ -1787,10 +1789,11 @@
_nmethod_itr.nmethods_do_end();
}
}
void work(uint worker_id) {
+ ShenandoahConcurrentWorkerSession worker_session(worker_id);
{
ShenandoahEvacOOMScope oom;
// jni_roots and weak_roots are OopStorage backed roots, concurrent iteration
// may race against OopStorage::release() calls.
ShenandoahEvacUpdateCleanupOopStorageRootsClosure cl;
@@ -1890,11 +1893,11 @@
ShenandoahMetricsSnapshot metrics;
metrics.snap_before();
full_gc()->do_it(cause);
if (UseTLAB) {
- ShenandoahGCSubPhase phase(ShenandoahPhaseTimings::full_gc_resize_tlabs);
+ ShenandoahGCPhase phase(ShenandoahPhaseTimings::full_gc_resize_tlabs);
resize_all_tlabs();
}
metrics.snap_after();
@@ -2201,11 +2204,11 @@
void ShenandoahHeap::stw_unload_classes(bool full_gc) {
if (!unload_classes()) return;
// Unload classes and purge SystemDictionary.
{
- ShenandoahGCSubPhase phase(full_gc ?
+ ShenandoahGCPhase phase(full_gc ?
ShenandoahPhaseTimings::full_gc_purge_class_unload :
ShenandoahPhaseTimings::purge_class_unload);
bool purged_class = SystemDictionary::do_unloading(gc_timer());
ShenandoahIsAliveSelector is_alive;
@@ -2213,11 +2216,11 @@
ShenandoahClassUnloadingTask unlink_task(is_alive.is_alive_closure(), num_workers, purged_class);
_workers->run_task(&unlink_task);
}
{
- ShenandoahGCSubPhase phase(full_gc ?
+ ShenandoahGCPhase phase(full_gc ?
ShenandoahPhaseTimings::full_gc_purge_cldg :
ShenandoahPhaseTimings::purge_cldg);
ClassLoaderDataGraph::purge();
}
// Resize and verify metaspace
@@ -2228,18 +2231,18 @@
// Weak roots are either pre-evacuated (final mark) or updated (final updaterefs),
// so they should not have forwarded oops.
// However, we do need to "null" dead oops in the roots, if can not be done
// in concurrent cycles.
void ShenandoahHeap::stw_process_weak_roots(bool full_gc) {
- ShenandoahGCSubPhase root_phase(full_gc ?
+ ShenandoahGCPhase root_phase(full_gc ?
ShenandoahPhaseTimings::full_gc_purge :
ShenandoahPhaseTimings::purge);
uint num_workers = _workers->active_workers();
ShenandoahPhaseTimings::Phase timing_phase = full_gc ?
ShenandoahPhaseTimings::full_gc_purge_weak_par :
ShenandoahPhaseTimings::purge_weak_par;
- ShenandoahGCSubPhase phase(timing_phase);
+ ShenandoahGCPhase phase(timing_phase);
ShenandoahGCWorkerPhase worker_phase(timing_phase);
// Cleanup weak roots
if (has_forwarded_objects()) {
ShenandoahForwardedIsAliveClosure is_alive;
@@ -2491,11 +2494,11 @@
assert(ShenandoahSafepoint::is_at_shenandoah_safepoint(), "must be at safepoint");
set_evacuation_in_progress(false);
{
- ShenandoahGCSubPhase phase(ShenandoahPhaseTimings::init_update_refs_retire_gclabs);
+ ShenandoahGCPhase phase(ShenandoahPhaseTimings::init_update_refs_retire_gclabs);
retire_and_reset_gclabs();
}
if (ShenandoahVerify) {
if (!is_degenerated_gc_in_progress()) {
@@ -2547,11 +2550,11 @@
finish_concurrent_unloading();
// Check if there is left-over work, and finish it
if (_update_refs_iterator.has_next()) {
- ShenandoahGCSubPhase phase(ShenandoahPhaseTimings::final_update_refs_finish_work);
+ ShenandoahGCPhase phase(ShenandoahPhaseTimings::final_update_refs_finish_work);
// Finish updating references where we left off.
clear_cancelled_gc();
update_heap_references(false);
}
@@ -2577,19 +2580,19 @@
if (ShenandoahVerify) {
verifier()->verify_roots_in_to_space();
}
{
- ShenandoahGCSubPhase phase(ShenandoahPhaseTimings::final_update_refs_update_region_states);
+ ShenandoahGCPhase phase(ShenandoahPhaseTimings::final_update_refs_update_region_states);
ShenandoahFinalUpdateRefsUpdateRegionStateClosure cl;
parallel_heap_region_iterate(&cl);
assert_pinned_region_status();
}
{
- ShenandoahGCSubPhase phase(ShenandoahPhaseTimings::final_update_refs_trash_cset);
+ ShenandoahGCPhase phase(ShenandoahPhaseTimings::final_update_refs_trash_cset);
trash_cset_regions();
}
set_has_forwarded_objects(false);
set_update_refs_in_progress(false);
@@ -2601,11 +2604,11 @@
if (VerifyAfterGC) {
Universe::verify();
}
{
- ShenandoahGCSubPhase phase(ShenandoahPhaseTimings::final_update_refs_rebuild_freeset);
+ ShenandoahGCPhase phase(ShenandoahPhaseTimings::final_update_refs_rebuild_freeset);
ShenandoahHeapLocker locker(lock());
_free_set->rebuild();
}
}
@@ -2689,137 +2692,125 @@
}
}
void ShenandoahHeap::vmop_entry_init_mark() {
TraceCollectorStats tcs(monitoring_support()->stw_collection_counters());
- ShenandoahGCPhase phase(ShenandoahPhaseTimings::init_mark_gross);
+ ShenandoahTimingsTracker timing(ShenandoahPhaseTimings::init_mark_gross);
try_inject_alloc_failure();
VM_ShenandoahInitMark op;
VMThread::execute(&op); // jump to entry_init_mark() under safepoint
}
void ShenandoahHeap::vmop_entry_final_mark() {
TraceCollectorStats tcs(monitoring_support()->stw_collection_counters());
- ShenandoahGCPhase phase(ShenandoahPhaseTimings::final_mark_gross);
+ ShenandoahTimingsTracker timing(ShenandoahPhaseTimings::final_mark_gross);
try_inject_alloc_failure();
VM_ShenandoahFinalMarkStartEvac op;
VMThread::execute(&op); // jump to entry_final_mark under safepoint
}
void ShenandoahHeap::vmop_entry_init_updaterefs() {
TraceCollectorStats tcs(monitoring_support()->stw_collection_counters());
- ShenandoahGCPhase phase(ShenandoahPhaseTimings::init_update_refs_gross);
+ ShenandoahTimingsTracker timing(ShenandoahPhaseTimings::init_update_refs_gross);
try_inject_alloc_failure();
VM_ShenandoahInitUpdateRefs op;
VMThread::execute(&op);
}
void ShenandoahHeap::vmop_entry_final_updaterefs() {
TraceCollectorStats tcs(monitoring_support()->stw_collection_counters());
- ShenandoahGCPhase phase(ShenandoahPhaseTimings::final_update_refs_gross);
+ ShenandoahTimingsTracker timing(ShenandoahPhaseTimings::final_update_refs_gross);
try_inject_alloc_failure();
VM_ShenandoahFinalUpdateRefs op;
VMThread::execute(&op);
}
void ShenandoahHeap::vmop_entry_full(GCCause::Cause cause) {
TraceCollectorStats tcs(monitoring_support()->full_stw_collection_counters());
- ShenandoahGCPhase phase(ShenandoahPhaseTimings::full_gc_gross);
+ ShenandoahTimingsTracker timing(ShenandoahPhaseTimings::full_gc_gross);
try_inject_alloc_failure();
VM_ShenandoahFullGC op(cause);
VMThread::execute(&op);
}
void ShenandoahHeap::vmop_degenerated(ShenandoahDegenPoint point) {
TraceCollectorStats tcs(monitoring_support()->full_stw_collection_counters());
- ShenandoahGCPhase phase(ShenandoahPhaseTimings::degen_gc_gross);
+ ShenandoahTimingsTracker timing(ShenandoahPhaseTimings::degen_gc_gross);
VM_ShenandoahDegeneratedGC degenerated_gc((int)point);
VMThread::execute(°enerated_gc);
}
void ShenandoahHeap::entry_init_mark() {
const char* msg = init_mark_event_message();
- ShenandoahPausePhase gc_phase(msg);
+ ShenandoahPausePhase gc_phase(msg, ShenandoahPhaseTimings::init_mark);
EventMark em("%s", msg);
- ShenandoahGCPhase phase(ShenandoahPhaseTimings::init_mark);
-
ShenandoahWorkerScope scope(workers(),
ShenandoahWorkerPolicy::calc_workers_for_init_marking(),
"init marking");
op_init_mark();
}
void ShenandoahHeap::entry_final_mark() {
const char* msg = final_mark_event_message();
- ShenandoahPausePhase gc_phase(msg);
+ ShenandoahPausePhase gc_phase(msg, ShenandoahPhaseTimings::final_mark);
EventMark em("%s", msg);
- ShenandoahGCPhase phase(ShenandoahPhaseTimings::final_mark);
-
ShenandoahWorkerScope scope(workers(),
ShenandoahWorkerPolicy::calc_workers_for_final_marking(),
"final marking");
op_final_mark();
}
void ShenandoahHeap::entry_init_updaterefs() {
static const char* msg = "Pause Init Update Refs";
- ShenandoahPausePhase gc_phase(msg);
+ ShenandoahPausePhase gc_phase(msg, ShenandoahPhaseTimings::init_update_refs);
EventMark em("%s", msg);
- ShenandoahGCPhase phase(ShenandoahPhaseTimings::init_update_refs);
-
// No workers used in this phase, no setup required
op_init_updaterefs();
}
void ShenandoahHeap::entry_final_updaterefs() {
static const char* msg = "Pause Final Update Refs";
- ShenandoahPausePhase gc_phase(msg);
+ ShenandoahPausePhase gc_phase(msg, ShenandoahPhaseTimings::final_update_refs);
EventMark em("%s", msg);
- ShenandoahGCPhase phase(ShenandoahPhaseTimings::final_update_refs);
-
ShenandoahWorkerScope scope(workers(),
ShenandoahWorkerPolicy::calc_workers_for_final_update_ref(),
"final reference update");
op_final_updaterefs();
}
void ShenandoahHeap::entry_full(GCCause::Cause cause) {
static const char* msg = "Pause Full";
- ShenandoahPausePhase gc_phase(msg, true /* log_heap_usage */);
+ ShenandoahPausePhase gc_phase(msg, ShenandoahPhaseTimings::full_gc, true /* log_heap_usage */);
EventMark em("%s", msg);
- ShenandoahGCPhase phase(ShenandoahPhaseTimings::full_gc);
-
ShenandoahWorkerScope scope(workers(),
ShenandoahWorkerPolicy::calc_workers_for_fullgc(),
"full gc");
op_full(cause);
}
void ShenandoahHeap::entry_degenerated(int point) {
ShenandoahDegenPoint dpoint = (ShenandoahDegenPoint)point;
const char* msg = degen_event_message(dpoint);
- ShenandoahPausePhase gc_phase(msg, true /* log_heap_usage */);
+ ShenandoahPausePhase gc_phase(msg, ShenandoahPhaseTimings::degen_gc, true /* log_heap_usage */);
EventMark em("%s", msg);
- ShenandoahGCPhase phase(ShenandoahPhaseTimings::degen_gc);
-
ShenandoahWorkerScope scope(workers(),
ShenandoahWorkerPolicy::calc_workers_for_stw_degenerated(),
"stw degenerated gc");
set_degenerated_gc_in_progress(true);
@@ -2829,15 +2820,13 @@
void ShenandoahHeap::entry_mark() {
TraceCollectorStats tcs(monitoring_support()->concurrent_collection_counters());
const char* msg = conc_mark_event_message();
- ShenandoahConcurrentPhase gc_phase(msg);
+ ShenandoahConcurrentPhase gc_phase(msg, ShenandoahPhaseTimings::conc_mark);
EventMark em("%s", msg);
- ShenandoahGCPhase conc_mark_phase(ShenandoahPhaseTimings::conc_mark);
-
ShenandoahWorkerScope scope(workers(),
ShenandoahWorkerPolicy::calc_workers_for_conc_marking(),
"concurrent marking");
try_inject_alloc_failure();
@@ -2846,44 +2835,39 @@
void ShenandoahHeap::entry_evac() {
TraceCollectorStats tcs(monitoring_support()->concurrent_collection_counters());
static const char* msg = "Concurrent evacuation";
- ShenandoahConcurrentPhase gc_phase(msg);
+ ShenandoahConcurrentPhase gc_phase(msg, ShenandoahPhaseTimings::conc_evac);
EventMark em("%s", msg);
- ShenandoahGCPhase conc_evac_phase(ShenandoahPhaseTimings::conc_evac);
-
ShenandoahWorkerScope scope(workers(),
ShenandoahWorkerPolicy::calc_workers_for_conc_evac(),
"concurrent evacuation");
try_inject_alloc_failure();
op_conc_evac();
}
void ShenandoahHeap::entry_updaterefs() {
static const char* msg = "Concurrent update references";
- ShenandoahConcurrentPhase gc_phase(msg);
+ ShenandoahConcurrentPhase gc_phase(msg, ShenandoahPhaseTimings::conc_update_refs);
EventMark em("%s", msg);
- ShenandoahGCPhase phase(ShenandoahPhaseTimings::conc_update_refs);
-
ShenandoahWorkerScope scope(workers(),
ShenandoahWorkerPolicy::calc_workers_for_conc_update_ref(),
"concurrent reference update");
try_inject_alloc_failure();
op_updaterefs();
}
void ShenandoahHeap::entry_weak_roots() {
static const char* msg = "Concurrent weak roots";
- ShenandoahConcurrentPhase gc_phase(msg);
+ ShenandoahConcurrentPhase gc_phase(msg, ShenandoahPhaseTimings::conc_weak_roots);
EventMark em("%s", msg);
- ShenandoahGCPhase phase(ShenandoahPhaseTimings::conc_weak_roots);
ShenandoahGCWorkerPhase worker_phase(ShenandoahPhaseTimings::conc_weak_roots);
ShenandoahWorkerScope scope(workers(),
ShenandoahWorkerPolicy::calc_workers_for_conc_root_processing(),
"concurrent weak root");
@@ -2892,29 +2876,26 @@
op_weak_roots();
}
void ShenandoahHeap::entry_class_unloading() {
static const char* msg = "Concurrent class unloading";
- ShenandoahConcurrentPhase gc_phase(msg);
+ ShenandoahConcurrentPhase gc_phase(msg, ShenandoahPhaseTimings::conc_class_unloading);
EventMark em("%s", msg);
- ShenandoahGCPhase phase(ShenandoahPhaseTimings::conc_class_unloading);
-
ShenandoahWorkerScope scope(workers(),
ShenandoahWorkerPolicy::calc_workers_for_conc_root_processing(),
"concurrent class unloading");
try_inject_alloc_failure();
op_class_unloading();
}
void ShenandoahHeap::entry_strong_roots() {
static const char* msg = "Concurrent strong roots";
- ShenandoahConcurrentPhase gc_phase(msg);
+ ShenandoahConcurrentPhase gc_phase(msg, ShenandoahPhaseTimings::conc_strong_roots);
EventMark em("%s", msg);
- ShenandoahGCPhase phase(ShenandoahPhaseTimings::conc_strong_roots);
ShenandoahGCWorkerPhase worker_phase(ShenandoahPhaseTimings::conc_strong_roots);
ShenandoahWorkerScope scope(workers(),
ShenandoahWorkerPolicy::calc_workers_for_conc_root_processing(),
"concurrent strong root");
@@ -2923,41 +2904,35 @@
op_strong_roots();
}
void ShenandoahHeap::entry_cleanup_early() {
static const char* msg = "Concurrent cleanup";
- ShenandoahConcurrentPhase gc_phase(msg, true /* log_heap_usage */);
+ ShenandoahConcurrentPhase gc_phase(msg, ShenandoahPhaseTimings::conc_cleanup_early, true /* log_heap_usage */);
EventMark em("%s", msg);
- ShenandoahGCSubPhase phase(ShenandoahPhaseTimings::conc_cleanup_early);
-
// This phase does not use workers, no need for setup
try_inject_alloc_failure();
op_cleanup_early();
}
void ShenandoahHeap::entry_cleanup_complete() {
static const char* msg = "Concurrent cleanup";
- ShenandoahConcurrentPhase gc_phase(msg, true /* log_heap_usage */);
+ ShenandoahConcurrentPhase gc_phase(msg, ShenandoahPhaseTimings::conc_cleanup_complete, true /* log_heap_usage */);
EventMark em("%s", msg);
- ShenandoahGCSubPhase phase(ShenandoahPhaseTimings::conc_cleanup_complete);
-
// This phase does not use workers, no need for setup
try_inject_alloc_failure();
op_cleanup_complete();
}
void ShenandoahHeap::entry_reset() {
static const char* msg = "Concurrent reset";
- ShenandoahConcurrentPhase gc_phase(msg);
+ ShenandoahConcurrentPhase gc_phase(msg, ShenandoahPhaseTimings::conc_reset);
EventMark em("%s", msg);
- ShenandoahGCSubPhase phase(ShenandoahPhaseTimings::conc_reset);
-
ShenandoahWorkerScope scope(workers(),
ShenandoahWorkerPolicy::calc_workers_for_conc_reset(),
"concurrent reset");
try_inject_alloc_failure();
@@ -2965,15 +2940,13 @@
}
void ShenandoahHeap::entry_preclean() {
if (ShenandoahPreclean && process_references()) {
static const char* msg = "Concurrent precleaning";
- ShenandoahConcurrentPhase gc_phase(msg);
+ ShenandoahConcurrentPhase gc_phase(msg, ShenandoahPhaseTimings::conc_preclean);
EventMark em("%s", msg);
- ShenandoahGCSubPhase conc_preclean(ShenandoahPhaseTimings::conc_preclean);
-
ShenandoahWorkerScope scope(workers(),
ShenandoahWorkerPolicy::calc_workers_for_conc_preclean(),
"concurrent preclean",
/* check_workers = */ false);
@@ -2982,15 +2955,13 @@
}
}
void ShenandoahHeap::entry_uncommit(double shrink_before) {
static const char *msg = "Concurrent uncommit";
- ShenandoahConcurrentPhase gc_phase(msg, true /* log_heap_usage */);
+ ShenandoahConcurrentPhase gc_phase(msg, ShenandoahPhaseTimings::conc_uncommit, true /* log_heap_usage */);
EventMark em("%s", msg);
- ShenandoahGCSubPhase phase(ShenandoahPhaseTimings::conc_uncommit);
-
op_uncommit(shrink_before);
}
void ShenandoahHeap::try_inject_alloc_failure() {
if (ShenandoahAllocFailureALot && !cancelled_gc() && ((os::random() % 1000) > 950)) {
< prev index next >