8203319: JDK-8201487 disabled too much queue balancing
Summary: Sometimes ignore ParallelRefProcBalancingEnabled.
Reviewed-by: tschatzl, sjohanss
--- a/src/hotspot/share/gc/shared/referenceProcessor.cpp Tue Jun 05 14:55:13 2018 +0200
+++ b/src/hotspot/share/gc/shared/referenceProcessor.cpp Tue Jun 05 09:15:03 2018 -0400
@@ -592,6 +592,28 @@
_next_id = 0;
}
+bool ReferenceProcessor::need_balance_queues(DiscoveredList refs_lists[]) {
+ assert(_processing_is_mt, "why balance non-mt processing?");
+ // _num_queues is the processing degree. Only list entries up to
+ // _num_queues will be processed, so any non-empty lists beyond
+ // that must be redistributed to lists in that range. Even if not
+ // needed for that, balancing may be desirable to eliminate poor
+ // distribution of references among the lists.
+ if (ParallelRefProcBalancingEnabled) {
+ return true; // Configuration says do it.
+ } else {
+ // Configuration says don't balance, but if there are non-empty
+ // lists beyond the processing degree, then must ignore the
+ // configuration and balance anyway.
+ for (uint i = _num_queues; i < _max_num_queues; ++i) {
+ if (!refs_lists[i].is_empty()) {
+ return true; // Must balance despite configuration.
+ }
+ }
+ return false; // Safe to obey configuration and not balance.
+ }
+}
+
// Balances reference queues.
// Move entries from all queues[0, 1, ..., _max_num_q-1] to
// queues[0, 1, ..., _num_q-1] because only the first _num_q
@@ -690,7 +712,7 @@
phase_times->set_processing_is_mt(mt_processing);
- if (mt_processing && ParallelRefProcBalancingEnabled) {
+ if (mt_processing && need_balance_queues(refs_lists)) {
RefProcBalanceQueuesTimeTracker tt(phase_times);
balance_queues(refs_lists);
}
--- a/src/hotspot/share/gc/shared/referenceProcessor.hpp Tue Jun 05 14:55:13 2018 +0200
+++ b/src/hotspot/share/gc/shared/referenceProcessor.hpp Tue Jun 05 09:15:03 2018 -0400
@@ -320,7 +320,8 @@
void log_reflist_counts(DiscoveredList ref_lists[], uint num_active_queues) PRODUCT_RETURN;
// Balances reference queues.
- void balance_queues(DiscoveredList ref_lists[]);
+ void balance_queues(DiscoveredList refs_lists[]);
+ bool need_balance_queues(DiscoveredList refs_lists[]);
// Update (advance) the soft ref master clock field.
void update_soft_ref_master_clock();