8259377: Shenandoah: Enhance weak reference processing time tracking

Reviewed-by: rkennke
This commit is contained in:
Zhengyu Gu 2021-01-13 19:01:18 +00:00
parent 916ab4e7d8
commit ccdf171d78
5 changed files with 39 additions and 29 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2013, 2020, Red Hat, Inc. All rights reserved. * Copyright (c) 2013, 2021, Red Hat, Inc. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -2049,20 +2049,18 @@ public:
void ShenandoahHeap::op_weak_refs() { void ShenandoahHeap::op_weak_refs() {
// Concurrent weak refs processing // Concurrent weak refs processing
{
ShenandoahTimingsTracker t(ShenandoahPhaseTimings::conc_weak_refs_work); ShenandoahTimingsTracker t(ShenandoahPhaseTimings::conc_weak_refs_work);
ShenandoahGCWorkerPhase worker_phase(ShenandoahPhaseTimings::conc_weak_refs_work); ShenandoahGCWorkerPhase worker_phase(ShenandoahPhaseTimings::conc_weak_refs_work);
ref_processor()->process_references(workers(), true /* concurrent */); ref_processor()->process_references(ShenandoahPhaseTimings::conc_weak_refs_work, workers(), true /* concurrent */);
}
} }
void ShenandoahHeap::stw_weak_refs(bool full_gc) { void ShenandoahHeap::stw_weak_refs(bool full_gc) {
// Weak refs processing // Weak refs processing
ShenandoahTimingsTracker t(full_gc ? ShenandoahPhaseTimings::full_gc_weakrefs_process ShenandoahPhaseTimings::Phase phase = full_gc ? ShenandoahPhaseTimings::full_gc_weakrefs
: ShenandoahPhaseTimings::degen_gc_weakrefs_process); : ShenandoahPhaseTimings::degen_gc_weakrefs;
ShenandoahGCWorkerPhase worker_phase(full_gc ? ShenandoahPhaseTimings::full_gc_weakrefs_process ShenandoahTimingsTracker t(phase);
: ShenandoahPhaseTimings::degen_gc_weakrefs_process); ShenandoahGCWorkerPhase worker_phase(phase);
ref_processor()->process_references(workers(), false /* concurrent */); ref_processor()->process_references(phase, workers(), false /* concurrent */);
} }
void ShenandoahHeap::op_weak_roots() { void ShenandoahHeap::op_weak_roots() {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2017, 2020, Red Hat, Inc. All rights reserved. * Copyright (c) 2017, 2021, Red Hat, Inc. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -105,11 +105,11 @@ bool ShenandoahPhaseTimings::is_worker_phase(Phase phase) {
case full_gc_adjust_roots: case full_gc_adjust_roots:
case degen_gc_scan_conc_roots: case degen_gc_scan_conc_roots:
case degen_gc_update_roots: case degen_gc_update_roots:
case full_gc_weakrefs_process: case full_gc_weakrefs:
case full_gc_scan_conc_roots: case full_gc_scan_conc_roots:
case full_gc_purge_class_unload: case full_gc_purge_class_unload:
case full_gc_purge_weak_par: case full_gc_purge_weak_par:
case degen_gc_weakrefs_process: case degen_gc_weakrefs:
case degen_gc_purge_class_unload: case degen_gc_purge_class_unload:
case degen_gc_purge_weak_par: case degen_gc_purge_weak_par:
case heap_iteration_roots: case heap_iteration_roots:

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2017, 2020, Red Hat, Inc. All rights reserved. * Copyright (c) 2017, 2021, Red Hat, Inc. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -42,7 +42,7 @@ class outputStream;
f(CNT_PREFIX ## CLDGRoots, DESC_PREFIX "CLDG Roots") \ f(CNT_PREFIX ## CLDGRoots, DESC_PREFIX "CLDG Roots") \
f(CNT_PREFIX ## StringDedupTableRoots, DESC_PREFIX "Dedup Table Roots") \ f(CNT_PREFIX ## StringDedupTableRoots, DESC_PREFIX "Dedup Table Roots") \
f(CNT_PREFIX ## StringDedupQueueRoots, DESC_PREFIX "Dedup Queue Roots") \ f(CNT_PREFIX ## StringDedupQueueRoots, DESC_PREFIX "Dedup Queue Roots") \
f(CNT_PREFIX ## FinishQueues, DESC_PREFIX "Finish Queues") \ f(CNT_PREFIX ## WeakRefProc, DESC_PREFIX "Weak References") \
// end // end
#define SHENANDOAH_PHASE_DO(f) \ #define SHENANDOAH_PHASE_DO(f) \
@ -119,7 +119,7 @@ class outputStream;
f(degen_gc_scan_conc_roots, " Degen Mark Roots") \ f(degen_gc_scan_conc_roots, " Degen Mark Roots") \
SHENANDOAH_PAR_PHASE_DO(degen_gc_conc_mark_, " DM: ", f) \ SHENANDOAH_PAR_PHASE_DO(degen_gc_conc_mark_, " DM: ", f) \
f(degen_gc_weakrefs, " Weak References") \ f(degen_gc_weakrefs, " Weak References") \
f(degen_gc_weakrefs_process, " Process") \ SHENANDOAH_PAR_PHASE_DO(degen_gc_weakrefs_p_, " WRP: ", f) \
f(degen_gc_purge, " System Purge") \ f(degen_gc_purge, " System Purge") \
f(degen_gc_purge_class_unload, " Unload Classes") \ f(degen_gc_purge_class_unload, " Unload Classes") \
SHENANDOAH_PAR_PHASE_DO(degen_gc_purge_cu_par_, " DCU: ", f) \ SHENANDOAH_PAR_PHASE_DO(degen_gc_purge_cu_par_, " DCU: ", f) \
@ -142,7 +142,7 @@ class outputStream;
f(full_gc_mark, " Mark") \ f(full_gc_mark, " Mark") \
f(full_gc_mark_finish_queues, " Finish Queues") \ f(full_gc_mark_finish_queues, " Finish Queues") \
f(full_gc_weakrefs, " Weak References") \ f(full_gc_weakrefs, " Weak References") \
f(full_gc_weakrefs_process, " Process") \ SHENANDOAH_PAR_PHASE_DO(full_gc_weakrefs_p_, " WRP: ", f) \
f(full_gc_purge, " System Purge") \ f(full_gc_purge, " System Purge") \
f(full_gc_purge_class_unload, " Unload Classes") \ f(full_gc_purge_class_unload, " Unload Classes") \
SHENANDOAH_PAR_PHASE_DO(full_gc_purge_cu_par_, " CU: ", f) \ SHENANDOAH_PAR_PHASE_DO(full_gc_purge_cu_par_, " CU: ", f) \

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, Red Hat, Inc. and/or its affiliates. * Copyright (c) 2020, 2021, Red Hat, Inc. and/or its affiliates.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -473,26 +473,37 @@ void ShenandoahReferenceProcessor::work() {
class ShenandoahReferenceProcessorTask : public AbstractGangTask { class ShenandoahReferenceProcessorTask : public AbstractGangTask {
private: private:
bool const _concurrent;
ShenandoahPhaseTimings::Phase const _phase;
ShenandoahReferenceProcessor* const _reference_processor; ShenandoahReferenceProcessor* const _reference_processor;
public: public:
ShenandoahReferenceProcessorTask(ShenandoahReferenceProcessor* reference_processor) : ShenandoahReferenceProcessorTask(ShenandoahPhaseTimings::Phase phase, bool concurrent, ShenandoahReferenceProcessor* reference_processor) :
AbstractGangTask("ShenandoahReferenceProcessorTask"), AbstractGangTask("ShenandoahReferenceProcessorTask"),
_concurrent(concurrent),
_phase(phase),
_reference_processor(reference_processor) { _reference_processor(reference_processor) {
} }
virtual void work(uint worker_id) { virtual void work(uint worker_id) {
if (_concurrent) {
ShenandoahConcurrentWorkerSession worker_session(worker_id); ShenandoahConcurrentWorkerSession worker_session(worker_id);
ShenandoahWorkerTimingsTracker x(_phase, ShenandoahPhaseTimings::WeakRefProc, worker_id);
_reference_processor->work(); _reference_processor->work();
} else {
ShenandoahParallelWorkerSession worker_session(worker_id);
ShenandoahWorkerTimingsTracker x(_phase, ShenandoahPhaseTimings::WeakRefProc, worker_id);
_reference_processor->work();
}
} }
}; };
void ShenandoahReferenceProcessor::process_references(WorkGang* workers, bool concurrent) { void ShenandoahReferenceProcessor::process_references(ShenandoahPhaseTimings::Phase phase, WorkGang* workers, bool concurrent) {
Atomic::release_store_fence(&_iterate_discovered_list_id, 0U); Atomic::release_store_fence(&_iterate_discovered_list_id, 0U);
// Process discovered lists // Process discovered lists
ShenandoahReferenceProcessorTask task(this); ShenandoahReferenceProcessorTask task(phase, concurrent, this);
workers->run_task(&task); workers->run_task(&task);
// Update SoftReference clock // Update SoftReference clock

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, Red Hat, Inc. and/or its affiliates. * Copyright (c) 2020, 2021, Red Hat, Inc. and/or its affiliates.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -27,6 +27,7 @@
#define SHARE_VM_GC_SHENANDOAH_SHENANDOAHREFERENCEPROCESSOR_HPP #define SHARE_VM_GC_SHENANDOAH_SHENANDOAHREFERENCEPROCESSOR_HPP
#include "gc/shared/referenceDiscoverer.hpp" #include "gc/shared/referenceDiscoverer.hpp"
#include "gc/shenandoah/shenandoahPhaseTimings.hpp"
#include "memory/allocation.hpp" #include "memory/allocation.hpp"
class ShenandoahMarkRefsSuperClosure; class ShenandoahMarkRefsSuperClosure;
@ -176,7 +177,7 @@ public:
bool discover_reference(oop obj, ReferenceType type) override; bool discover_reference(oop obj, ReferenceType type) override;
void process_references(WorkGang* workers, bool concurrent); void process_references(ShenandoahPhaseTimings::Phase phase, WorkGang* workers, bool concurrent);
void work(); void work();