< prev index next >

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

Print this page

  1 /*
  2  * Copyright (c) 2013, 2021, Red Hat, Inc. All rights reserved.

  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.
  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #include "precompiled.hpp"
 26 
 27 #include "gc/shenandoah/shenandoahCollectorPolicy.hpp"
 28 #include "gc/shenandoah/shenandoahGC.hpp"
 29 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
 30 #include "runtime/os.hpp"
 31 
 32 ShenandoahCollectorPolicy::ShenandoahCollectorPolicy() :
 33   _success_concurrent_gcs(0),





 34   _success_degenerated_gcs(0),
 35   _success_full_gcs(0),


 36   _alloc_failure_degenerated(0),
 37   _alloc_failure_degenerated_upgrade_to_full(0),
 38   _alloc_failure_full(0),
 39   _explicit_concurrent(0),
 40   _explicit_full(0),
 41   _implicit_concurrent(0),
 42   _implicit_full(0),
 43   _cycle_counter(0) {
 44 
 45   Copy::zero_to_bytes(_degen_points, sizeof(size_t) * ShenandoahGC::_DEGENERATED_LIMIT);
 46 
 47   _tracer = new ShenandoahTracer();
 48 
 49 }
 50 
 51 void ShenandoahCollectorPolicy::record_explicit_to_concurrent() {
 52   _explicit_concurrent++;
 53 }
 54 
 55 void ShenandoahCollectorPolicy::record_explicit_to_full() {

 58 
 59 void ShenandoahCollectorPolicy::record_implicit_to_concurrent() {
 60   _implicit_concurrent++;
 61 }
 62 
 63 void ShenandoahCollectorPolicy::record_implicit_to_full() {
 64   _implicit_full++;
 65 }
 66 
 67 void ShenandoahCollectorPolicy::record_alloc_failure_to_full() {
 68   _alloc_failure_full++;
 69 }
 70 
 71 void ShenandoahCollectorPolicy::record_alloc_failure_to_degenerated(ShenandoahGC::ShenandoahDegenPoint point) {
 72   assert(point < ShenandoahGC::_DEGENERATED_LIMIT, "sanity");
 73   _alloc_failure_degenerated++;
 74   _degen_points[point]++;
 75 }
 76 
 77 void ShenandoahCollectorPolicy::record_degenerated_upgrade_to_full() {

 78   _alloc_failure_degenerated_upgrade_to_full++;
 79 }
 80 
 81 void ShenandoahCollectorPolicy::record_success_concurrent() {



 82   _success_concurrent_gcs++;

















 83 }
 84 
 85 void ShenandoahCollectorPolicy::record_success_degenerated() {


 86   _success_degenerated_gcs++;












 87 }
 88 
 89 void ShenandoahCollectorPolicy::record_success_full() {


 90   _success_full_gcs++;
 91 }
 92 
 93 size_t ShenandoahCollectorPolicy::cycle_counter() const {
 94   return _cycle_counter;
 95 }
 96 
 97 void ShenandoahCollectorPolicy::record_cycle_start() {
 98   _cycle_counter++;
 99 }
100 
101 void ShenandoahCollectorPolicy::record_shutdown() {
102   _in_shutdown.set();
103 }
104 
105 bool ShenandoahCollectorPolicy::is_at_shutdown() {
106   return _in_shutdown.is_set();
107 }
108 
109 void ShenandoahCollectorPolicy::print_gc_stats(outputStream* out) const {
110   out->print_cr("Under allocation pressure, concurrent cycles may cancel, and either continue cycle");
111   out->print_cr("under stop-the-world pause or result in stop-the-world Full GC. Increase heap size,");
112   out->print_cr("tune GC heuristics, set more aggressive pacing delay, or lower allocation rate");
113   out->print_cr("to avoid Degenerated and Full GC cycles.");

114   out->cr();
115 
116   out->print_cr(SIZE_FORMAT_W(5) " successful concurrent GCs",         _success_concurrent_gcs);
117   out->print_cr("  " SIZE_FORMAT_W(5) " invoked explicitly",           _explicit_concurrent);
118   out->print_cr("  " SIZE_FORMAT_W(5) " invoked implicitly",           _implicit_concurrent);



119   out->cr();
120 
121   out->print_cr(SIZE_FORMAT_W(5) " Degenerated GCs",                   _success_degenerated_gcs);
122   out->print_cr("  " SIZE_FORMAT_W(5) " caused by allocation failure", _alloc_failure_degenerated);










123   for (int c = 0; c < ShenandoahGC::_DEGENERATED_LIMIT; c++) {
124     if (_degen_points[c] > 0) {
125       const char* desc = ShenandoahGC::degen_point_to_string((ShenandoahGC::ShenandoahDegenPoint)c);
126       out->print_cr("    " SIZE_FORMAT_W(5) " happened at %s",         _degen_points[c], desc);
127     }
128   }
129   out->print_cr("  " SIZE_FORMAT_W(5) " upgraded to Full GC",          _alloc_failure_degenerated_upgrade_to_full);
130   out->cr();
131 
132   out->print_cr(SIZE_FORMAT_W(5) " Full GCs",                          _success_full_gcs + _alloc_failure_degenerated_upgrade_to_full);
133   out->print_cr("  " SIZE_FORMAT_W(5) " invoked explicitly",           _explicit_full);
134   out->print_cr("  " SIZE_FORMAT_W(5) " invoked implicitly",           _implicit_full);
135   out->print_cr("  " SIZE_FORMAT_W(5) " caused by allocation failure", _alloc_failure_full);
136   out->print_cr("  " SIZE_FORMAT_W(5) " upgraded from Degenerated GC", _alloc_failure_degenerated_upgrade_to_full);
137 }

  1 /*
  2  * Copyright (c) 2013, 2021, Red Hat, Inc. All rights reserved.
  3  * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
  4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  5  *
  6  * This code is free software; you can redistribute it and/or modify it
  7  * under the terms of the GNU General Public License version 2 only, as
  8  * published by the Free Software Foundation.
  9  *
 10  * This code is distributed in the hope that it will be useful, but WITHOUT
 11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 13  * version 2 for more details (a copy is included in the LICENSE file that
 14  * accompanied this code).
 15  *
 16  * You should have received a copy of the GNU General Public License version
 17  * 2 along with this work; if not, write to the Free Software Foundation,
 18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 19  *
 20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 21  * or visit www.oracle.com if you need additional information or have any
 22  * questions.
 23  *
 24  */
 25 
 26 #include "precompiled.hpp"
 27 
 28 #include "gc/shenandoah/shenandoahCollectorPolicy.hpp"
 29 #include "gc/shenandoah/shenandoahGC.hpp"
 30 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
 31 #include "runtime/os.hpp"
 32 
 33 ShenandoahCollectorPolicy::ShenandoahCollectorPolicy() :
 34   _success_concurrent_gcs(0),
 35   _mixed_gcs(0),
 36   _abbreviated_concurrent_gcs(0),
 37   _abbreviated_degenerated_gcs(0),
 38   _success_old_gcs(0),
 39   _interrupted_old_gcs(0),
 40   _success_degenerated_gcs(0),
 41   _success_full_gcs(0),
 42   _consecutive_young_gcs(0),
 43   _consecutive_degenerated_gcs(0),
 44   _alloc_failure_degenerated(0),
 45   _alloc_failure_degenerated_upgrade_to_full(0),
 46   _alloc_failure_full(0),
 47   _explicit_concurrent(0),
 48   _explicit_full(0),
 49   _implicit_concurrent(0),
 50   _implicit_full(0),
 51   _cycle_counter(0) {
 52 
 53   Copy::zero_to_bytes(_degen_points, sizeof(size_t) * ShenandoahGC::_DEGENERATED_LIMIT);
 54 
 55   _tracer = new ShenandoahTracer();
 56 
 57 }
 58 
 59 void ShenandoahCollectorPolicy::record_explicit_to_concurrent() {
 60   _explicit_concurrent++;
 61 }
 62 
 63 void ShenandoahCollectorPolicy::record_explicit_to_full() {

 66 
 67 void ShenandoahCollectorPolicy::record_implicit_to_concurrent() {
 68   _implicit_concurrent++;
 69 }
 70 
 71 void ShenandoahCollectorPolicy::record_implicit_to_full() {
 72   _implicit_full++;
 73 }
 74 
 75 void ShenandoahCollectorPolicy::record_alloc_failure_to_full() {
 76   _alloc_failure_full++;
 77 }
 78 
 79 void ShenandoahCollectorPolicy::record_alloc_failure_to_degenerated(ShenandoahGC::ShenandoahDegenPoint point) {
 80   assert(point < ShenandoahGC::_DEGENERATED_LIMIT, "sanity");
 81   _alloc_failure_degenerated++;
 82   _degen_points[point]++;
 83 }
 84 
 85 void ShenandoahCollectorPolicy::record_degenerated_upgrade_to_full() {
 86   _consecutive_degenerated_gcs = 0;
 87   _alloc_failure_degenerated_upgrade_to_full++;
 88 }
 89 
 90 void ShenandoahCollectorPolicy::record_success_concurrent(bool is_young, bool is_abbreviated) {
 91   update_young(is_young);
 92 
 93   _consecutive_degenerated_gcs = 0;
 94   _success_concurrent_gcs++;
 95   if (is_abbreviated) {
 96     _abbreviated_concurrent_gcs++;
 97   }
 98 }
 99 
100 void ShenandoahCollectorPolicy::record_mixed_cycle() {
101   _mixed_gcs++;
102 }
103 
104 void ShenandoahCollectorPolicy::record_success_old() {
105   _consecutive_young_gcs = 0;
106   _success_old_gcs++;
107 }
108 
109 void ShenandoahCollectorPolicy::record_interrupted_old() {
110   _consecutive_young_gcs = 0;
111   _interrupted_old_gcs++;
112 }
113 
114 void ShenandoahCollectorPolicy::record_success_degenerated(bool is_young, bool is_abbreviated) {
115   update_young(is_young);
116 
117   _success_degenerated_gcs++;
118   _consecutive_degenerated_gcs++;
119   if (is_abbreviated) {
120     _abbreviated_degenerated_gcs++;
121   }
122 }
123 
124 void ShenandoahCollectorPolicy::update_young(bool is_young) {
125   if (is_young) {
126     _consecutive_young_gcs++;
127   } else {
128     _consecutive_young_gcs = 0;
129   }
130 }
131 
132 void ShenandoahCollectorPolicy::record_success_full() {
133   _consecutive_degenerated_gcs = 0;
134   _consecutive_young_gcs = 0;
135   _success_full_gcs++;
136 }
137 
138 size_t ShenandoahCollectorPolicy::cycle_counter() const {
139   return _cycle_counter;
140 }
141 
142 void ShenandoahCollectorPolicy::record_cycle_start() {
143   _cycle_counter++;
144 }
145 
146 void ShenandoahCollectorPolicy::record_shutdown() {
147   _in_shutdown.set();
148 }
149 
150 bool ShenandoahCollectorPolicy::is_at_shutdown() {
151   return _in_shutdown.is_set();
152 }
153 
154 void ShenandoahCollectorPolicy::print_gc_stats(outputStream* out) const {
155   out->print_cr("Under allocation pressure, concurrent cycles may cancel, and either continue cycle");
156   out->print_cr("under stop-the-world pause or result in stop-the-world Full GC. Increase heap size,");
157   out->print_cr("tune GC heuristics, set more aggressive pacing delay, or lower allocation rate");
158   out->print_cr("to avoid Degenerated and Full GC cycles. Abbreviated cycles are those which found");
159   out->print_cr("enough regions with no live objects to skip evacuation.");
160   out->cr();
161 
162   size_t completed_gcs = _success_full_gcs + _success_degenerated_gcs + _success_concurrent_gcs + _success_old_gcs;
163   out->print_cr(SIZE_FORMAT_W(5) " Completed GCs", completed_gcs);
164   out->print_cr(SIZE_FORMAT_W(5) " Successful Concurrent GCs (%.2f%%)",  _success_concurrent_gcs, percent_of(_success_concurrent_gcs, completed_gcs));
165   out->print_cr("  " SIZE_FORMAT_W(5) " invoked explicitly (%.2f%%)",    _explicit_concurrent, percent_of(_explicit_concurrent, _success_concurrent_gcs));
166   out->print_cr("  " SIZE_FORMAT_W(5) " invoked implicitly (%.2f%%)",    _implicit_concurrent, percent_of(_implicit_concurrent, _success_concurrent_gcs));
167   out->print_cr("  " SIZE_FORMAT_W(5) " abbreviated (%.2f%%)",           _abbreviated_concurrent_gcs, percent_of(_abbreviated_concurrent_gcs, _success_concurrent_gcs));
168   out->cr();
169 
170   if (ShenandoahHeap::heap()->mode()->is_generational()) {
171     out->print_cr(SIZE_FORMAT_W(5) " Completed Old GCs (%.2f%%)",        _success_old_gcs, percent_of(_success_old_gcs, completed_gcs));
172     out->print_cr("  " SIZE_FORMAT_W(5) " mixed",                        _mixed_gcs);
173     out->print_cr("  " SIZE_FORMAT_W(5) " interruptions",                _interrupted_old_gcs);
174     out->cr();
175   }
176 
177   size_t degenerated_gcs = _alloc_failure_degenerated_upgrade_to_full + _success_degenerated_gcs;
178   out->print_cr(SIZE_FORMAT_W(5) " Degenerated GCs (%.2f%%)", degenerated_gcs, percent_of(degenerated_gcs, completed_gcs));
179   out->print_cr("  " SIZE_FORMAT_W(5) " upgraded to Full GC (%.2f%%)",          _alloc_failure_degenerated_upgrade_to_full, percent_of(_alloc_failure_degenerated_upgrade_to_full, degenerated_gcs));
180   out->print_cr("  " SIZE_FORMAT_W(5) " caused by allocation failure (%.2f%%)", _alloc_failure_degenerated, percent_of(_alloc_failure_degenerated, degenerated_gcs));
181   out->print_cr("  " SIZE_FORMAT_W(5) " abbreviated (%.2f%%)",                  _abbreviated_degenerated_gcs, percent_of(_abbreviated_degenerated_gcs, degenerated_gcs));
182   for (int c = 0; c < ShenandoahGC::_DEGENERATED_LIMIT; c++) {
183     if (_degen_points[c] > 0) {
184       const char* desc = ShenandoahGC::degen_point_to_string((ShenandoahGC::ShenandoahDegenPoint)c);
185       out->print_cr("    " SIZE_FORMAT_W(5) " happened at %s",         _degen_points[c], desc);
186     }
187   }

188   out->cr();
189 
190   out->print_cr(SIZE_FORMAT_W(5) " Full GCs (%.2f%%)",                          _success_full_gcs, percent_of(_success_full_gcs, completed_gcs));
191   out->print_cr("  " SIZE_FORMAT_W(5) " invoked explicitly (%.2f%%)",           _explicit_full, percent_of(_explicit_full, _success_full_gcs));
192   out->print_cr("  " SIZE_FORMAT_W(5) " invoked implicitly (%.2f%%)",           _implicit_full, percent_of(_implicit_full, _success_full_gcs));
193   out->print_cr("  " SIZE_FORMAT_W(5) " caused by allocation failure (%.2f%%)", _alloc_failure_full, percent_of(_alloc_failure_full, _success_full_gcs));
194   out->print_cr("  " SIZE_FORMAT_W(5) " upgraded from Degenerated GC (%.2f%%)", _alloc_failure_degenerated_upgrade_to_full, percent_of(_alloc_failure_degenerated_upgrade_to_full, _success_full_gcs));
195 }
< prev index next >