Path: blob/master/src/hotspot/share/gc/shenandoah/shenandoahCollectorPolicy.cpp
40960 views
/*1* Copyright (c) 2013, 2021, Red Hat, Inc. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#include "precompiled.hpp"2526#include "gc/shenandoah/shenandoahCollectorPolicy.hpp"27#include "gc/shenandoah/shenandoahGC.hpp"28#include "gc/shenandoah/shenandoahHeap.inline.hpp"29#include "runtime/os.hpp"3031ShenandoahCollectorPolicy::ShenandoahCollectorPolicy() :32_success_concurrent_gcs(0),33_success_degenerated_gcs(0),34_success_full_gcs(0),35_alloc_failure_degenerated(0),36_alloc_failure_degenerated_upgrade_to_full(0),37_alloc_failure_full(0),38_explicit_concurrent(0),39_explicit_full(0),40_implicit_concurrent(0),41_implicit_full(0),42_cycle_counter(0) {4344Copy::zero_to_bytes(_degen_points, sizeof(size_t) * ShenandoahGC::_DEGENERATED_LIMIT);4546_tracer = new (ResourceObj::C_HEAP, mtGC) ShenandoahTracer();4748}4950void ShenandoahCollectorPolicy::record_explicit_to_concurrent() {51_explicit_concurrent++;52}5354void ShenandoahCollectorPolicy::record_explicit_to_full() {55_explicit_full++;56}5758void ShenandoahCollectorPolicy::record_implicit_to_concurrent() {59_implicit_concurrent++;60}6162void ShenandoahCollectorPolicy::record_implicit_to_full() {63_implicit_full++;64}6566void ShenandoahCollectorPolicy::record_alloc_failure_to_full() {67_alloc_failure_full++;68}6970void ShenandoahCollectorPolicy::record_alloc_failure_to_degenerated(ShenandoahGC::ShenandoahDegenPoint point) {71assert(point < ShenandoahGC::_DEGENERATED_LIMIT, "sanity");72_alloc_failure_degenerated++;73_degen_points[point]++;74}7576void ShenandoahCollectorPolicy::record_degenerated_upgrade_to_full() {77_alloc_failure_degenerated_upgrade_to_full++;78}7980void ShenandoahCollectorPolicy::record_success_concurrent() {81_success_concurrent_gcs++;82}8384void ShenandoahCollectorPolicy::record_success_degenerated() {85_success_degenerated_gcs++;86}8788void ShenandoahCollectorPolicy::record_success_full() {89_success_full_gcs++;90}9192size_t ShenandoahCollectorPolicy::cycle_counter() const {93return _cycle_counter;94}9596void ShenandoahCollectorPolicy::record_cycle_start() {97_cycle_counter++;98}99100void ShenandoahCollectorPolicy::record_shutdown() {101_in_shutdown.set();102}103104bool ShenandoahCollectorPolicy::is_at_shutdown() {105return _in_shutdown.is_set();106}107108void ShenandoahCollectorPolicy::print_gc_stats(outputStream* out) const {109out->print_cr("Under allocation pressure, concurrent cycles may cancel, and either continue cycle");110out->print_cr("under stop-the-world pause or result in stop-the-world Full GC. Increase heap size,");111out->print_cr("tune GC heuristics, set more aggressive pacing delay, or lower allocation rate");112out->print_cr("to avoid Degenerated and Full GC cycles.");113out->cr();114115out->print_cr(SIZE_FORMAT_W(5) " successful concurrent GCs", _success_concurrent_gcs);116out->print_cr(" " SIZE_FORMAT_W(5) " invoked explicitly", _explicit_concurrent);117out->print_cr(" " SIZE_FORMAT_W(5) " invoked implicitly", _implicit_concurrent);118out->cr();119120out->print_cr(SIZE_FORMAT_W(5) " Degenerated GCs", _success_degenerated_gcs);121out->print_cr(" " SIZE_FORMAT_W(5) " caused by allocation failure", _alloc_failure_degenerated);122for (int c = 0; c < ShenandoahGC::_DEGENERATED_LIMIT; c++) {123if (_degen_points[c] > 0) {124const char* desc = ShenandoahGC::degen_point_to_string((ShenandoahGC::ShenandoahDegenPoint)c);125out->print_cr(" " SIZE_FORMAT_W(5) " happened at %s", _degen_points[c], desc);126}127}128out->print_cr(" " SIZE_FORMAT_W(5) " upgraded to Full GC", _alloc_failure_degenerated_upgrade_to_full);129out->cr();130131out->print_cr(SIZE_FORMAT_W(5) " Full GCs", _success_full_gcs + _alloc_failure_degenerated_upgrade_to_full);132out->print_cr(" " SIZE_FORMAT_W(5) " invoked explicitly", _explicit_full);133out->print_cr(" " SIZE_FORMAT_W(5) " invoked implicitly", _implicit_full);134out->print_cr(" " SIZE_FORMAT_W(5) " caused by allocation failure", _alloc_failure_full);135out->print_cr(" " SIZE_FORMAT_W(5) " upgraded from Degenerated GC", _alloc_failure_degenerated_upgrade_to_full);136}137138139