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

8269222: Incorrect number of workers reported for reference processing #4588

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -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);