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

8259404: Shenandoah: Fix time tracking in parallel_cleaning #2073

Closed
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 9 additions & 8 deletions src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp
Expand Up @@ -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 p = full_gc ?
zhengyu123 marked this conversation as resolved.
Show resolved Hide resolved
ShenandoahPhaseTimings::full_gc_purge_class_unload :
ShenandoahPhaseTimings::degen_gc_purge_class_unload;
ShenandoahGCPhase phase(p);
ShenandoahGCWorkerPhase worker_phase(p);
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(p, is_alive.is_alive_closure(), num_workers, purged_class);
_workers->run_task(&unlink_task);
}

Expand All @@ -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;
Expand All @@ -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 root_phase(full_gc ?
zhengyu123 marked this conversation as resolved.
Show resolved Hide resolved
ShenandoahPhaseTimings::full_gc_purge :
ShenandoahPhaseTimings::degen_gc_purge);
stw_weak_refs(full_gc);
stw_process_weak_roots(full_gc);
stw_unload_classes(full_gc);
Expand Down
10 changes: 8 additions & 2 deletions src/hotspot/share/gc/shenandoah/shenandoahParallelCleaning.cpp
Expand Up @@ -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::CodeCacheRoots, worker_id);
_code_cache_task.work(worker_id);
zhengyu123 marked this conversation as resolved.
Show resolved Hide resolved
}
// 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::CLDGRoots, worker_id);
_klass_cleaning_task.work();
zhengyu123 marked this conversation as resolved.
Show resolved Hide resolved
}
}
20 changes: 12 additions & 8 deletions src/hotspot/share/gc/shenandoah/shenandoahParallelCleaning.hpp
Expand Up @@ -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,
Expand All @@ -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);

Expand Down
Expand Up @@ -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);
zhengyu123 marked this conversation as resolved.
Show resolved Hide resolved
}

#endif // SHARE_GC_SHENANDOAH_SHENANDOAHPARALLELCLEANING_INLINE_HPP
6 changes: 3 additions & 3 deletions src/hotspot/share/gc/shenandoah/shenandoahPhaseTimings.hpp
Expand Up @@ -126,9 +126,9 @@ class outputStream;
f(degen_gc_purge, " System Purge") \
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") \
Expand Down