Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8215297: Remove ParallelTaskTerminator
Remove ParallelTaskTerminator as the alternate OWSTTaskTerminator algorithm has worked well for more than a year now.

Reviewed-by: zgu, sjohanss
  • Loading branch information
Thomas Schatzl committed Feb 3, 2020
1 parent 4b8a5f9 commit 76675e9
Show file tree
Hide file tree
Showing 21 changed files with 185 additions and 342 deletions.
17 changes: 9 additions & 8 deletions src/hotspot/share/gc/g1/g1CollectedHeap.cpp
Expand Up @@ -76,6 +76,7 @@
#include "gc/shared/isGCActiveMark.hpp"
#include "gc/shared/locationPrinter.inline.hpp"
#include "gc/shared/oopStorageParState.hpp"
#include "gc/shared/owstTaskTerminator.hpp"
#include "gc/shared/preservedMarks.inline.hpp"
#include "gc/shared/suspendibleThreadSet.hpp"
#include "gc/shared/referenceProcessor.inline.hpp"
Expand Down Expand Up @@ -1132,7 +1133,7 @@ void G1CollectedHeap::print_heap_after_full_collection(G1HeapTransition* heap_tr
print_heap_after_gc();
print_heap_regions();
#ifdef TRACESPINNING
ParallelTaskTerminator::print_termination_counts();
OWSTTaskTerminator::print_termination_counts();
#endif
}

Expand Down Expand Up @@ -3140,7 +3141,7 @@ void G1CollectedHeap::do_collection_pause_at_safepoint_helper(double target_paus
verify_after_young_collection(verify_type);

#ifdef TRACESPINNING
ParallelTaskTerminator::print_termination_counts();
OWSTTaskTerminator::print_termination_counts();
#endif

gc_epilogue(false);
Expand Down Expand Up @@ -3476,14 +3477,14 @@ class G1STWRefProcTaskProxy: public AbstractGangTask {
G1CollectedHeap* _g1h;
G1ParScanThreadStateSet* _pss;
RefToScanQueueSet* _task_queues;
ParallelTaskTerminator* _terminator;
OWSTTaskTerminator* _terminator;

public:
G1STWRefProcTaskProxy(ProcessTask& proc_task,
G1CollectedHeap* g1h,
G1ParScanThreadStateSet* per_thread_states,
RefToScanQueueSet *task_queues,
ParallelTaskTerminator* terminator) :
OWSTTaskTerminator* terminator) :
AbstractGangTask("Process reference objects in parallel"),
_proc_task(proc_task),
_g1h(g1h),
Expand Down Expand Up @@ -3527,8 +3528,8 @@ void G1STWRefProcTaskExecutor::execute(ProcessTask& proc_task, uint ergo_workers
assert(_workers->active_workers() >= ergo_workers,
"Ergonomically chosen workers (%u) should be less than or equal to active workers (%u)",
ergo_workers, _workers->active_workers());
TaskTerminator terminator(ergo_workers, _queues);
G1STWRefProcTaskProxy proc_task_proxy(proc_task, _g1h, _pss, _queues, terminator.terminator());
OWSTTaskTerminator terminator(ergo_workers, _queues);
G1STWRefProcTaskProxy proc_task_proxy(proc_task, _g1h, _pss, _queues, &terminator);

_workers->run_task(&proc_task_proxy, ergo_workers);
}
Expand Down Expand Up @@ -3814,7 +3815,7 @@ class G1EvacuateRegionsBaseTask : public AbstractGangTask {
G1CollectedHeap* _g1h;
G1ParScanThreadStateSet* _per_thread_states;
RefToScanQueueSet* _task_queues;
TaskTerminator _terminator;
OWSTTaskTerminator _terminator;
uint _num_workers;

void evacuate_live_objects(G1ParScanThreadState* pss,
Expand All @@ -3824,7 +3825,7 @@ class G1EvacuateRegionsBaseTask : public AbstractGangTask {
G1GCPhaseTimes* p = _g1h->phase_times();

Ticks start = Ticks::now();
G1ParEvacuateFollowersClosure cl(_g1h, pss, _task_queues, _terminator.terminator(), objcopy_phase);
G1ParEvacuateFollowersClosure cl(_g1h, pss, _task_queues, &_terminator, objcopy_phase);
cl.do_void();

assert(pss->queue_is_empty(), "should be empty");
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/share/gc/g1/g1CollectedHeap.hpp
Expand Up @@ -1482,18 +1482,18 @@ class G1ParEvacuateFollowersClosure : public VoidClosure {
G1CollectedHeap* _g1h;
G1ParScanThreadState* _par_scan_state;
RefToScanQueueSet* _queues;
ParallelTaskTerminator* _terminator;
OWSTTaskTerminator* _terminator;
G1GCPhaseTimes::GCParPhases _phase;

G1ParScanThreadState* par_scan_state() { return _par_scan_state; }
RefToScanQueueSet* queues() { return _queues; }
ParallelTaskTerminator* terminator() { return _terminator; }
OWSTTaskTerminator* terminator() { return _terminator; }

public:
G1ParEvacuateFollowersClosure(G1CollectedHeap* g1h,
G1ParScanThreadState* par_scan_state,
RefToScanQueueSet* queues,
ParallelTaskTerminator* terminator,
OWSTTaskTerminator* terminator,
G1GCPhaseTimes::GCParPhases phase)
: _start_term(0.0), _term_time(0.0), _term_attempts(0),
_g1h(g1h), _par_scan_state(par_scan_state),
Expand Down
5 changes: 3 additions & 2 deletions src/hotspot/share/gc/g1/g1ConcurrentMark.cpp
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -46,6 +46,7 @@
#include "gc/shared/gcTraceTime.inline.hpp"
#include "gc/shared/gcVMOperations.hpp"
#include "gc/shared/genOopClosures.inline.hpp"
#include "gc/shared/owstTaskTerminator.hpp"
#include "gc/shared/referencePolicy.hpp"
#include "gc/shared/strongRootsScope.hpp"
#include "gc/shared/suspendibleThreadSet.hpp"
Expand Down Expand Up @@ -600,7 +601,7 @@ void G1ConcurrentMark::set_concurrency(uint active_tasks) {
_num_active_tasks = active_tasks;
// Need to update the three data structures below according to the
// number of active threads for this phase.
_terminator.terminator()->reset_for_reuse((int) active_tasks);
_terminator.reset_for_reuse(active_tasks);
_first_overflow_barrier_sync.set_n_workers((int) active_tasks);
_second_overflow_barrier_sync.set_n_workers((int) active_tasks);
}
Expand Down
13 changes: 7 additions & 6 deletions src/hotspot/share/gc/g1/g1ConcurrentMark.hpp
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -30,6 +30,7 @@
#include "gc/g1/g1HeapVerifier.hpp"
#include "gc/g1/g1RegionMarkStatsCache.hpp"
#include "gc/g1/heapRegionSet.hpp"
#include "gc/shared/owstTaskTerminator.hpp"
#include "gc/shared/taskqueue.hpp"
#include "gc/shared/verifyOption.hpp"
#include "gc/shared/workgroup.hpp"
Expand Down Expand Up @@ -328,7 +329,7 @@ class G1ConcurrentMark : public CHeapObj<mtGC> {
G1CMTask** _tasks; // Task queue array (max_worker_id length)

G1CMTaskQueueSet* _task_queues; // Task queue set
TaskTerminator _terminator; // For termination
OWSTTaskTerminator _terminator; // For termination

// Two sync barriers that are used to synchronize tasks when an
// overflow occurs. The algorithm is the following. All tasks enter
Expand Down Expand Up @@ -414,10 +415,10 @@ class G1ConcurrentMark : public CHeapObj<mtGC> {
// Prints all gathered CM-related statistics
void print_stats();

HeapWord* finger() { return _finger; }
bool concurrent() { return _concurrent; }
uint active_tasks() { return _num_active_tasks; }
ParallelTaskTerminator* terminator() const { return _terminator.terminator(); }
HeapWord* finger() { return _finger; }
bool concurrent() { return _concurrent; }
uint active_tasks() { return _num_active_tasks; }
OWSTTaskTerminator* terminator() { return &_terminator; }

// Claims the next available region to be scanned by a marking
// task/thread. It might return NULL if the next region is empty or
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/gc/g1/g1FullGCMarkTask.cpp
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -59,7 +59,7 @@ void G1FullGCMarkTask::work(uint worker_id) {
}

// Mark stack is populated, now process and drain it.
marker->complete_marking(collector()->oop_queue_set(), collector()->array_queue_set(), _terminator.terminator());
marker->complete_marking(collector()->oop_queue_set(), collector()->array_queue_set(), &_terminator);

// This is the point where the entire marking should have completed.
assert(marker->oop_stack()->is_empty(), "Marking should have completed");
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/gc/g1/g1FullGCMarkTask.hpp
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -36,7 +36,7 @@

class G1FullGCMarkTask : public G1FullGCTask {
G1RootProcessor _root_processor;
TaskTerminator _terminator;
OWSTTaskTerminator _terminator;

public:
G1FullGCMarkTask(G1FullCollector* collector);
Expand Down
5 changes: 3 additions & 2 deletions src/hotspot/share/gc/g1/g1FullGCMarker.cpp
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -25,6 +25,7 @@
#include "precompiled.hpp"
#include "classfile/classLoaderData.hpp"
#include "gc/g1/g1FullGCMarker.inline.hpp"
#include "gc/shared/owstTaskTerminator.hpp"
#include "gc/shared/referenceProcessor.hpp"
#include "gc/shared/verifyOption.hpp"
#include "memory/iterator.inline.hpp"
Expand All @@ -49,7 +50,7 @@ G1FullGCMarker::~G1FullGCMarker() {

void G1FullGCMarker::complete_marking(OopQueueSet* oop_stacks,
ObjArrayTaskQueueSet* array_stacks,
ParallelTaskTerminator* terminator) {
OWSTTaskTerminator* terminator) {
do {
drain_stack();
ObjArrayTask steal_array;
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/gc/g1/g1FullGCMarker.hpp
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -87,7 +87,7 @@ class G1FullGCMarker : public CHeapObj<mtGC> {
inline void drain_stack();
void complete_marking(OopQueueSet* oop_stacks,
ObjArrayTaskQueueSet* array_stacks,
ParallelTaskTerminator* terminator);
OWSTTaskTerminator* terminator);

// Closure getters
CLDToOopClosure* cld_closure() { return &_cld_closure; }
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -61,7 +61,7 @@ class G1FullGCReferenceProcessingExecutor: public AbstractRefProcTaskExecutor {
typedef AbstractRefProcTaskExecutor::ProcessTask ProcessTask;
ProcessTask& _proc_task;
G1FullCollector* _collector;
TaskTerminator _terminator;
OWSTTaskTerminator _terminator;

public:
G1RefProcTaskProxy(ProcessTask& proc_task,
Expand Down
3 changes: 1 addition & 2 deletions src/hotspot/share/gc/parallel/psCompactionManager.hpp
Expand Up @@ -38,7 +38,6 @@ class ParallelCompactData;
class ParMarkBitMap;

class ParCompactionManager : public CHeapObj<mtGC> {
friend class ParallelTaskTerminator;
friend class ParMarkBitMap;
friend class PSParallelCompact;
friend class CompactionWithStealingTask;
Expand Down Expand Up @@ -96,7 +95,7 @@ class ParCompactionManager : public CHeapObj<mtGC> {
static void initialize(ParMarkBitMap* mbm);

protected:
// Array of tasks. Needed by the ParallelTaskTerminator.
// Array of task queues. Needed by the task terminator.
static RegionTaskQueueSet* region_array() { return _region_array; }
OverflowTaskQueue<oop, mtGC>* marking_stack() { return &_marking_stack; }

Expand Down
21 changes: 11 additions & 10 deletions src/hotspot/share/gc/parallel/psParallelCompact.cpp
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -49,6 +49,7 @@
#include "gc/shared/gcTrace.hpp"
#include "gc/shared/gcTraceTime.inline.hpp"
#include "gc/shared/isGCActiveMark.hpp"
#include "gc/shared/owstTaskTerminator.hpp"
#include "gc/shared/referencePolicy.hpp"
#include "gc/shared/referenceProcessor.hpp"
#include "gc/shared/referenceProcessorPhaseTimes.hpp"
Expand Down Expand Up @@ -1969,7 +1970,7 @@ bool PSParallelCompact::invoke_no_policy(bool maximum_heap_compaction) {
collection_exit.ticks());

#ifdef TRACESPINNING
ParallelTaskTerminator::print_termination_counts();
OWSTTaskTerminator::print_termination_counts();
#endif

AdaptiveSizePolicyOutput::print(size_policy, heap->total_collections());
Expand Down Expand Up @@ -2149,7 +2150,7 @@ static void mark_from_roots_work(ParallelRootType::Value root_type, uint worker_
cm->follow_marking_stacks();
}

static void steal_marking_work(ParallelTaskTerminator& terminator, uint worker_id) {
static void steal_marking_work(OWSTTaskTerminator& terminator, uint worker_id) {
assert(ParallelScavengeHeap::heap()->is_gc_active(), "called outside gc");

ParCompactionManager* cm =
Expand All @@ -2173,7 +2174,7 @@ class MarkFromRootsTask : public AbstractGangTask {
typedef AbstractRefProcTaskExecutor::ProcessTask ProcessTask;
StrongRootsScope _strong_roots_scope; // needed for Threads::possibly_parallel_threads_do
SequentialSubTasksDone _subtasks;
TaskTerminator _terminator;
OWSTTaskTerminator _terminator;
uint _active_workers;

public:
Expand All @@ -2197,7 +2198,7 @@ class MarkFromRootsTask : public AbstractGangTask {
Threads::possibly_parallel_threads_do(true /*parallel */, &closure);

if (_active_workers > 1) {
steal_marking_work(*_terminator.terminator(), worker_id);
steal_marking_work(_terminator, worker_id);
}
}
};
Expand All @@ -2206,7 +2207,7 @@ class PCRefProcTask : public AbstractGangTask {
typedef AbstractRefProcTaskExecutor::ProcessTask ProcessTask;
ProcessTask& _task;
uint _ergo_workers;
TaskTerminator _terminator;
OWSTTaskTerminator _terminator;

public:
PCRefProcTask(ProcessTask& task, uint ergo_workers) :
Expand All @@ -2227,7 +2228,7 @@ class PCRefProcTask : public AbstractGangTask {
_task.work(worker_id, *PSParallelCompact::is_alive_closure(),
mark_and_push_closure, follow_stack_closure);

steal_marking_work(*_terminator.terminator(), worker_id);
steal_marking_work(_terminator, worker_id);
}
};

Expand Down Expand Up @@ -2586,7 +2587,7 @@ void PSParallelCompact::write_block_fill_histogram()
}
#endif // #ifdef ASSERT

static void compaction_with_stealing_work(ParallelTaskTerminator* terminator, uint worker_id) {
static void compaction_with_stealing_work(OWSTTaskTerminator* terminator, uint worker_id) {
assert(ParallelScavengeHeap::heap()->is_gc_active(), "called outside gc");

ParCompactionManager* cm =
Expand Down Expand Up @@ -2622,7 +2623,7 @@ static void compaction_with_stealing_work(ParallelTaskTerminator* terminator, ui
class UpdateDensePrefixAndCompactionTask: public AbstractGangTask {
typedef AbstractRefProcTaskExecutor::ProcessTask ProcessTask;
TaskQueue& _tq;
TaskTerminator _terminator;
OWSTTaskTerminator _terminator;
uint _active_workers;

public:
Expand All @@ -2644,7 +2645,7 @@ class UpdateDensePrefixAndCompactionTask: public AbstractGangTask {

// Once a thread has drained it's stack, it should try to steal regions from
// other threads.
compaction_with_stealing_work(_terminator.terminator(), worker_id);
compaction_with_stealing_work(&_terminator, worker_id);
}
};

Expand Down
2 changes: 0 additions & 2 deletions src/hotspot/share/gc/parallel/psParallelCompact.hpp
Expand Up @@ -40,9 +40,7 @@ class PSAdaptiveSizePolicy;
class PSYoungGen;
class PSOldGen;
class ParCompactionManager;
class ParallelTaskTerminator;
class PSParallelCompact;
class PreGCValues;
class MoveAndUpdateClosure;
class RefProcTaskExecutor;
class ParallelOldTracer;
Expand Down

0 comments on commit 76675e9

Please sign in to comment.