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