Skip to content
Permalink
Browse files
8259404: Shenandoah: Fix time tracking in parallel_cleaning
Reviewed-by: shade
  • Loading branch information
zhengyu123 committed Jan 29, 2021
1 parent 0675473 commit a5fb5173c11864cb08493dd7e857236c72a79ebc
@@ -1792,14 +1792,16 @@ void ShenandoahHeap::stw_unload_classes(bool full_gc) {
if (!unload_classes()) return;
// Unload classes and purge SystemDictionary.
{
ShenandoahGCPhase phase(full_gc ?
ShenandoahPhaseTimings::full_gc_purge_class_unload :
ShenandoahPhaseTimings::degen_gc_purge_class_unload);
ShenandoahPhaseTimings::Phase phase = full_gc ?
ShenandoahPhaseTimings::full_gc_purge_class_unload :
ShenandoahPhaseTimings::degen_gc_purge_class_unload;
ShenandoahGCPhase gc_phase(phase);
ShenandoahGCWorkerPhase worker_phase(phase);
bool purged_class = SystemDictionary::do_unloading(gc_timer());

ShenandoahIsAliveSelector is_alive;
uint num_workers = _workers->active_workers();
ShenandoahClassUnloadingTask unlink_task(is_alive.is_alive_closure(), num_workers, purged_class);
ShenandoahClassUnloadingTask unlink_task(phase, is_alive.is_alive_closure(), num_workers, purged_class);
_workers->run_task(&unlink_task);
}

@@ -1819,16 +1821,12 @@ void ShenandoahHeap::stw_unload_classes(bool full_gc) {
// 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) {
ShenandoahGCPhase root_phase(full_gc ?
ShenandoahPhaseTimings::full_gc_purge :
ShenandoahPhaseTimings::degen_gc_purge);
uint num_workers = _workers->active_workers();
ShenandoahPhaseTimings::Phase timing_phase = full_gc ?
ShenandoahPhaseTimings::full_gc_purge_weak_par :
ShenandoahPhaseTimings::degen_gc_purge_weak_par;
ShenandoahGCPhase phase(timing_phase);
ShenandoahGCWorkerPhase worker_phase(timing_phase);

// Cleanup weak roots
if (has_forwarded_objects()) {
ShenandoahForwardedIsAliveClosure is_alive;
@@ -1853,6 +1851,9 @@ void ShenandoahHeap::stw_process_weak_roots(bool full_gc) {
void ShenandoahHeap::parallel_cleaning(bool full_gc) {
assert(SafepointSynchronize::is_at_safepoint(), "Must be at a safepoint");
assert(is_stw_gc_in_progress(), "Only for Degenerated and Full GC");
ShenandoahGCPhase phase(full_gc ?
ShenandoahPhaseTimings::full_gc_purge :
ShenandoahPhaseTimings::degen_gc_purge);
stw_weak_refs(full_gc);
stw_process_weak_roots(full_gc);
stw_unload_classes(full_gc);
@@ -31,22 +31,28 @@
#include "gc/shenandoah/shenandoahParallelCleaning.hpp"
#include "runtime/safepoint.hpp"

ShenandoahClassUnloadingTask::ShenandoahClassUnloadingTask(BoolObjectClosure* is_alive,
ShenandoahClassUnloadingTask::ShenandoahClassUnloadingTask(ShenandoahPhaseTimings::Phase phase,
BoolObjectClosure* is_alive,
uint num_workers,
bool unloading_occurred) :
AbstractGangTask("Shenandoah Class Unloading"),
_phase(phase),
_unloading_occurred(unloading_occurred),
_code_cache_task(num_workers, is_alive, unloading_occurred),
_klass_cleaning_task() {
assert(SafepointSynchronize::is_at_safepoint(), "Must be at a safepoint");
}

void ShenandoahClassUnloadingTask::work(uint worker_id) {
_code_cache_task.work(worker_id);
{
ShenandoahWorkerTimingsTracker x(_phase, ShenandoahPhaseTimings::CodeCacheUnload, worker_id);
_code_cache_task.work(worker_id);
}
// Clean all klasses that were not unloaded.
// The weak metadata in klass doesn't need to be
// processed if there was no unloading.
if (_unloading_occurred) {
ShenandoahWorkerTimingsTracker x(_phase, ShenandoahPhaseTimings::CLDUnlink, worker_id);
_klass_cleaning_task.work();
}
}
@@ -28,17 +28,19 @@
#include "gc/shared/parallelCleaning.hpp"
#include "gc/shared/weakProcessor.hpp"
#include "gc/shared/workgroup.hpp"
#include "gc/shenandoah/shenandoahPhaseTimings.hpp"
#include "gc/shenandoah/shenandoahRootProcessor.inline.hpp"
#include "memory/iterator.hpp"

// Perform weak root cleaning at a pause
template <typename IsAlive, typename KeepAlive>
class ShenandoahParallelWeakRootsCleaningTask : public AbstractGangTask {
protected:
ShenandoahPhaseTimings::Phase _phase;
WeakProcessor::Task _weak_processing_task;
IsAlive* _is_alive;
KeepAlive* _keep_alive;
ShenandoahPhaseTimings::Phase const _phase;
WeakProcessor::Task _weak_processing_task;
ShenandoahStringDedupRoots _dedup_roots;
IsAlive* _is_alive;
KeepAlive* _keep_alive;

public:
ShenandoahParallelWeakRootsCleaningTask(ShenandoahPhaseTimings::Phase phase,
@@ -53,11 +55,13 @@ class ShenandoahParallelWeakRootsCleaningTask : public AbstractGangTask {
// Perform class unloading at a pause
class ShenandoahClassUnloadingTask : public AbstractGangTask {
private:
bool _unloading_occurred;
CodeCacheUnloadingTask _code_cache_task;
KlassCleaningTask _klass_cleaning_task;
ShenandoahPhaseTimings::Phase const _phase;
bool _unloading_occurred;
CodeCacheUnloadingTask _code_cache_task;
KlassCleaningTask _klass_cleaning_task;
public:
ShenandoahClassUnloadingTask(BoolObjectClosure* is_alive,
ShenandoahClassUnloadingTask(ShenandoahPhaseTimings::Phase phase,
BoolObjectClosure* is_alive,
uint num_workers,
bool unloading_occurred);

@@ -38,30 +38,26 @@ ShenandoahParallelWeakRootsCleaningTask<IsAlive, KeepAlive>::ShenandoahParallelW
KeepAlive* keep_alive,
uint num_workers) :
AbstractGangTask("Shenandoah Weak Root Cleaning"),
_phase(phase), _weak_processing_task(num_workers),
_is_alive(is_alive), _keep_alive(keep_alive) {
_phase(phase),
_weak_processing_task(num_workers),
_dedup_roots(phase),
_is_alive(is_alive),
_keep_alive(keep_alive) {
assert(SafepointSynchronize::is_at_safepoint(), "Must be at a safepoint");

if (ShenandoahStringDedup::is_enabled()) {
StringDedup::gc_prologue(false);
}
}

template<typename IsAlive, typename KeepAlive>
ShenandoahParallelWeakRootsCleaningTask<IsAlive, KeepAlive>::~ShenandoahParallelWeakRootsCleaningTask() {
if (StringDedup::is_enabled()) {
StringDedup::gc_epilogue();
}
_weak_processing_task.report_num_dead();
}

template<typename IsAlive, typename KeepAlive>
void ShenandoahParallelWeakRootsCleaningTask<IsAlive, KeepAlive>::work(uint worker_id) {
_weak_processing_task.work<IsAlive, KeepAlive>(worker_id, _is_alive, _keep_alive);

if (ShenandoahStringDedup::is_enabled()) {
ShenandoahStringDedup::parallel_oops_do(_phase, _is_alive, _keep_alive, worker_id);
{
ShenandoahWorkerTimingsTracker x(_phase, ShenandoahPhaseTimings::VMWeakRoots, worker_id);
_weak_processing_task.work<IsAlive, KeepAlive>(worker_id, _is_alive, _keep_alive);
}
_dedup_roots.oops_do(_is_alive, _keep_alive, worker_id);
}

#endif // SHARE_GC_SHENANDOAH_SHENANDOAHPARALLELCLEANING_INLINE_HPP
@@ -40,6 +40,8 @@ class outputStream;
f(CNT_PREFIX ## VMStrongRoots, DESC_PREFIX "VM Strong Roots") \
f(CNT_PREFIX ## VMWeakRoots, DESC_PREFIX "VM Weak Roots") \
f(CNT_PREFIX ## CLDGRoots, DESC_PREFIX "CLDG Roots") \
f(CNT_PREFIX ## CodeCacheUnload, DESC_PREFIX "Unload Code Caches") \
f(CNT_PREFIX ## CLDUnlink, DESC_PREFIX "Unlink CLDs") \
f(CNT_PREFIX ## StringDedupTableRoots, DESC_PREFIX "Dedup Table Roots") \
f(CNT_PREFIX ## StringDedupQueueRoots, DESC_PREFIX "Dedup Queue Roots") \
f(CNT_PREFIX ## WeakRefProc, DESC_PREFIX "Weak References") \
@@ -119,14 +121,14 @@ class outputStream;
SHENANDOAH_PAR_PHASE_DO(degen_gc_stw_mark_, " DSM: ", f) \
f(degen_gc_mark, " Degen Mark") \
SHENANDOAH_PAR_PHASE_DO(degen_gc_mark_, " DM: ", f) \
f(degen_gc_weakrefs, " Weak References") \
SHENANDOAH_PAR_PHASE_DO(degen_gc_weakrefs_p_, " WRP: ", f) \
f(degen_gc_purge, " System Purge") \
f(degen_gc_weakrefs, " Weak References") \
SHENANDOAH_PAR_PHASE_DO(degen_gc_weakrefs_p_, " WRP: ", f) \
f(degen_gc_purge_class_unload, " Unload Classes") \
SHENANDOAH_PAR_PHASE_DO(degen_gc_purge_cu_par_, " DCU: ", f) \
f(degen_gc_purge_weak_par, " Weak Roots") \
SHENANDOAH_PAR_PHASE_DO(degen_gc_purge_weak_p_, " DWR: ", f) \
f(degen_gc_purge_cldg, " CLDG") \
f(degen_gc_purge_weak_par, " Weak Roots") \
SHENANDOAH_PAR_PHASE_DO(degen_gc_purge_weak_p_, " DWR: ", f) \
f(degen_gc_purge_cldg, " CLDG") \
f(degen_gc_final_update_region_states, " Update Region States") \
f(degen_gc_final_manage_labs, " Manage GC/TLABs") \
f(degen_gc_choose_cset, " Choose Collection Set") \
@@ -150,9 +152,9 @@ class outputStream;
SHENANDOAH_PAR_PHASE_DO(full_gc_update_roots_, " FU: ", f) \
f(full_gc_mark, " Mark") \
SHENANDOAH_PAR_PHASE_DO(full_gc_mark_, " FM: ", f) \
f(full_gc_weakrefs, " Weak References") \
SHENANDOAH_PAR_PHASE_DO(full_gc_weakrefs_p_, " WRP: ", f) \
f(full_gc_purge, " System Purge") \
f(full_gc_weakrefs, " Weak References") \
SHENANDOAH_PAR_PHASE_DO(full_gc_weakrefs_p_, " WRP: ", f) \
f(full_gc_purge_class_unload, " Unload Classes") \
SHENANDOAH_PAR_PHASE_DO(full_gc_purge_cu_par_, " CU: ", f) \
f(full_gc_purge_weak_par, " Weak Roots") \

0 comments on commit a5fb517

Please sign in to comment.