Skip to content

Commit ccdf171

Browse files
committed
8259377: Shenandoah: Enhance weak reference processing time tracking
Reviewed-by: rkennke
1 parent 916ab4e commit ccdf171

File tree

5 files changed

+39
-29
lines changed

5 files changed

+39
-29
lines changed

src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, 2020, Red Hat, Inc. All rights reserved.
2+
* Copyright (c) 2013, 2021, Red Hat, Inc. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -2049,20 +2049,18 @@ class ShenandoahConcurrentWeakRootsEvacUpdateTask : public AbstractGangTask {
20492049

20502050
void ShenandoahHeap::op_weak_refs() {
20512051
// Concurrent weak refs processing
2052-
{
2053-
ShenandoahTimingsTracker t(ShenandoahPhaseTimings::conc_weak_refs_work);
2054-
ShenandoahGCWorkerPhase worker_phase(ShenandoahPhaseTimings::conc_weak_refs_work);
2055-
ref_processor()->process_references(workers(), true /* concurrent */);
2056-
}
2052+
ShenandoahTimingsTracker t(ShenandoahPhaseTimings::conc_weak_refs_work);
2053+
ShenandoahGCWorkerPhase worker_phase(ShenandoahPhaseTimings::conc_weak_refs_work);
2054+
ref_processor()->process_references(ShenandoahPhaseTimings::conc_weak_refs_work, workers(), true /* concurrent */);
20572055
}
20582056

20592057
void ShenandoahHeap::stw_weak_refs(bool full_gc) {
20602058
// Weak refs processing
2061-
ShenandoahTimingsTracker t(full_gc ? ShenandoahPhaseTimings::full_gc_weakrefs_process
2062-
: ShenandoahPhaseTimings::degen_gc_weakrefs_process);
2063-
ShenandoahGCWorkerPhase worker_phase(full_gc ? ShenandoahPhaseTimings::full_gc_weakrefs_process
2064-
: ShenandoahPhaseTimings::degen_gc_weakrefs_process);
2065-
ref_processor()->process_references(workers(), false /* concurrent */);
2059+
ShenandoahPhaseTimings::Phase phase = full_gc ? ShenandoahPhaseTimings::full_gc_weakrefs
2060+
: ShenandoahPhaseTimings::degen_gc_weakrefs;
2061+
ShenandoahTimingsTracker t(phase);
2062+
ShenandoahGCWorkerPhase worker_phase(phase);
2063+
ref_processor()->process_references(phase, workers(), false /* concurrent */);
20662064
}
20672065

20682066
void ShenandoahHeap::op_weak_roots() {

src/hotspot/share/gc/shenandoah/shenandoahPhaseTimings.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2020, Red Hat, Inc. All rights reserved.
2+
* Copyright (c) 2017, 2021, Red Hat, Inc. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -105,11 +105,11 @@ bool ShenandoahPhaseTimings::is_worker_phase(Phase phase) {
105105
case full_gc_adjust_roots:
106106
case degen_gc_scan_conc_roots:
107107
case degen_gc_update_roots:
108-
case full_gc_weakrefs_process:
108+
case full_gc_weakrefs:
109109
case full_gc_scan_conc_roots:
110110
case full_gc_purge_class_unload:
111111
case full_gc_purge_weak_par:
112-
case degen_gc_weakrefs_process:
112+
case degen_gc_weakrefs:
113113
case degen_gc_purge_class_unload:
114114
case degen_gc_purge_weak_par:
115115
case heap_iteration_roots:

src/hotspot/share/gc/shenandoah/shenandoahPhaseTimings.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2020, Red Hat, Inc. All rights reserved.
2+
* Copyright (c) 2017, 2021, Red Hat, Inc. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -42,7 +42,7 @@ class outputStream;
4242
f(CNT_PREFIX ## CLDGRoots, DESC_PREFIX "CLDG Roots") \
4343
f(CNT_PREFIX ## StringDedupTableRoots, DESC_PREFIX "Dedup Table Roots") \
4444
f(CNT_PREFIX ## StringDedupQueueRoots, DESC_PREFIX "Dedup Queue Roots") \
45-
f(CNT_PREFIX ## FinishQueues, DESC_PREFIX "Finish Queues") \
45+
f(CNT_PREFIX ## WeakRefProc, DESC_PREFIX "Weak References") \
4646
// end
4747

4848
#define SHENANDOAH_PHASE_DO(f) \
@@ -118,8 +118,8 @@ class outputStream;
118118
f(degen_gc, "Pause Degenerated GC (N)") \
119119
f(degen_gc_scan_conc_roots, " Degen Mark Roots") \
120120
SHENANDOAH_PAR_PHASE_DO(degen_gc_conc_mark_, " DM: ", f) \
121-
f(degen_gc_weakrefs, " Weak References") \
122-
f(degen_gc_weakrefs_process, " Process") \
121+
f(degen_gc_weakrefs, " Weak References") \
122+
SHENANDOAH_PAR_PHASE_DO(degen_gc_weakrefs_p_, " WRP: ", f) \
123123
f(degen_gc_purge, " System Purge") \
124124
f(degen_gc_purge_class_unload, " Unload Classes") \
125125
SHENANDOAH_PAR_PHASE_DO(degen_gc_purge_cu_par_, " DCU: ", f) \
@@ -142,7 +142,7 @@ class outputStream;
142142
f(full_gc_mark, " Mark") \
143143
f(full_gc_mark_finish_queues, " Finish Queues") \
144144
f(full_gc_weakrefs, " Weak References") \
145-
f(full_gc_weakrefs_process, " Process") \
145+
SHENANDOAH_PAR_PHASE_DO(full_gc_weakrefs_p_, " WRP: ", f) \
146146
f(full_gc_purge, " System Purge") \
147147
f(full_gc_purge_class_unload, " Unload Classes") \
148148
SHENANDOAH_PAR_PHASE_DO(full_gc_purge_cu_par_, " CU: ", f) \

src/hotspot/share/gc/shenandoah/shenandoahReferenceProcessor.cpp

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
3-
* Copyright (c) 2020, Red Hat, Inc. and/or its affiliates.
2+
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
3+
* Copyright (c) 2020, 2021, Red Hat, Inc. and/or its affiliates.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
66
* This code is free software; you can redistribute it and/or modify it
@@ -473,26 +473,37 @@ void ShenandoahReferenceProcessor::work() {
473473

474474
class ShenandoahReferenceProcessorTask : public AbstractGangTask {
475475
private:
476+
bool const _concurrent;
477+
ShenandoahPhaseTimings::Phase const _phase;
476478
ShenandoahReferenceProcessor* const _reference_processor;
477479

478480
public:
479-
ShenandoahReferenceProcessorTask(ShenandoahReferenceProcessor* reference_processor) :
481+
ShenandoahReferenceProcessorTask(ShenandoahPhaseTimings::Phase phase, bool concurrent, ShenandoahReferenceProcessor* reference_processor) :
480482
AbstractGangTask("ShenandoahReferenceProcessorTask"),
483+
_concurrent(concurrent),
484+
_phase(phase),
481485
_reference_processor(reference_processor) {
482486
}
483487

484488
virtual void work(uint worker_id) {
485-
ShenandoahConcurrentWorkerSession worker_session(worker_id);
486-
_reference_processor->work();
489+
if (_concurrent) {
490+
ShenandoahConcurrentWorkerSession worker_session(worker_id);
491+
ShenandoahWorkerTimingsTracker x(_phase, ShenandoahPhaseTimings::WeakRefProc, worker_id);
492+
_reference_processor->work();
493+
} else {
494+
ShenandoahParallelWorkerSession worker_session(worker_id);
495+
ShenandoahWorkerTimingsTracker x(_phase, ShenandoahPhaseTimings::WeakRefProc, worker_id);
496+
_reference_processor->work();
497+
}
487498
}
488499
};
489500

490-
void ShenandoahReferenceProcessor::process_references(WorkGang* workers, bool concurrent) {
501+
void ShenandoahReferenceProcessor::process_references(ShenandoahPhaseTimings::Phase phase, WorkGang* workers, bool concurrent) {
491502

492503
Atomic::release_store_fence(&_iterate_discovered_list_id, 0U);
493504

494505
// Process discovered lists
495-
ShenandoahReferenceProcessorTask task(this);
506+
ShenandoahReferenceProcessorTask task(phase, concurrent, this);
496507
workers->run_task(&task);
497508

498509
// Update SoftReference clock

src/hotspot/share/gc/shenandoah/shenandoahReferenceProcessor.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
3-
* Copyright (c) 2020, Red Hat, Inc. and/or its affiliates.
2+
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
3+
* Copyright (c) 2020, 2021, Red Hat, Inc. and/or its affiliates.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
66
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@
2727
#define SHARE_VM_GC_SHENANDOAH_SHENANDOAHREFERENCEPROCESSOR_HPP
2828

2929
#include "gc/shared/referenceDiscoverer.hpp"
30+
#include "gc/shenandoah/shenandoahPhaseTimings.hpp"
3031
#include "memory/allocation.hpp"
3132

3233
class ShenandoahMarkRefsSuperClosure;
@@ -176,7 +177,7 @@ class ShenandoahReferenceProcessor : public ReferenceDiscoverer {
176177

177178
bool discover_reference(oop obj, ReferenceType type) override;
178179

179-
void process_references(WorkGang* workers, bool concurrent);
180+
void process_references(ShenandoahPhaseTimings::Phase phase, WorkGang* workers, bool concurrent);
180181

181182
void work();
182183

0 commit comments

Comments
 (0)