< prev index next >

src/hotspot/share/gc/shared/referenceProcessorPhaseTimes.cpp

Print this page
rev 49836 : [mq]: 8202017-reference-processor-remove-enqueue


  61   _start_ticks.stamp();
  62   if (_phase_times->gc_timer() != NULL) {
  63     _phase_times->gc_timer()->register_gc_phase_start(_title, _start_ticks);
  64   }
  65 }
  66 
  67 static const char* phase_enum_2_phase_string(ReferenceProcessorPhaseTimes::RefProcParPhases phase) {
  68   switch(phase) {
  69     case ReferenceProcessorPhaseTimes::SoftRefPhase1:
  70       return "Phase1";
  71     case ReferenceProcessorPhaseTimes::SoftRefPhase2:
  72     case ReferenceProcessorPhaseTimes::WeakRefPhase2:
  73     case ReferenceProcessorPhaseTimes::FinalRefPhase2:
  74     case ReferenceProcessorPhaseTimes::PhantomRefPhase2:
  75       return "Phase2";
  76     case ReferenceProcessorPhaseTimes::SoftRefPhase3:
  77     case ReferenceProcessorPhaseTimes::WeakRefPhase3:
  78     case ReferenceProcessorPhaseTimes::FinalRefPhase3:
  79     case ReferenceProcessorPhaseTimes::PhantomRefPhase3:
  80       return "Phase3";
  81     case ReferenceProcessorPhaseTimes::RefEnqueue:
  82       return "Reference Enqueuing";
  83     default:
  84       ShouldNotReachHere();
  85       return NULL;
  86   }
  87 }
  88 
  89 static const char* Indents[6] = {"", "  ", "    ", "      ", "        ", "          "};
  90 
  91 Ticks RefProcPhaseTimeBaseTracker::end_ticks() {
  92   // If ASSERT is defined, the default value of Ticks will be -2.
  93   if (_end_ticks.value() <= 0) {
  94     _end_ticks.stamp();
  95   }
  96 
  97   return _end_ticks;
  98 }
  99 
 100 double RefProcPhaseTimeBaseTracker::elapsed_time() {
 101   jlong end_value = end_ticks().value();
 102 


 174                                                    ReferenceProcessorPhaseTimes* phase_times,
 175                                                    ReferenceProcessor* rp) :
 176   _rp(rp), RefProcPhaseTimeBaseTracker(ref_type_2_string(ref_type), phase_times) {
 177   phase_times->set_processing_ref_type(ref_type);
 178 
 179   size_t discovered = rp->total_reference_count(ref_type);
 180   phase_times->set_ref_discovered(ref_type, discovered);
 181 }
 182 
 183 RefProcPhaseTimesTracker::~RefProcPhaseTimesTracker() {
 184   double elapsed = elapsed_time();
 185   ReferenceProcessorPhaseTimes* times = phase_times();
 186   ReferenceType ref_type = times->processing_ref_type();
 187   times->set_ref_proc_time_ms(ref_type, elapsed);
 188 
 189   size_t after_count = _rp->total_reference_count(ref_type);
 190   size_t discovered = times->ref_discovered(ref_type);
 191   times->set_ref_cleared(ref_type, discovered - after_count);
 192 }
 193 
 194 RefProcEnqueueTimeTracker::RefProcEnqueueTimeTracker(ReferenceProcessorPhaseTimes* phase_times,
 195                                                      ReferenceProcessorStats& stats) :
 196   RefProcPhaseTimeBaseTracker("Reference Enqueuing", phase_times) {
 197     phase_times->set_ref_enqueued(REF_SOFT, stats.soft_count());
 198     phase_times->set_ref_enqueued(REF_WEAK, stats.weak_count());
 199     phase_times->set_ref_enqueued(REF_FINAL, stats.final_count());
 200     phase_times->set_ref_enqueued(REF_PHANTOM, stats.phantom_count());
 201 }
 202 
 203 RefProcEnqueueTimeTracker::~RefProcEnqueueTimeTracker() {
 204   double elapsed = elapsed_time();
 205 
 206   phase_times()->set_par_phase_time_ms(ReferenceProcessorPhaseTimes::RefEnqueue, elapsed);
 207 }
 208 
 209 ReferenceProcessorPhaseTimes::ReferenceProcessorPhaseTimes(GCTimer* gc_timer, uint max_gc_threads) :
 210   _gc_timer(gc_timer), _processing_is_mt(false) {
 211 
 212   for (int i = 0; i < RefParPhaseMax; i++) {
 213     _worker_time_sec[i] = new WorkerDataArray<double>(max_gc_threads, "Process lists (ms)");
 214     _par_phase_time_ms[i] = uninitialized();
 215   }
 216 
 217   for (int i = 0; i < number_of_subclasses_of_ref; i++) {
 218     _ref_proc_time_ms[i] = uninitialized();
 219     _balance_queues_time_ms[i] = uninitialized();
 220     _ref_cleared[i] = 0;
 221     _ref_discovered[i] = 0;
 222     _ref_enqueued[i] = 0;
 223   }
 224 }
 225 
 226 inline int ref_type_2_index(ReferenceType ref_type) {
 227   return ref_type - REF_SOFT;
 228 }


 350       result = (int)FinalRefPhase2;
 351       result += (phase_number - 1);
 352       assert((RefProcParPhases)result >= FinalRefPhase2 &&
 353              (RefProcParPhases)result <= FinalRefPhase3,
 354              "Invariant (%d)", result);
 355       break;
 356     case REF_PHANTOM:
 357       result = (int)PhantomRefPhase2;
 358       result += (phase_number - 1);
 359       assert((RefProcParPhases)result >= PhantomRefPhase2 &&
 360              (RefProcParPhases)result <= PhantomRefPhase3,
 361              "Invariant (%d)", result);
 362       break;
 363     default:
 364       ShouldNotReachHere();
 365   }
 366 
 367   ASSERT_PAR_PHASE(result);
 368 
 369   return (RefProcParPhases)result;
 370 }
 371 
 372 void ReferenceProcessorPhaseTimes::print_enqueue_phase(uint base_indent, bool print_total) const {
 373   if (print_total) {
 374     print_phase(RefEnqueue, base_indent);
 375   }
 376 
 377   log_debug(gc, phases, ref)("%sReference Counts:  Soft: " SIZE_FORMAT "  Weak: " SIZE_FORMAT
 378                              "  Final: " SIZE_FORMAT "  Phantom: " SIZE_FORMAT ,
 379                              Indents[base_indent + 1], ref_enqueued(REF_SOFT), ref_enqueued(REF_WEAK),
 380                              ref_enqueued(REF_FINAL), ref_enqueued(REF_PHANTOM));
 381 }
 382 
 383 #define TIME_FORMAT "%.1lfms"
 384 
 385 void ReferenceProcessorPhaseTimes::print_all_references(uint base_indent, bool print_total) const {
 386   if (print_total) {
 387     LogTarget(Debug, gc, phases, ref) lt;
 388 
 389     if (lt.is_enabled()) {
 390       LogStream ls(lt);
 391       ls.print_cr("%s%s: " TIME_FORMAT,
 392                   Indents[base_indent], "Reference Processing", total_time_ms());
 393     }
 394   }
 395 
 396   uint next_indent = base_indent + 1;
 397   print_reference(REF_SOFT, next_indent);
 398   print_reference(REF_WEAK, next_indent);
 399   print_reference(REF_FINAL, next_indent);
 400   print_reference(REF_PHANTOM, next_indent);




  61   _start_ticks.stamp();
  62   if (_phase_times->gc_timer() != NULL) {
  63     _phase_times->gc_timer()->register_gc_phase_start(_title, _start_ticks);
  64   }
  65 }
  66 
  67 static const char* phase_enum_2_phase_string(ReferenceProcessorPhaseTimes::RefProcParPhases phase) {
  68   switch(phase) {
  69     case ReferenceProcessorPhaseTimes::SoftRefPhase1:
  70       return "Phase1";
  71     case ReferenceProcessorPhaseTimes::SoftRefPhase2:
  72     case ReferenceProcessorPhaseTimes::WeakRefPhase2:
  73     case ReferenceProcessorPhaseTimes::FinalRefPhase2:
  74     case ReferenceProcessorPhaseTimes::PhantomRefPhase2:
  75       return "Phase2";
  76     case ReferenceProcessorPhaseTimes::SoftRefPhase3:
  77     case ReferenceProcessorPhaseTimes::WeakRefPhase3:
  78     case ReferenceProcessorPhaseTimes::FinalRefPhase3:
  79     case ReferenceProcessorPhaseTimes::PhantomRefPhase3:
  80       return "Phase3";


  81     default:
  82       ShouldNotReachHere();
  83       return NULL;
  84   }
  85 }
  86 
  87 static const char* Indents[6] = {"", "  ", "    ", "      ", "        ", "          "};
  88 
  89 Ticks RefProcPhaseTimeBaseTracker::end_ticks() {
  90   // If ASSERT is defined, the default value of Ticks will be -2.
  91   if (_end_ticks.value() <= 0) {
  92     _end_ticks.stamp();
  93   }
  94 
  95   return _end_ticks;
  96 }
  97 
  98 double RefProcPhaseTimeBaseTracker::elapsed_time() {
  99   jlong end_value = end_ticks().value();
 100 


 172                                                    ReferenceProcessorPhaseTimes* phase_times,
 173                                                    ReferenceProcessor* rp) :
 174   _rp(rp), RefProcPhaseTimeBaseTracker(ref_type_2_string(ref_type), phase_times) {
 175   phase_times->set_processing_ref_type(ref_type);
 176 
 177   size_t discovered = rp->total_reference_count(ref_type);
 178   phase_times->set_ref_discovered(ref_type, discovered);
 179 }
 180 
 181 RefProcPhaseTimesTracker::~RefProcPhaseTimesTracker() {
 182   double elapsed = elapsed_time();
 183   ReferenceProcessorPhaseTimes* times = phase_times();
 184   ReferenceType ref_type = times->processing_ref_type();
 185   times->set_ref_proc_time_ms(ref_type, elapsed);
 186 
 187   size_t after_count = _rp->total_reference_count(ref_type);
 188   size_t discovered = times->ref_discovered(ref_type);
 189   times->set_ref_cleared(ref_type, discovered - after_count);
 190 }
 191 















 192 ReferenceProcessorPhaseTimes::ReferenceProcessorPhaseTimes(GCTimer* gc_timer, uint max_gc_threads) :
 193   _gc_timer(gc_timer), _processing_is_mt(false) {
 194 
 195   for (int i = 0; i < RefParPhaseMax; i++) {
 196     _worker_time_sec[i] = new WorkerDataArray<double>(max_gc_threads, "Process lists (ms)");
 197     _par_phase_time_ms[i] = uninitialized();
 198   }
 199 
 200   for (int i = 0; i < number_of_subclasses_of_ref; i++) {
 201     _ref_proc_time_ms[i] = uninitialized();
 202     _balance_queues_time_ms[i] = uninitialized();
 203     _ref_cleared[i] = 0;
 204     _ref_discovered[i] = 0;
 205     _ref_enqueued[i] = 0;
 206   }
 207 }
 208 
 209 inline int ref_type_2_index(ReferenceType ref_type) {
 210   return ref_type - REF_SOFT;
 211 }


 333       result = (int)FinalRefPhase2;
 334       result += (phase_number - 1);
 335       assert((RefProcParPhases)result >= FinalRefPhase2 &&
 336              (RefProcParPhases)result <= FinalRefPhase3,
 337              "Invariant (%d)", result);
 338       break;
 339     case REF_PHANTOM:
 340       result = (int)PhantomRefPhase2;
 341       result += (phase_number - 1);
 342       assert((RefProcParPhases)result >= PhantomRefPhase2 &&
 343              (RefProcParPhases)result <= PhantomRefPhase3,
 344              "Invariant (%d)", result);
 345       break;
 346     default:
 347       ShouldNotReachHere();
 348   }
 349 
 350   ASSERT_PAR_PHASE(result);
 351 
 352   return (RefProcParPhases)result;











 353 }
 354 
 355 #define TIME_FORMAT "%.1lfms"
 356 
 357 void ReferenceProcessorPhaseTimes::print_all_references(uint base_indent, bool print_total) const {
 358   if (print_total) {
 359     LogTarget(Debug, gc, phases, ref) lt;
 360 
 361     if (lt.is_enabled()) {
 362       LogStream ls(lt);
 363       ls.print_cr("%s%s: " TIME_FORMAT,
 364                   Indents[base_indent], "Reference Processing", total_time_ms());
 365     }
 366   }
 367 
 368   uint next_indent = base_indent + 1;
 369   print_reference(REF_SOFT, next_indent);
 370   print_reference(REF_WEAK, next_indent);
 371   print_reference(REF_FINAL, next_indent);
 372   print_reference(REF_PHANTOM, next_indent);


< prev index next >