Skip to content
Permalink
Browse files
8269222: Incorrect number of workers reported for reference processing
Reviewed-by: tschatzl, sangheki
  • Loading branch information
albertnetymk committed Jun 28, 2021
1 parent 4d2412e commit 87ff27786b7310840aab00c391e2a7fa19a3c328
@@ -525,7 +525,7 @@ class RefProcPhase1Task : public RefProcTask {
OopClosure* keep_alive,
VoidClosure* complete_gc) override {
ResourceMark rm;
RefProcSubPhasesWorkerTimeTracker tt(ReferenceProcessor::SoftRefSubPhase1, _phase_times, worker_id);
RefProcSubPhasesWorkerTimeTracker tt(ReferenceProcessor::SoftRefSubPhase1, _phase_times, tracker_id(worker_id));
size_t const removed = _ref_processor.process_soft_ref_reconsider_work(_ref_processor._discoveredSoftRefs[worker_id],
_policy,
is_alive,
@@ -563,17 +563,17 @@ class RefProcPhase2Task: public RefProcTask {
OopClosure* keep_alive,
VoidClosure* complete_gc) override {
ResourceMark rm;
RefProcWorkerTimeTracker t(_phase_times->phase2_worker_time_sec(), worker_id);
RefProcWorkerTimeTracker t(_phase_times->phase2_worker_time_sec(), tracker_id(worker_id));
{
RefProcSubPhasesWorkerTimeTracker tt(ReferenceProcessor::SoftRefSubPhase2, _phase_times, worker_id);
RefProcSubPhasesWorkerTimeTracker tt(ReferenceProcessor::SoftRefSubPhase2, _phase_times, tracker_id(worker_id));
run_phase2(worker_id, _ref_processor._discoveredSoftRefs, is_alive, keep_alive, true /* do_enqueue_and_clear */, REF_SOFT);
}
{
RefProcSubPhasesWorkerTimeTracker tt(ReferenceProcessor::WeakRefSubPhase2, _phase_times, worker_id);
RefProcSubPhasesWorkerTimeTracker tt(ReferenceProcessor::WeakRefSubPhase2, _phase_times, tracker_id(worker_id));
run_phase2(worker_id, _ref_processor._discoveredWeakRefs, is_alive, keep_alive, true /* do_enqueue_and_clear */, REF_WEAK);
}
{
RefProcSubPhasesWorkerTimeTracker tt(ReferenceProcessor::FinalRefSubPhase2, _phase_times, worker_id);
RefProcSubPhasesWorkerTimeTracker tt(ReferenceProcessor::FinalRefSubPhase2, _phase_times, tracker_id(worker_id));
run_phase2(worker_id, _ref_processor._discoveredFinalRefs, is_alive, keep_alive, false /* do_enqueue_and_clear */, REF_FINAL);
}
// Close the reachable set; needed for collectors which keep_alive_closure do
@@ -594,7 +594,7 @@ class RefProcPhase3Task: public RefProcTask {
OopClosure* keep_alive,
VoidClosure* complete_gc) override {
ResourceMark rm;
RefProcSubPhasesWorkerTimeTracker tt(ReferenceProcessor::FinalRefSubPhase3, _phase_times, worker_id);
RefProcSubPhasesWorkerTimeTracker tt(ReferenceProcessor::FinalRefSubPhase3, _phase_times, tracker_id(worker_id));
_ref_processor.process_final_keep_alive_work(_ref_processor._discoveredFinalRefs[worker_id], keep_alive, complete_gc);
}
};
@@ -611,7 +611,7 @@ class RefProcPhase4Task: public RefProcTask {
OopClosure* keep_alive,
VoidClosure* complete_gc) override {
ResourceMark rm;
RefProcSubPhasesWorkerTimeTracker tt(ReferenceProcessor::PhantomRefSubPhase4, _phase_times, worker_id);
RefProcSubPhasesWorkerTimeTracker tt(ReferenceProcessor::PhantomRefSubPhase4, _phase_times, tracker_id(worker_id));
size_t const removed = _ref_processor.process_phantom_refs_work(_ref_processor._discoveredPhantomRefs[worker_id],
is_alive,
keep_alive,
@@ -573,6 +573,10 @@ class RefProcTask : StackObj {
ReferenceProcessor& _ref_processor;
ReferenceProcessorPhaseTimes* _phase_times;

// Used for tracking how much time a worker spends in a (sub)phase.
uint tracker_id(uint worker_id) const {
return _ref_processor.processing_is_mt() ? worker_id : 0;
}
public:
RefProcTask(ReferenceProcessor& ref_processor,
ReferenceProcessorPhaseTimes* phase_times)
@@ -98,7 +98,7 @@ RefProcWorkerTimeTracker::RefProcWorkerTimeTracker(WorkerDataArray<double>* work

RefProcWorkerTimeTracker::~RefProcWorkerTimeTracker() {
double result = os::elapsedTime() - _start_time;
_worker_time->set(_worker_id, result);
_worker_time->set_or_add(_worker_id, result);
}

RefProcSubPhasesWorkerTimeTracker::RefProcSubPhasesWorkerTimeTracker(ReferenceProcessor::RefProcSubPhases phase,
@@ -67,6 +67,7 @@ class WorkerDataArray : public CHeapObj<mtGC> {
static T uninitialized();

void set(uint worker_i, T value);
void set_or_add(uint worker_i, T value);
T get(uint worker_i) const;

void add(uint worker_i, T value);
@@ -53,6 +53,16 @@ void WorkerDataArray<T>::set(uint worker_i, T value) {
_data[worker_i] = value;
}

template <typename T>
void WorkerDataArray<T>::set_or_add(uint worker_i, T value) {
assert(worker_i < _length, "Worker %d is greater than max: %d", worker_i, _length);
if (_data[worker_i] == uninitialized()) {
_data[worker_i] = value;
} else {
_data[worker_i] += value;
}
}

template <typename T>
T WorkerDataArray<T>::get(uint worker_i) const {
assert(worker_i < _length, "Worker %d is greater than max: %d", worker_i, _length);

1 comment on commit 87ff277

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on 87ff277 Jun 28, 2021

Please sign in to comment.