8258985: Parallel WeakProcessor may use too few threads

Use total workers rather than active.

Reviewed-by: tschatzl, ayang, sjohanss
This commit is contained in:
Kim Barrett 2021-01-13 08:22:40 +00:00
parent 417e1d1a4e
commit efc36be5be
2 changed files with 11 additions and 6 deletions

View File

@ -47,8 +47,9 @@ public:
// Visit all oop*s and apply the given closure.
static void oops_do(OopClosure* closure);
// Parallel version. Uses ergo_workers(), active workers, and
// phase_time's max_threads to determine the number of threads to use.
// Parallel version. Uses ergo_workers() to determine the number of
// threads to use, limited by the total workers and phase_times'
// max_threads.
// IsAlive must be derived from BoolObjectClosure.
// KeepAlive must be derived from OopClosure.
template<typename IsAlive, typename KeepAlive>
@ -57,8 +58,9 @@ public:
KeepAlive* keep_alive,
WeakProcessorPhaseTimes* phase_times);
// Convenience parallel version. Uses ergo_workers() and active workers
// to determine the number of threads to run. Implicitly logs phase times.
// Convenience parallel version. Uses ergo_workers() to determine the
// number of threads to use, limited by the total workers. Implicitly
// logs phase times.
// IsAlive must be derived from BoolObjectClosure.
// KeepAlive must be derived from OopClosure.
template<typename IsAlive, typename KeepAlive>
@ -67,7 +69,10 @@ public:
KeepAlive* keep_alive,
uint indent_log);
// Uses the total number of weak references and ReferencesPerThread to
// determine the number of threads to use, limited by max_workers.
static uint ergo_workers(uint max_workers);
class Task;
private:

View File

@ -134,7 +134,7 @@ void WeakProcessor::weak_oops_do(WorkGang* workers,
WeakProcessorPhaseTimes* phase_times) {
WeakProcessorTimeTracker tt(phase_times);
uint nworkers = ergo_workers(MIN2(workers->active_workers(),
uint nworkers = ergo_workers(MIN2(workers->total_workers(),
phase_times->max_threads()));
GangTask task("Weak Processor", is_alive, keep_alive, phase_times, nworkers);
@ -147,7 +147,7 @@ void WeakProcessor::weak_oops_do(WorkGang* workers,
IsAlive* is_alive,
KeepAlive* keep_alive,
uint indent_log) {
uint nworkers = ergo_workers(workers->active_workers());
uint nworkers = ergo_workers(workers->total_workers());
WeakProcessorPhaseTimes pt(nworkers);
weak_oops_do(workers, is_alive, keep_alive, &pt);
pt.log_print_phases(indent_log);