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 #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHCOLLECTORPOLICY_HPP
26 #define SHARE_GC_SHENANDOAH_SHENANDOAHCOLLECTORPOLICY_HPP
27
28 #include "gc/shared/gcTrace.hpp"
29 #include "gc/shenandoah/shenandoahGC.hpp"
30 #include "gc/shenandoah/shenandoahSharedVariables.hpp"
31 #include "memory/allocation.hpp"
32 #include "utilities/ostream.hpp"
33
34 class ShenandoahTracer : public GCTracer, public CHeapObj<mtGC> {
35 public:
36 ShenandoahTracer() : GCTracer(Shenandoah) {}
37 };
38
39 class ShenandoahCollectorPolicy : public CHeapObj<mtGC> {
40 private:
41 size_t _success_concurrent_gcs;
42 size_t _abbreviated_concurrent_gcs;
43 size_t _success_degenerated_gcs;
44 size_t _abbreviated_degenerated_gcs;
45 // Written by control thread, read by mutators
46 volatile size_t _success_full_gcs;
47 uint _consecutive_degenerated_gcs;
48 size_t _alloc_failure_degenerated;
49 size_t _alloc_failure_degenerated_upgrade_to_full;
50 size_t _alloc_failure_full;
51 size_t _collection_cause_counts[GCCause::_last_gc_cause];
52 size_t _degen_point_counts[ShenandoahGC::_DEGENERATED_LIMIT];
53
54 ShenandoahSharedFlag _in_shutdown;
55 ShenandoahTracer* _tracer;
56
57
58 public:
59 ShenandoahCollectorPolicy();
60
61 // A collection cycle may be "abbreviated" if Shenandoah finds a sufficient percentage
62 // of regions that contain no live objects (ShenandoahImmediateThreshold). These cycles
63 // end after final mark, skipping the evacuation and reference-updating phases. Such
64 // cycles are very efficient and are worth tracking. Note that both degenerated and
65 // concurrent cycles can be abbreviated.
66 void record_success_concurrent(bool is_abbreviated);
67 void record_success_degenerated(bool is_abbreviated);
68 void record_success_full();
69 void record_alloc_failure_to_degenerated(ShenandoahGC::ShenandoahDegenPoint point);
70 void record_alloc_failure_to_full();
71 void record_degenerated_upgrade_to_full();
72 void record_collection_cause(GCCause::Cause cause);
73
74 void record_shutdown();
75 bool is_at_shutdown();
76
77 ShenandoahTracer* tracer() {return _tracer;}
78
79 void print_gc_stats(outputStream* out) const;
80
81 size_t full_gc_count() const {
82 return _success_full_gcs + _alloc_failure_degenerated_upgrade_to_full;
83 }
84
85 // If the heuristics find that the number of consecutive degenerated cycles is above
86 // ShenandoahFullGCThreshold, then they will initiate a Full GC upon an allocation
87 // failure.
88 inline size_t consecutive_degenerated_gc_count() const {
89 return _consecutive_degenerated_gcs;
90 }
91
92 static bool should_run_full_gc(GCCause::Cause cause);
93 static bool should_handle_requested_gc(GCCause::Cause cause);
94 };
95
96 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHCOLLECTORPOLICY_HPP
|
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 #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHCOLLECTORPOLICY_HPP
27 #define SHARE_GC_SHENANDOAH_SHENANDOAHCOLLECTORPOLICY_HPP
28
29 #include "gc/shared/gcTrace.hpp"
30 #include "gc/shenandoah/shenandoahGC.hpp"
31 #include "gc/shenandoah/shenandoahSharedVariables.hpp"
32 #include "gc/shenandoah/shenandoahTrace.hpp"
33 #include "memory/allocation.hpp"
34 #include "utilities/ostream.hpp"
35
36 class ShenandoahCollectorPolicy : public CHeapObj<mtGC> {
37 private:
38 size_t _success_concurrent_gcs;
39 size_t _abbreviated_concurrent_gcs;
40 size_t _success_degenerated_gcs;
41 size_t _abbreviated_degenerated_gcs;
42 // Written by control thread, read by mutators
43 volatile size_t _success_full_gcs;
44 uint _consecutive_degenerated_gcs;
45 volatile size_t _consecutive_young_gcs;
46 size_t _mixed_gcs;
47 size_t _success_old_gcs;
48 size_t _interrupted_old_gcs;
49 size_t _alloc_failure_degenerated;
50 size_t _alloc_failure_degenerated_upgrade_to_full;
51 size_t _alloc_failure_full;
52 size_t _collection_cause_counts[GCCause::_last_gc_cause];
53 size_t _degen_point_counts[ShenandoahGC::_DEGENERATED_LIMIT];
54
55 ShenandoahSharedFlag _in_shutdown;
56 ShenandoahTracer* _tracer;
57
58
59 public:
60 ShenandoahCollectorPolicy();
61
62 void record_mixed_cycle();
63 void record_success_old();
64 void record_interrupted_old();
65
66 // A collection cycle may be "abbreviated" if Shenandoah finds a sufficient percentage
67 // of regions that contain no live objects (ShenandoahImmediateThreshold). These cycles
68 // end after final mark, skipping the evacuation and reference-updating phases. Such
69 // cycles are very efficient and are worth tracking. Note that both degenerated and
70 // concurrent cycles can be abbreviated.
71 void record_success_concurrent(bool is_young, bool is_abbreviated);
72 void record_success_degenerated(bool is_young, bool is_abbreviated);
73 void record_success_full();
74 void record_alloc_failure_to_degenerated(ShenandoahGC::ShenandoahDegenPoint point);
75 void record_alloc_failure_to_full();
76 void record_degenerated_upgrade_to_full();
77 void record_collection_cause(GCCause::Cause cause);
78
79 void record_shutdown();
80 bool is_at_shutdown();
81
82 ShenandoahTracer* tracer() {return _tracer;}
83
84 void print_gc_stats(outputStream* out) const;
85
86 size_t full_gc_count() const {
87 return _success_full_gcs + _alloc_failure_degenerated_upgrade_to_full;
88 }
89
90 // If the heuristics find that the number of consecutive degenerated cycles is above
91 // ShenandoahFullGCThreshold, then they will initiate a Full GC upon an allocation
92 // failure.
93 inline size_t consecutive_degenerated_gc_count() const {
94 return _consecutive_degenerated_gcs;
95 }
96
97 static bool is_requested_gc(GCCause::Cause cause);
98 static bool should_run_full_gc(GCCause::Cause cause);
99 static bool should_handle_requested_gc(GCCause::Cause cause);
100
101 inline size_t consecutive_young_gc_count() const {
102 return _consecutive_young_gcs;
103 }
104
105 private:
106 void update_young(bool is_young);
107 };
108
109 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHCOLLECTORPOLICY_HPP
|