Summary
-------
Make the option `ParallelRefProcEnabled` to default to `true` for Parallel GC. Make reference processing for Parallel GC use the same heuristics as for G1 to calculate the number of threads to use for this phase.
Problem
-------
Today, the behaviour of G1 and Parallel GC differs in that in G1 the option `ParallelRefProcEnabled` is `true` by default and uses some heuristics to set the amount of worker threads depending on the actually observed reference count. Neither is currently true for Parallel GC: the default for `ParallelRefProcEnabled` is `false`, and if the user manually enables it, all available gc worker threads will be used.
Solution
--------
Set `ParallelRefProcEnabled` to `true` by default and remove the special handling in Parallel GC so that it also uses the same ergonomic calculations as G1 for thread counts.
This change is positive in two ways: First it will make both garbage collectors use the same defaults and heuristics, second it will by default increase performance for Parallel GC when processing many references.
Specification
-------------
diff --git a/src/hotspot/share/gc/parallel/parallelArguments.cpp b/src/hotspot/share/gc/parallel/parallelArguments.cpp
index 185d2266796..2ffffdf1455 100644
--- a/src/hotspot/share/gc/parallel/parallelArguments.cpp
+++ b/src/hotspot/share/gc/parallel/parallelArguments.cpp
@@ -85,6 +85,10 @@ void ParallelArguments::initialize() {
if (FLAG_IS_DEFAULT(MarkSweepDeadRatio)) {
FLAG_SET_DEFAULT(MarkSweepDeadRatio, 1);
}
+
+ if (FLAG_IS_DEFAULT(ParallelRefProcEnabled) && ParallelGCThreads > 1) {
+ FLAG_SET_DEFAULT(ParallelRefProcEnabled, true);
+ }
}
// The alignment used for boundary between young gen and old gen