< prev index next >

src/hotspot/share/gc/g1/g1RemSetSummary.cpp

Print this page
rev 57544 : 8236485: Work-in-progress: Epoch synchronization protocol for G1 concurrent refinement
Reviewed-by:


  39 
  40 void G1RemSetSummary::update() {
  41   class CollectData : public ThreadClosure {
  42     G1RemSetSummary* _summary;
  43     uint _counter;
  44   public:
  45     CollectData(G1RemSetSummary * summary) : _summary(summary),  _counter(0) {}
  46     virtual void do_thread(Thread* t) {
  47       G1ConcurrentRefineThread* crt = static_cast<G1ConcurrentRefineThread*>(t);
  48       _summary->set_rs_thread_vtime(_counter, crt->vtime_accum());
  49       _counter++;
  50       _summary->_total_concurrent_refined_cards += crt->total_refined_cards();
  51     }
  52   } collector(this);
  53   G1CollectedHeap* g1h = G1CollectedHeap::heap();
  54   g1h->concurrent_refine()->threads_do(&collector);
  55   _total_mutator_refined_cards = G1BarrierSet::dirty_card_queue_set().total_mutator_refined_cards();
  56   _num_coarsenings = HeapRegionRemSet::n_coarsenings();
  57 
  58   set_sampling_thread_vtime(g1h->sampling_thread()->vtime_accum());









  59 }
  60 
  61 void G1RemSetSummary::set_rs_thread_vtime(uint thread, double value) {
  62   assert(_rs_threads_vtimes != NULL, "just checking");
  63   assert(thread < _num_vtimes, "just checking");
  64   _rs_threads_vtimes[thread] = value;
  65 }
  66 
  67 double G1RemSetSummary::rs_thread_vtime(uint thread) const {
  68   assert(_rs_threads_vtimes != NULL, "just checking");
  69   assert(thread < _num_vtimes, "just checking");
  70   return _rs_threads_vtimes[thread];
  71 }
  72 
  73 G1RemSetSummary::G1RemSetSummary(bool should_update) :
  74   _total_mutator_refined_cards(0),
  75   _total_concurrent_refined_cards(0),
  76   _num_coarsenings(0),
  77   _num_vtimes(G1ConcurrentRefine::max_num_threads()),
  78   _rs_threads_vtimes(NEW_C_HEAP_ARRAY(double, _num_vtimes, mtGC)),
  79   _sampling_thread_vtime(0.0f) {







  80 
  81   memset(_rs_threads_vtimes, 0, sizeof(double) * _num_vtimes);
  82 
  83   if (should_update) {
  84     update();
  85   }
  86 }
  87 
  88 G1RemSetSummary::~G1RemSetSummary() {
  89   FREE_C_HEAP_ARRAY(double, _rs_threads_vtimes);
  90 }
  91 
  92 void G1RemSetSummary::set(G1RemSetSummary* other) {
  93   assert(other != NULL, "just checking");
  94   assert(_num_vtimes == other->_num_vtimes, "just checking");
  95 
  96   _total_mutator_refined_cards = other->total_mutator_refined_cards();
  97   _total_concurrent_refined_cards = other->total_concurrent_refined_cards();
  98 
  99   _num_coarsenings = other->num_coarsenings();
 100 
 101   memcpy(_rs_threads_vtimes, other->_rs_threads_vtimes, sizeof(double) * _num_vtimes);
 102 
 103   set_sampling_thread_vtime(other->sampling_thread_vtime());








 104 }
 105 
 106 void G1RemSetSummary::subtract_from(G1RemSetSummary* other) {
 107   assert(other != NULL, "just checking");
 108   assert(_num_vtimes == other->_num_vtimes, "just checking");
 109 
 110   _total_mutator_refined_cards = other->total_mutator_refined_cards() - _total_mutator_refined_cards;
 111   _total_concurrent_refined_cards = other->total_concurrent_refined_cards() - _total_concurrent_refined_cards;
 112 
 113   _num_coarsenings = other->num_coarsenings() - _num_coarsenings;
 114 
 115   for (uint i = 0; i < _num_vtimes; i++) {
 116     set_rs_thread_vtime(i, other->rs_thread_vtime(i) - rs_thread_vtime(i));
 117   }
 118 
 119   _sampling_thread_vtime = other->sampling_thread_vtime() - _sampling_thread_vtime;








 120 }
 121 
 122 class RegionTypeCounter {
 123 private:
 124   const char* _name;
 125 
 126   size_t _rs_mem_size;
 127   size_t _cards_occupied;
 128   size_t _amount;
 129 
 130   size_t _code_root_mem_size;
 131   size_t _code_root_elems;
 132 
 133   double rs_mem_size_percent_of(size_t total) {
 134     return percent_of(_rs_mem_size, total);
 135   }
 136 
 137   double cards_occupied_percent_of(size_t total) {
 138     return percent_of(_cards_occupied, total);
 139   }


 330 };
 331 
 332 void G1RemSetSummary::print_on(outputStream* out) {
 333   out->print_cr(" Recent concurrent refinement statistics");
 334   out->print_cr("  Of " SIZE_FORMAT " refined cards:", total_refined_cards());
 335   out->print_cr("     " SIZE_FORMAT_W(8) " (%5.1f%%) by concurrent refinement threads.",
 336                 total_concurrent_refined_cards(),
 337                 percent_of(total_concurrent_refined_cards(), total_refined_cards()));
 338   out->print_cr("     " SIZE_FORMAT_W(8) " (%5.1f%%) by mutator threads.",
 339                 total_mutator_refined_cards(),
 340                 percent_of(total_mutator_refined_cards(), total_refined_cards()));
 341   out->print_cr("  Did " SIZE_FORMAT " coarsenings.", num_coarsenings());
 342   out->print_cr("  Concurrent refinement threads times (s)");
 343   out->print("     ");
 344   for (uint i = 0; i < _num_vtimes; i++) {
 345     out->print("    %5.2f", rs_thread_vtime(i));
 346   }
 347   out->cr();
 348   out->print_cr("  Concurrent sampling threads times (s)");
 349   out->print_cr("         %5.2f", sampling_thread_vtime());










 350 
 351   HRRSStatsIter blk;
 352   G1CollectedHeap::heap()->heap_region_iterate(&blk);
 353   blk.print_summary_on(out);
 354 }


  39 
  40 void G1RemSetSummary::update() {
  41   class CollectData : public ThreadClosure {
  42     G1RemSetSummary* _summary;
  43     uint _counter;
  44   public:
  45     CollectData(G1RemSetSummary * summary) : _summary(summary),  _counter(0) {}
  46     virtual void do_thread(Thread* t) {
  47       G1ConcurrentRefineThread* crt = static_cast<G1ConcurrentRefineThread*>(t);
  48       _summary->set_rs_thread_vtime(_counter, crt->vtime_accum());
  49       _counter++;
  50       _summary->_total_concurrent_refined_cards += crt->total_refined_cards();
  51     }
  52   } collector(this);
  53   G1CollectedHeap* g1h = G1CollectedHeap::heap();
  54   g1h->concurrent_refine()->threads_do(&collector);
  55   _total_mutator_refined_cards = G1BarrierSet::dirty_card_queue_set().total_mutator_refined_cards();
  56   _num_coarsenings = HeapRegionRemSet::n_coarsenings();
  57 
  58   set_sampling_thread_vtime(g1h->sampling_thread()->vtime_accum());
  59 
  60   G1EpochSynchronizerCounters* sync_counters = g1h->concurrent_refine()->synchronizer_counters();
  61   _num_fast_sync = sync_counters->num_fast_sync();
  62   _num_no_handshake_sync = sync_counters->num_no_handshake_sync();
  63   _num_handshake_sync = sync_counters->num_handshake_sync();
  64   _no_handshake_accum_time_ms = TimeHelper::counter_to_millis(sync_counters->no_handshake_accum_time_counter());
  65   _handshake_accum_time_ms = TimeHelper::counter_to_millis(sync_counters->handshake_accum_time_counter());
  66   _num_handshake_no_safepoint = sync_counters->num_handshake_no_safepoint();
  67   _num_handshake_safepoint = sync_counters->num_handshake_safepoint();
  68 }
  69 
  70 void G1RemSetSummary::set_rs_thread_vtime(uint thread, double value) {
  71   assert(_rs_threads_vtimes != NULL, "just checking");
  72   assert(thread < _num_vtimes, "just checking");
  73   _rs_threads_vtimes[thread] = value;
  74 }
  75 
  76 double G1RemSetSummary::rs_thread_vtime(uint thread) const {
  77   assert(_rs_threads_vtimes != NULL, "just checking");
  78   assert(thread < _num_vtimes, "just checking");
  79   return _rs_threads_vtimes[thread];
  80 }
  81 
  82 G1RemSetSummary::G1RemSetSummary(bool should_update) :
  83   _total_mutator_refined_cards(0),
  84   _total_concurrent_refined_cards(0),
  85   _num_coarsenings(0),
  86   _num_vtimes(G1ConcurrentRefine::max_num_threads()),
  87   _rs_threads_vtimes(NEW_C_HEAP_ARRAY(double, _num_vtimes, mtGC)),
  88   _sampling_thread_vtime(0.0f),
  89   _num_fast_sync(0),
  90   _num_no_handshake_sync(0),
  91   _num_handshake_sync(0),
  92   _no_handshake_accum_time_ms(0),
  93   _handshake_accum_time_ms(0),
  94   _num_handshake_no_safepoint(0),
  95   _num_handshake_safepoint(0) {
  96 
  97   memset(_rs_threads_vtimes, 0, sizeof(double) * _num_vtimes);
  98 
  99   if (should_update) {
 100     update();
 101   }
 102 }
 103 
 104 G1RemSetSummary::~G1RemSetSummary() {
 105   FREE_C_HEAP_ARRAY(double, _rs_threads_vtimes);
 106 }
 107 
 108 void G1RemSetSummary::set(G1RemSetSummary* other) {
 109   assert(other != NULL, "just checking");
 110   assert(_num_vtimes == other->_num_vtimes, "just checking");
 111 
 112   _total_mutator_refined_cards = other->total_mutator_refined_cards();
 113   _total_concurrent_refined_cards = other->total_concurrent_refined_cards();
 114 
 115   _num_coarsenings = other->num_coarsenings();
 116 
 117   memcpy(_rs_threads_vtimes, other->_rs_threads_vtimes, sizeof(double) * _num_vtimes);
 118 
 119   set_sampling_thread_vtime(other->sampling_thread_vtime());
 120 
 121   _num_fast_sync = other->num_fast_sync();
 122   _num_no_handshake_sync = other->num_no_handshake_sync();
 123   _num_handshake_sync = other->num_handshake_sync();
 124   _no_handshake_accum_time_ms = other->no_handshake_accum_time_ms();
 125   _handshake_accum_time_ms = other->handshake_accum_time_ms();
 126   _num_handshake_no_safepoint = other->num_handshake_no_safepoint();
 127   _num_handshake_safepoint = other->num_handshake_safepoint();
 128 }
 129 
 130 void G1RemSetSummary::subtract_from(G1RemSetSummary* other) {
 131   assert(other != NULL, "just checking");
 132   assert(_num_vtimes == other->_num_vtimes, "just checking");
 133 
 134   _total_mutator_refined_cards = other->total_mutator_refined_cards() - _total_mutator_refined_cards;
 135   _total_concurrent_refined_cards = other->total_concurrent_refined_cards() - _total_concurrent_refined_cards;
 136 
 137   _num_coarsenings = other->num_coarsenings() - _num_coarsenings;
 138 
 139   for (uint i = 0; i < _num_vtimes; i++) {
 140     set_rs_thread_vtime(i, other->rs_thread_vtime(i) - rs_thread_vtime(i));
 141   }
 142 
 143   _sampling_thread_vtime = other->sampling_thread_vtime() - _sampling_thread_vtime;
 144 
 145   _num_fast_sync = other->num_fast_sync() - _num_fast_sync;
 146   _num_no_handshake_sync = other->num_no_handshake_sync() - _num_no_handshake_sync;
 147   _num_handshake_sync = other->num_handshake_sync() - _num_handshake_sync;
 148   _no_handshake_accum_time_ms = other->no_handshake_accum_time_ms() - _no_handshake_accum_time_ms;
 149   _handshake_accum_time_ms = other->handshake_accum_time_ms() - _handshake_accum_time_ms;
 150   _num_handshake_no_safepoint = other->num_handshake_no_safepoint() - _num_handshake_no_safepoint;
 151   _num_handshake_safepoint = other->num_handshake_safepoint() - _num_handshake_safepoint;
 152 }
 153 
 154 class RegionTypeCounter {
 155 private:
 156   const char* _name;
 157 
 158   size_t _rs_mem_size;
 159   size_t _cards_occupied;
 160   size_t _amount;
 161 
 162   size_t _code_root_mem_size;
 163   size_t _code_root_elems;
 164 
 165   double rs_mem_size_percent_of(size_t total) {
 166     return percent_of(_rs_mem_size, total);
 167   }
 168 
 169   double cards_occupied_percent_of(size_t total) {
 170     return percent_of(_cards_occupied, total);
 171   }


 362 };
 363 
 364 void G1RemSetSummary::print_on(outputStream* out) {
 365   out->print_cr(" Recent concurrent refinement statistics");
 366   out->print_cr("  Of " SIZE_FORMAT " refined cards:", total_refined_cards());
 367   out->print_cr("     " SIZE_FORMAT_W(8) " (%5.1f%%) by concurrent refinement threads.",
 368                 total_concurrent_refined_cards(),
 369                 percent_of(total_concurrent_refined_cards(), total_refined_cards()));
 370   out->print_cr("     " SIZE_FORMAT_W(8) " (%5.1f%%) by mutator threads.",
 371                 total_mutator_refined_cards(),
 372                 percent_of(total_mutator_refined_cards(), total_refined_cards()));
 373   out->print_cr("  Did " SIZE_FORMAT " coarsenings.", num_coarsenings());
 374   out->print_cr("  Concurrent refinement threads times (s)");
 375   out->print("     ");
 376   for (uint i = 0; i < _num_vtimes; i++) {
 377     out->print("    %5.2f", rs_thread_vtime(i));
 378   }
 379   out->cr();
 380   out->print_cr("  Concurrent sampling threads times (s)");
 381   out->print_cr("         %5.2f", sampling_thread_vtime());
 382 
 383   out->print_cr("  Epoch synchronization statistics");
 384   out->print_cr("  fastpath   no-handshake(time (ms))   handshake(time (ms))   no_safepoint/safepoint");
 385   out->print_cr("  " SIZE_FORMAT_W(8) "   " SIZE_FORMAT_W(12) "(" SIZE_FORMAT_W(9)
 386                 ")   " SIZE_FORMAT_W(9) "(" SIZE_FORMAT_W(9) ")   "
 387                 SIZE_FORMAT_W(12) "/" SIZE_FORMAT_W(9),
 388                 num_fast_sync(),
 389                 num_no_handshake_sync(), no_handshake_accum_time_ms(),
 390                 num_handshake_sync(), handshake_accum_time_ms(),
 391                 num_handshake_no_safepoint(), num_handshake_safepoint());
 392 
 393   HRRSStatsIter blk;
 394   G1CollectedHeap::heap()->heap_region_iterate(&blk);
 395   blk.print_summary_on(out);
 396 }
< prev index next >