src/hotspot/share/gc/shared/referenceProcessor.cpp
changeset 50401 bf7eb61349d2
parent 50277 f84ae8aa5d88
child 50605 7f63c74f0974
equal deleted inserted replaced
50400:dcbbc6fb0b69 50401:bf7eb61349d2
   590 void ReferenceProcessor::set_active_mt_degree(uint v) {
   590 void ReferenceProcessor::set_active_mt_degree(uint v) {
   591   _num_queues = v;
   591   _num_queues = v;
   592   _next_id = 0;
   592   _next_id = 0;
   593 }
   593 }
   594 
   594 
       
   595 bool ReferenceProcessor::need_balance_queues(DiscoveredList refs_lists[]) {
       
   596   assert(_processing_is_mt, "why balance non-mt processing?");
       
   597   // _num_queues is the processing degree.  Only list entries up to
       
   598   // _num_queues will be processed, so any non-empty lists beyond
       
   599   // that must be redistributed to lists in that range.  Even if not
       
   600   // needed for that, balancing may be desirable to eliminate poor
       
   601   // distribution of references among the lists.
       
   602   if (ParallelRefProcBalancingEnabled) {
       
   603     return true;                // Configuration says do it.
       
   604   } else {
       
   605     // Configuration says don't balance, but if there are non-empty
       
   606     // lists beyond the processing degree, then must ignore the
       
   607     // configuration and balance anyway.
       
   608     for (uint i = _num_queues; i < _max_num_queues; ++i) {
       
   609       if (!refs_lists[i].is_empty()) {
       
   610         return true;            // Must balance despite configuration.
       
   611       }
       
   612     }
       
   613     return false;               // Safe to obey configuration and not balance.
       
   614   }
       
   615 }
       
   616 
   595 // Balances reference queues.
   617 // Balances reference queues.
   596 // Move entries from all queues[0, 1, ..., _max_num_q-1] to
   618 // Move entries from all queues[0, 1, ..., _max_num_q-1] to
   597 // queues[0, 1, ..., _num_q-1] because only the first _num_q
   619 // queues[0, 1, ..., _num_q-1] because only the first _num_q
   598 // corresponding to the active workers will be processed.
   620 // corresponding to the active workers will be processed.
   599 void ReferenceProcessor::balance_queues(DiscoveredList ref_lists[])
   621 void ReferenceProcessor::balance_queues(DiscoveredList ref_lists[])
   688 {
   710 {
   689   bool mt_processing = task_executor != NULL && _processing_is_mt;
   711   bool mt_processing = task_executor != NULL && _processing_is_mt;
   690 
   712 
   691   phase_times->set_processing_is_mt(mt_processing);
   713   phase_times->set_processing_is_mt(mt_processing);
   692 
   714 
   693   if (mt_processing && ParallelRefProcBalancingEnabled) {
   715   if (mt_processing && need_balance_queues(refs_lists)) {
   694     RefProcBalanceQueuesTimeTracker tt(phase_times);
   716     RefProcBalanceQueuesTimeTracker tt(phase_times);
   695     balance_queues(refs_lists);
   717     balance_queues(refs_lists);
   696   }
   718   }
   697 
   719 
   698   // Phase 1 (soft refs only):
   720   // Phase 1 (soft refs only):