< prev index next >

src/share/vm/gc/shenandoah/shenandoahCollectorPolicy.cpp

Print this page




  59       res = NEW_C_HEAP_ARRAY(RegionGarbage, num, mtGC);
  60       _region_garbage_size = num;
  61     } else if (_region_garbage_size < num) {
  62       REALLOC_C_HEAP_ARRAY(RegionGarbage, _region_garbage, num, mtGC);
  63       _region_garbage_size = num;
  64     }
  65     return res;
  66   }
  67 
  68   RegionGarbage* _region_garbage;
  69   size_t _region_garbage_size;
  70 
  71   size_t _bytes_allocated_start_CM;
  72   size_t _bytes_allocated_during_CM;
  73 
  74   size_t _bytes_allocated_after_last_gc;
  75 
  76   uint _cancelled_cm_cycles_in_a_row;
  77   uint _successful_cm_cycles_in_a_row;
  78 



  79   size_t _bytes_in_cset;
  80 
  81 public:
  82 
  83   ShenandoahHeuristics();
  84   ~ShenandoahHeuristics();
  85 
  86   void record_bytes_allocated(size_t bytes);
  87   void record_bytes_reclaimed(size_t bytes);
  88   void record_bytes_start_CM(size_t bytes);
  89   void record_bytes_end_CM(size_t bytes);
  90 
  91   void record_gc_start() {
  92     // Do nothing.
  93   }
  94 
  95   void record_gc_end() {
  96     _bytes_allocated_after_last_gc = ShenandoahHeap::heap()->used();
  97   }
  98 
  99   size_t bytes_in_cset() const { return _bytes_in_cset; }
 100 
 101   virtual void print_thresholds() {
 102   }
 103 
 104   virtual bool should_start_concurrent_mark(size_t used, size_t capacity) const=0;
 105 
 106   virtual bool update_refs_early() const {
 107     return ShenandoahUpdateRefsEarly;
 108   }
 109 
 110   virtual bool should_start_partial_gc() {
 111     return false;
 112   }
 113 
 114   virtual bool handover_cancelled_marking() {
 115     return _cancelled_cm_cycles_in_a_row <= ShenandoahFullGCThreshold;
 116   }
 117 




 118   virtual void record_cm_cancelled() {
 119     _cancelled_cm_cycles_in_a_row++;
 120     _successful_cm_cycles_in_a_row = 0;
 121   }
 122 
 123   virtual void record_cm_success() {
 124     _cancelled_cm_cycles_in_a_row = 0;
 125     _successful_cm_cycles_in_a_row++;
 126   }
 127 










 128   virtual void record_full_gc() {
 129     _bytes_in_cset = 0;
 130   }
 131 
 132   virtual void start_choose_collection_set() {
 133   }
 134   virtual void end_choose_collection_set() {
 135   }
 136   virtual bool region_in_collection_set(ShenandoahHeapRegion* r, size_t immediate_garbage) = 0;
 137 
 138   virtual void choose_collection_set(ShenandoahCollectionSet* collection_set, int* connections=NULL);
 139   virtual void choose_free_set(ShenandoahFreeSet* free_set);
 140 
 141   virtual bool process_references() {
 142     if (ShenandoahRefProcFrequency == 0) return false;
 143     size_t cycle = ShenandoahHeap::heap()->shenandoahPolicy()->cycle_counter();
 144     // Process references every Nth GC cycle.
 145     return cycle % ShenandoahRefProcFrequency == 0;
 146   }
 147 


 153     // Offsetting by one is enough to break the rendezvous when periods are equal.
 154     // When periods are not equal, offsetting by one is just as good as any other guess.
 155     return (cycle + 1) % ShenandoahUnloadClassesFrequency == 0;
 156   }
 157 
 158   virtual bool needs_regions_sorted_by_garbage() {
 159     // Most of them do not.
 160     return false;
 161   }
 162 };
 163 
 164 ShenandoahHeuristics::ShenandoahHeuristics() :
 165   _bytes_allocated_since_CM(0),
 166   _bytes_reclaimed_this_cycle(0),
 167   _bytes_allocated_start_CM(0),
 168   _bytes_allocated_during_CM(0),
 169   _bytes_allocated_after_last_gc(0),
 170   _bytes_in_cset(0),
 171   _cancelled_cm_cycles_in_a_row(0),
 172   _successful_cm_cycles_in_a_row(0),


 173   _region_garbage(NULL),
 174   _region_garbage_size(0)
 175 {
 176 }
 177 
 178 ShenandoahHeuristics::~ShenandoahHeuristics() {
 179   if (_region_garbage != NULL) {
 180     FREE_C_HEAP_ARRAY(RegionGarbage, _region_garbage);
 181   }
 182 }
 183 
 184 void ShenandoahHeuristics::choose_collection_set(ShenandoahCollectionSet* collection_set, int* connections) {
 185   start_choose_collection_set();
 186 
 187   ShenandoahHeap* heap = ShenandoahHeap::heap();
 188 
 189   // Poll this before populating collection set.
 190   size_t total_garbage = heap->garbage();
 191 
 192   // Step 1. Build up the region candidates we care about, rejecting losers and accepting winners right away.


 453 
 454 public:
 455   AdaptiveHeuristics() :
 456     ShenandoahHeuristics(),
 457     _free_threshold(ShenandoahInitFreeThreshold),
 458     _cset_history(new TruncatedSeq((uint)ShenandoahHappyCyclesThreshold)) {
 459 
 460     _cset_history->add((double) ShenandoahCSetThreshold);
 461     _cset_history->add((double) ShenandoahCSetThreshold);
 462   }
 463 
 464   virtual ~AdaptiveHeuristics() {
 465     delete _cset_history;
 466   }
 467 
 468   virtual bool region_in_collection_set(ShenandoahHeapRegion* r, size_t immediate_garbage) {
 469     size_t threshold = ShenandoahHeapRegion::region_size_bytes() * ShenandoahGarbageThreshold / 100;
 470     return r->garbage() > threshold;
 471   }
 472 
 473   virtual void record_cm_cancelled() {
 474     ShenandoahHeuristics::record_cm_cancelled();








 475     if (_free_threshold < ShenandoahMaxFreeThreshold) {
 476       _free_threshold++;
 477       log_info(gc,ergo)("increasing free threshold to: "UINTX_FORMAT, _free_threshold);
 478     }
 479   }
 480 





 481   virtual void record_cm_success() {
 482     ShenandoahHeuristics::record_cm_success();
 483     if (_successful_cm_cycles_in_a_row > ShenandoahHappyCyclesThreshold &&
 484         _free_threshold > ShenandoahMinFreeThreshold) {
 485       _free_threshold--;
 486       log_info(gc,ergo)("reducing free threshold to: "UINTX_FORMAT, _free_threshold);
 487       _successful_cm_cycles_in_a_row = 0;
 488     }














 489   }
 490 

 491   virtual bool should_start_concurrent_mark(size_t used, size_t capacity) const {
 492     bool shouldStartConcurrentMark = false;
 493 
 494     ShenandoahHeap* heap = ShenandoahHeap::heap();
 495     size_t free_capacity = heap->free_regions()->capacity();
 496     size_t free_used = heap->free_regions()->used();
 497     assert(free_used <= free_capacity, "must use less than capacity");
 498     size_t available =  free_capacity - free_used;
 499     uintx factor = _free_threshold;
 500     size_t cset_threshold = 0;
 501     if (!update_refs_early()) {
 502       // Count in the memory available after cset reclamation.
 503       cset_threshold = (size_t) _cset_history->davg();
 504       size_t cset = MIN2(_bytes_in_cset, (cset_threshold * capacity) / 100);
 505       available += cset;
 506       factor += cset_threshold;
 507     }
 508 
 509     size_t targetStartMarking = (capacity * factor) / 100;
 510 


 705   }
 706 
 707   virtual ~PartialHeuristics() {}
 708 
 709   bool update_refs_early() const {
 710     return true;
 711   }
 712 
 713   bool should_start_partial_gc() {
 714     ShenandoahHeap* heap = ShenandoahHeap::heap();
 715     size_t capacity = heap->capacity();
 716 
 717     size_t used = heap->used();
 718     return (used - _bytes_allocated_after_last_gc) * 100 / capacity > ShenandoahAllocationThreshold;
 719   }
 720 };
 721 
 722 ShenandoahCollectorPolicy::ShenandoahCollectorPolicy() :
 723   _cycle_counter(0),
 724   _successful_cm(0),
 725   _degenerated_cm(0)


 726 {
 727 
 728   ShenandoahHeapRegion::setup_heap_region_size(initial_heap_byte_size(), max_heap_byte_size());
 729 
 730   initialize_all();
 731 
 732   _tracer = new (ResourceObj::C_HEAP, mtGC) ShenandoahTracer();
 733   _stw_timer = new (ResourceObj::C_HEAP, mtGC) STWGCTimer();
 734   _conc_timer = new (ResourceObj::C_HEAP, mtGC) ConcurrentGCTimer();
 735   _user_requested_gcs = 0;
 736   _allocation_failure_gcs = 0;
 737   _conc_gc_aborted = false;
 738 
 739   _phase_names[total_pause]                     = "Total Pauses (N)";
 740   _phase_names[total_pause_gross]               = "Total Pauses (G)";
 741   _phase_names[init_mark]                       = "Initial Mark Pauses (N)";
 742   _phase_names[init_mark_gross]                 = "Initial Mark Pauses (G)";
 743   _phase_names[final_mark]                      = "Final Mark Pauses (N)";
 744   _phase_names[final_mark_gross]                = "Final Mark Pauses (G)";
 745   _phase_names[accumulate_stats]                = "  Accumulate Stats";


 930   _heuristics->record_bytes_reclaimed(bytes);
 931 }
 932 
 933 void ShenandoahCollectorPolicy::record_user_requested_gc() {
 934   _user_requested_gcs++;
 935 }
 936 
 937 void ShenandoahCollectorPolicy::record_allocation_failure_gc() {
 938   _allocation_failure_gcs++;
 939 }
 940 
 941 bool ShenandoahCollectorPolicy::should_start_concurrent_mark(size_t used,
 942                                                              size_t capacity) {
 943   return _heuristics->should_start_concurrent_mark(used, capacity);
 944 }
 945 
 946 bool ShenandoahCollectorPolicy::handover_cancelled_marking() {
 947   return _heuristics->handover_cancelled_marking();
 948 }
 949 




 950 bool ShenandoahCollectorPolicy::update_refs_early() {
 951   return _heuristics->update_refs_early();
 952 }
 953 
 954 void ShenandoahCollectorPolicy::record_cm_success() {
 955   _heuristics->record_cm_success();
 956   _successful_cm++;
 957 }
 958 
 959 void ShenandoahCollectorPolicy::record_cm_degenerated() {
 960   _degenerated_cm++;
 961 }
 962 
 963 void ShenandoahCollectorPolicy::record_cm_cancelled() {
 964   _heuristics->record_cm_cancelled();
 965 }
 966 













 967 void ShenandoahCollectorPolicy::record_full_gc() {
 968   _heuristics->record_full_gc();
 969 }
 970 
 971 void ShenandoahCollectorPolicy::choose_collection_set(ShenandoahCollectionSet* collection_set, int* connections) {
 972   _heuristics->choose_collection_set(collection_set, connections);
 973 }
 974 
 975 void ShenandoahCollectorPolicy::choose_free_set(ShenandoahFreeSet* free_set) {
 976    _heuristics->choose_free_set(free_set);
 977 }
 978 
 979 
 980 bool ShenandoahCollectorPolicy::process_references() {
 981   return _heuristics->process_references();
 982 }
 983 
 984 bool ShenandoahCollectorPolicy::unload_classes() {
 985   return _heuristics->unload_classes();
 986 }
 987 
 988 void ShenandoahCollectorPolicy::print_tracing_info(outputStream* out) {
 989   out->cr();
 990   out->print_cr("GC STATISTICS:");
 991   out->print_cr("  \"(G)\" (gross) pauses include time to safepoint. \"(N)\" (net) pauses are times spent in GC.");
 992   out->print_cr("  \"a\" is average time for each phase, look at levels to see if average makes sense.");
 993   out->print_cr("  \"lvls\" are quantiles: 0%% (minimum), 25%%, 50%% (median), 75%%, 100%% (maximum).");
 994   out->cr();
 995 
 996   for (uint i = 0; i < _num_phases; i++) {
 997     if (_timing_data[i]._secs.maximum() != 0) {
 998       print_summary_sd(out, _phase_names[i], &(_timing_data[i]._secs));
 999     }
1000   }
1001 
1002   out->cr();
1003   out->print_cr("" SIZE_FORMAT " allocation failure and " SIZE_FORMAT " user requested GCs", _allocation_failure_gcs, _user_requested_gcs);
1004   out->print_cr("" SIZE_FORMAT " successful and " SIZE_FORMAT " degenerated concurrent markings", _successful_cm, _degenerated_cm);

1005   out->cr();
1006 }
1007 
1008 void ShenandoahCollectorPolicy::print_summary_sd(outputStream* out, const char* str, const HdrSeq* seq)  {
1009   out->print_cr("%-27s = %8.2lf s (a = %8.0lf us) (n = "INT32_FORMAT_W(5)") (lvls, us = %8.0lf, %8.0lf, %8.0lf, %8.0lf, %8.0lf)",
1010           str,
1011           seq->sum(),
1012           seq->avg() * 1000000.0,
1013           seq->num(),
1014           seq->percentile(0)  * 1000000.0,
1015           seq->percentile(25) * 1000000.0,
1016           seq->percentile(50) * 1000000.0,
1017           seq->percentile(75) * 1000000.0,
1018           seq->maximum() * 1000000.0
1019   );
1020 }
1021 
1022 void ShenandoahCollectorPolicy::increase_cycle_counter() {
1023   _cycle_counter++;
1024 }




  59       res = NEW_C_HEAP_ARRAY(RegionGarbage, num, mtGC);
  60       _region_garbage_size = num;
  61     } else if (_region_garbage_size < num) {
  62       REALLOC_C_HEAP_ARRAY(RegionGarbage, _region_garbage, num, mtGC);
  63       _region_garbage_size = num;
  64     }
  65     return res;
  66   }
  67 
  68   RegionGarbage* _region_garbage;
  69   size_t _region_garbage_size;
  70 
  71   size_t _bytes_allocated_start_CM;
  72   size_t _bytes_allocated_during_CM;
  73 
  74   size_t _bytes_allocated_after_last_gc;
  75 
  76   uint _cancelled_cm_cycles_in_a_row;
  77   uint _successful_cm_cycles_in_a_row;
  78 
  79   uint _cancelled_uprefs_cycles_in_a_row;
  80   uint _successful_uprefs_cycles_in_a_row;
  81 
  82   size_t _bytes_in_cset;
  83 
  84 public:
  85 
  86   ShenandoahHeuristics();
  87   ~ShenandoahHeuristics();
  88 
  89   void record_bytes_allocated(size_t bytes);
  90   void record_bytes_reclaimed(size_t bytes);
  91   void record_bytes_start_CM(size_t bytes);
  92   void record_bytes_end_CM(size_t bytes);
  93 
  94   void record_gc_start() {
  95     // Do nothing.
  96   }
  97 
  98   void record_gc_end() {
  99     _bytes_allocated_after_last_gc = ShenandoahHeap::heap()->used();
 100   }
 101 
 102   size_t bytes_in_cset() const { return _bytes_in_cset; }
 103 
 104   virtual void print_thresholds() {
 105   }
 106 
 107   virtual bool should_start_concurrent_mark(size_t used, size_t capacity) const=0;
 108 
 109   virtual bool update_refs_early() const {
 110     return ShenandoahUpdateRefsEarly;
 111   }
 112 
 113   virtual bool should_start_partial_gc() {
 114     return false;
 115   }
 116 
 117   virtual bool handover_cancelled_marking() {
 118     return _cancelled_cm_cycles_in_a_row <= ShenandoahFullGCThreshold;
 119   }
 120 
 121   virtual bool handover_cancelled_uprefs() {
 122     return _cancelled_uprefs_cycles_in_a_row <= ShenandoahFullGCThreshold;
 123   }
 124 
 125   virtual void record_cm_cancelled() {
 126     _cancelled_cm_cycles_in_a_row++;
 127     _successful_cm_cycles_in_a_row = 0;
 128   }
 129 
 130   virtual void record_cm_success() {
 131     _cancelled_cm_cycles_in_a_row = 0;
 132     _successful_cm_cycles_in_a_row++;
 133   }
 134 
 135   virtual void record_uprefs_cancelled() {
 136     _cancelled_uprefs_cycles_in_a_row++;
 137     _successful_uprefs_cycles_in_a_row = 0;
 138   }
 139 
 140   virtual void record_uprefs_success() {
 141     _cancelled_uprefs_cycles_in_a_row = 0;
 142     _successful_uprefs_cycles_in_a_row++;
 143   }
 144 
 145   virtual void record_full_gc() {
 146     _bytes_in_cset = 0;
 147   }
 148 
 149   virtual void start_choose_collection_set() {
 150   }
 151   virtual void end_choose_collection_set() {
 152   }
 153   virtual bool region_in_collection_set(ShenandoahHeapRegion* r, size_t immediate_garbage) = 0;
 154 
 155   virtual void choose_collection_set(ShenandoahCollectionSet* collection_set, int* connections=NULL);
 156   virtual void choose_free_set(ShenandoahFreeSet* free_set);
 157 
 158   virtual bool process_references() {
 159     if (ShenandoahRefProcFrequency == 0) return false;
 160     size_t cycle = ShenandoahHeap::heap()->shenandoahPolicy()->cycle_counter();
 161     // Process references every Nth GC cycle.
 162     return cycle % ShenandoahRefProcFrequency == 0;
 163   }
 164 


 170     // Offsetting by one is enough to break the rendezvous when periods are equal.
 171     // When periods are not equal, offsetting by one is just as good as any other guess.
 172     return (cycle + 1) % ShenandoahUnloadClassesFrequency == 0;
 173   }
 174 
 175   virtual bool needs_regions_sorted_by_garbage() {
 176     // Most of them do not.
 177     return false;
 178   }
 179 };
 180 
 181 ShenandoahHeuristics::ShenandoahHeuristics() :
 182   _bytes_allocated_since_CM(0),
 183   _bytes_reclaimed_this_cycle(0),
 184   _bytes_allocated_start_CM(0),
 185   _bytes_allocated_during_CM(0),
 186   _bytes_allocated_after_last_gc(0),
 187   _bytes_in_cset(0),
 188   _cancelled_cm_cycles_in_a_row(0),
 189   _successful_cm_cycles_in_a_row(0),
 190   _cancelled_uprefs_cycles_in_a_row(0),
 191   _successful_uprefs_cycles_in_a_row(0),
 192   _region_garbage(NULL),
 193   _region_garbage_size(0)
 194 {
 195 }
 196 
 197 ShenandoahHeuristics::~ShenandoahHeuristics() {
 198   if (_region_garbage != NULL) {
 199     FREE_C_HEAP_ARRAY(RegionGarbage, _region_garbage);
 200   }
 201 }
 202 
 203 void ShenandoahHeuristics::choose_collection_set(ShenandoahCollectionSet* collection_set, int* connections) {
 204   start_choose_collection_set();
 205 
 206   ShenandoahHeap* heap = ShenandoahHeap::heap();
 207 
 208   // Poll this before populating collection set.
 209   size_t total_garbage = heap->garbage();
 210 
 211   // Step 1. Build up the region candidates we care about, rejecting losers and accepting winners right away.


 472 
 473 public:
 474   AdaptiveHeuristics() :
 475     ShenandoahHeuristics(),
 476     _free_threshold(ShenandoahInitFreeThreshold),
 477     _cset_history(new TruncatedSeq((uint)ShenandoahHappyCyclesThreshold)) {
 478 
 479     _cset_history->add((double) ShenandoahCSetThreshold);
 480     _cset_history->add((double) ShenandoahCSetThreshold);
 481   }
 482 
 483   virtual ~AdaptiveHeuristics() {
 484     delete _cset_history;
 485   }
 486 
 487   virtual bool region_in_collection_set(ShenandoahHeapRegion* r, size_t immediate_garbage) {
 488     size_t threshold = ShenandoahHeapRegion::region_size_bytes() * ShenandoahGarbageThreshold / 100;
 489     return r->garbage() > threshold;
 490   }
 491 
 492   void optimize_free_threshold(uint successful_cycles) {
 493     if (successful_cycles > ShenandoahHappyCyclesThreshold &&
 494         _free_threshold > ShenandoahMinFreeThreshold) {
 495       _free_threshold--;
 496       log_info(gc,ergo)("reducing free threshold to: "UINTX_FORMAT, _free_threshold);
 497       _successful_cm_cycles_in_a_row = 0;
 498     }
 499   }
 500 
 501   void pessimize_free_threshold() {
 502     if (_free_threshold < ShenandoahMaxFreeThreshold) {
 503       _free_threshold++;
 504       log_info(gc,ergo)("increasing free threshold to: "UINTX_FORMAT, _free_threshold);
 505     }
 506   }
 507 
 508   virtual void record_cm_cancelled() {
 509     ShenandoahHeuristics::record_cm_cancelled();
 510     pessimize_free_threshold();
 511   }
 512 
 513   virtual void record_cm_success() {
 514     ShenandoahHeuristics::record_cm_success();
 515     if (update_refs_early()) {
 516       optimize_free_threshold(_successful_cm_cycles_in_a_row);
 517     }


 518   }
 519 
 520   virtual void record_uprefs_cancelled() {
 521     ShenandoahHeuristics::record_uprefs_cancelled();
 522     pessimize_free_threshold();
 523   }
 524 
 525   virtual void record_uprefs_success() {
 526     ShenandoahHeuristics::record_uprefs_success();
 527     optimize_free_threshold(_successful_uprefs_cycles_in_a_row);
 528   }
 529 
 530   virtual void record_full_gc() {
 531     ShenandoahHeuristics::record_full_gc();
 532     pessimize_free_threshold();
 533   }
 534 
 535 
 536   virtual bool should_start_concurrent_mark(size_t used, size_t capacity) const {
 537     bool shouldStartConcurrentMark = false;
 538 
 539     ShenandoahHeap* heap = ShenandoahHeap::heap();
 540     size_t free_capacity = heap->free_regions()->capacity();
 541     size_t free_used = heap->free_regions()->used();
 542     assert(free_used <= free_capacity, "must use less than capacity");
 543     size_t available =  free_capacity - free_used;
 544     uintx factor = _free_threshold;
 545     size_t cset_threshold = 0;
 546     if (!update_refs_early()) {
 547       // Count in the memory available after cset reclamation.
 548       cset_threshold = (size_t) _cset_history->davg();
 549       size_t cset = MIN2(_bytes_in_cset, (cset_threshold * capacity) / 100);
 550       available += cset;
 551       factor += cset_threshold;
 552     }
 553 
 554     size_t targetStartMarking = (capacity * factor) / 100;
 555 


 750   }
 751 
 752   virtual ~PartialHeuristics() {}
 753 
 754   bool update_refs_early() const {
 755     return true;
 756   }
 757 
 758   bool should_start_partial_gc() {
 759     ShenandoahHeap* heap = ShenandoahHeap::heap();
 760     size_t capacity = heap->capacity();
 761 
 762     size_t used = heap->used();
 763     return (used - _bytes_allocated_after_last_gc) * 100 / capacity > ShenandoahAllocationThreshold;
 764   }
 765 };
 766 
 767 ShenandoahCollectorPolicy::ShenandoahCollectorPolicy() :
 768   _cycle_counter(0),
 769   _successful_cm(0),
 770   _degenerated_cm(0),
 771   _successful_uprefs(0),
 772   _degenerated_uprefs(0)
 773 {
 774 
 775   ShenandoahHeapRegion::setup_heap_region_size(initial_heap_byte_size(), max_heap_byte_size());
 776 
 777   initialize_all();
 778 
 779   _tracer = new (ResourceObj::C_HEAP, mtGC) ShenandoahTracer();
 780   _stw_timer = new (ResourceObj::C_HEAP, mtGC) STWGCTimer();
 781   _conc_timer = new (ResourceObj::C_HEAP, mtGC) ConcurrentGCTimer();
 782   _user_requested_gcs = 0;
 783   _allocation_failure_gcs = 0;
 784   _conc_gc_aborted = false;
 785 
 786   _phase_names[total_pause]                     = "Total Pauses (N)";
 787   _phase_names[total_pause_gross]               = "Total Pauses (G)";
 788   _phase_names[init_mark]                       = "Initial Mark Pauses (N)";
 789   _phase_names[init_mark_gross]                 = "Initial Mark Pauses (G)";
 790   _phase_names[final_mark]                      = "Final Mark Pauses (N)";
 791   _phase_names[final_mark_gross]                = "Final Mark Pauses (G)";
 792   _phase_names[accumulate_stats]                = "  Accumulate Stats";


 977   _heuristics->record_bytes_reclaimed(bytes);
 978 }
 979 
 980 void ShenandoahCollectorPolicy::record_user_requested_gc() {
 981   _user_requested_gcs++;
 982 }
 983 
 984 void ShenandoahCollectorPolicy::record_allocation_failure_gc() {
 985   _allocation_failure_gcs++;
 986 }
 987 
 988 bool ShenandoahCollectorPolicy::should_start_concurrent_mark(size_t used,
 989                                                              size_t capacity) {
 990   return _heuristics->should_start_concurrent_mark(used, capacity);
 991 }
 992 
 993 bool ShenandoahCollectorPolicy::handover_cancelled_marking() {
 994   return _heuristics->handover_cancelled_marking();
 995 }
 996 
 997 bool ShenandoahCollectorPolicy::handover_cancelled_uprefs() {
 998   return _heuristics->handover_cancelled_uprefs();
 999 }
1000 
1001 bool ShenandoahCollectorPolicy::update_refs_early() {
1002   return _heuristics->update_refs_early();
1003 }
1004 
1005 void ShenandoahCollectorPolicy::record_cm_success() {
1006   _heuristics->record_cm_success();
1007   _successful_cm++;
1008 }
1009 
1010 void ShenandoahCollectorPolicy::record_cm_degenerated() {
1011   _degenerated_cm++;
1012 }
1013 
1014 void ShenandoahCollectorPolicy::record_cm_cancelled() {
1015   _heuristics->record_cm_cancelled();
1016 }
1017 
1018 void ShenandoahCollectorPolicy::record_uprefs_success() {
1019   _heuristics->record_uprefs_success();
1020   _successful_uprefs++;
1021 }
1022 
1023 void ShenandoahCollectorPolicy::record_uprefs_degenerated() {
1024   _degenerated_uprefs++;
1025 }
1026 
1027 void ShenandoahCollectorPolicy::record_uprefs_cancelled() {
1028   _heuristics->record_uprefs_cancelled();
1029 }
1030 
1031 void ShenandoahCollectorPolicy::record_full_gc() {
1032   _heuristics->record_full_gc();
1033 }
1034 
1035 void ShenandoahCollectorPolicy::choose_collection_set(ShenandoahCollectionSet* collection_set, int* connections) {
1036   _heuristics->choose_collection_set(collection_set, connections);
1037 }
1038 
1039 void ShenandoahCollectorPolicy::choose_free_set(ShenandoahFreeSet* free_set) {
1040    _heuristics->choose_free_set(free_set);
1041 }
1042 
1043 
1044 bool ShenandoahCollectorPolicy::process_references() {
1045   return _heuristics->process_references();
1046 }
1047 
1048 bool ShenandoahCollectorPolicy::unload_classes() {
1049   return _heuristics->unload_classes();
1050 }
1051 
1052 void ShenandoahCollectorPolicy::print_tracing_info(outputStream* out) {
1053   out->cr();
1054   out->print_cr("GC STATISTICS:");
1055   out->print_cr("  \"(G)\" (gross) pauses include time to safepoint. \"(N)\" (net) pauses are times spent in GC.");
1056   out->print_cr("  \"a\" is average time for each phase, look at levels to see if average makes sense.");
1057   out->print_cr("  \"lvls\" are quantiles: 0%% (minimum), 25%%, 50%% (median), 75%%, 100%% (maximum).");
1058   out->cr();
1059 
1060   for (uint i = 0; i < _num_phases; i++) {
1061     if (_timing_data[i]._secs.maximum() != 0) {
1062       print_summary_sd(out, _phase_names[i], &(_timing_data[i]._secs));
1063     }
1064   }
1065 
1066   out->cr();
1067   out->print_cr("" SIZE_FORMAT " allocation failure and " SIZE_FORMAT " user requested GCs", _allocation_failure_gcs, _user_requested_gcs);
1068   out->print_cr("" SIZE_FORMAT " successful and " SIZE_FORMAT " degenerated concurrent markings", _successful_cm, _degenerated_cm);
1069   out->print_cr("" SIZE_FORMAT " successful and " SIZE_FORMAT " degenerated update references  ", _successful_uprefs, _degenerated_uprefs);
1070   out->cr();
1071 }
1072 
1073 void ShenandoahCollectorPolicy::print_summary_sd(outputStream* out, const char* str, const HdrSeq* seq)  {
1074   out->print_cr("%-27s = %8.2lf s (a = %8.0lf us) (n = "INT32_FORMAT_W(5)") (lvls, us = %8.0lf, %8.0lf, %8.0lf, %8.0lf, %8.0lf)",
1075           str,
1076           seq->sum(),
1077           seq->avg() * 1000000.0,
1078           seq->num(),
1079           seq->percentile(0)  * 1000000.0,
1080           seq->percentile(25) * 1000000.0,
1081           seq->percentile(50) * 1000000.0,
1082           seq->percentile(75) * 1000000.0,
1083           seq->maximum() * 1000000.0
1084   );
1085 }
1086 
1087 void ShenandoahCollectorPolicy::increase_cycle_counter() {
1088   _cycle_counter++;
1089 }


< prev index next >