Print this page
G1: Use SoftMaxHeapSize to guide GC heuristics
Split |
Close |
Expand all |
Collapse all |
--- old/src/hotspot/share/gc/g1/g1IHOPControl.hpp
+++ new/src/hotspot/share/gc/g1/g1IHOPControl.hpp
1 1 /*
2 2 * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 4 *
5 5 * This code is free software; you can redistribute it and/or modify it
6 6 * under the terms of the GNU General Public License version 2 only, as
7 7 * published by the Free Software Foundation.
8 8 *
9 9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 12 * version 2 for more details (a copy is included in the LICENSE file that
13 13 * accompanied this code).
14 14 *
15 15 * You should have received a copy of the GNU General Public License version
16 16 * 2 along with this work; if not, write to the Free Software Foundation,
17 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 18 *
19 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 20 * or visit www.oracle.com if you need additional information or have any
21 21 * questions.
22 22 *
23 23 */
24 24
25 25 #ifndef SHARE_GC_G1_G1IHOPCONTROL_HPP
26 26 #define SHARE_GC_G1_G1IHOPCONTROL_HPP
27 27
28 28 #include "memory/allocation.hpp"
29 29 #include "utilities/numberSeq.hpp"
30 30
31 31 class G1Predictions;
32 32 class G1NewTracer;
33 33
34 34 // Base class for algorithms that calculate the heap occupancy at which
35 35 // concurrent marking should start. This heap usage threshold should be relative
36 36 // to old gen size.
37 37 class G1IHOPControl : public CHeapObj<mtGC> {
38 38 protected:
39 39 // The initial IHOP value relative to the target occupancy.
40 40 double _initial_ihop_percent;
41 41 // The target maximum occupancy of the heap. The target occupancy is the number
42 42 // of bytes when marking should be finished and reclaim started.
43 43 size_t _target_occupancy;
44 44
45 45 // Most recent complete mutator allocation period in seconds.
46 46 double _last_allocation_time_s;
47 47 // Amount of bytes allocated during _last_allocation_time_s.
48 48 size_t _last_allocated_bytes;
49 49
50 50 // Initialize an instance with the initial IHOP value in percent. The target
51 51 // occupancy will be updated at the first heap expansion.
52 52 G1IHOPControl(double initial_ihop_percent);
53 53
54 54 // Most recent time from the end of the initial mark to the start of the first
55 55 // mixed gc.
56 56 virtual double last_marking_length_s() const = 0;
57 57 public:
58 58 virtual ~G1IHOPControl() { }
59 59
60 60 // Get the current non-young occupancy at which concurrent marking should start.
61 61 virtual size_t get_conc_mark_start_threshold() = 0;
62 62
63 63 // Adjust target occupancy.
64 64 virtual void update_target_occupancy(size_t new_target_occupancy);
65 65 // Update information about time during which allocations in the Java heap occurred,
66 66 // how large these allocations were in bytes, and an additional buffer.
67 67 // The allocations should contain any amount of space made unusable for further
68 68 // allocation, e.g. any waste caused by TLAB allocation, space at the end of
69 69 // humongous objects that can not be used for allocation, etc.
↓ open down ↓ |
69 lines elided |
↑ open up ↑ |
70 70 // Together with the target occupancy, this additional buffer should contain the
71 71 // difference between old gen size and total heap size at the start of reclamation,
72 72 // and space required for that reclamation.
73 73 virtual void update_allocation_info(double allocation_time_s, size_t allocated_bytes, size_t additional_buffer_size);
74 74 // Update the time spent in the mutator beginning from the end of initial mark to
75 75 // the first mixed gc.
76 76 virtual void update_marking_length(double marking_length_s) = 0;
77 77
78 78 virtual void print();
79 79 virtual void send_trace_event(G1NewTracer* tracer);
80 +
81 + virtual size_t predict_unstrained_buffer_size() const { return 0; }
80 82 };
81 83
82 84 // The returned concurrent mark starting occupancy threshold is a fixed value
83 85 // relative to the maximum heap size.
84 86 class G1StaticIHOPControl : public G1IHOPControl {
85 87 // Most recent mutator time between the end of initial mark to the start of the
86 88 // first mixed gc.
87 89 double _last_marking_length_s;
88 90 protected:
89 91 double last_marking_length_s() const { return _last_marking_length_s; }
90 92 public:
91 93 G1StaticIHOPControl(double ihop_percent);
92 94
93 95 size_t get_conc_mark_start_threshold() {
94 96 guarantee(_target_occupancy > 0, "Target occupancy must have been initialized.");
95 97 return (size_t) (_initial_ihop_percent * _target_occupancy / 100.0);
96 98 }
97 99
98 100 virtual void update_marking_length(double marking_length_s) {
99 101 assert(marking_length_s > 0.0, "Marking length must be larger than zero but is %.3f", marking_length_s);
100 102 _last_marking_length_s = marking_length_s;
101 103 }
102 104 };
103 105
104 106 // This algorithm tries to return a concurrent mark starting occupancy value that
105 107 // makes sure that during marking the given target occupancy is never exceeded,
106 108 // based on predictions of current allocation rate and time periods between
107 109 // initial mark and the first mixed gc.
108 110 class G1AdaptiveIHOPControl : public G1IHOPControl {
109 111 size_t _heap_reserve_percent; // Percentage of maximum heap capacity we should avoid to touch
110 112 size_t _heap_waste_percent; // Percentage of free heap that should be considered as waste.
111 113
112 114 const G1Predictions * _predictor;
113 115
114 116 TruncatedSeq _marking_times_s;
115 117 TruncatedSeq _allocation_rate_s;
116 118
117 119 // The most recent unrestrained size of the young gen. This is used as an additional
118 120 // factor in the calculation of the threshold, as the threshold is based on
119 121 // non-young gen occupancy at the end of GC. For the IHOP threshold, we need to
120 122 // consider the young gen size during that time too.
121 123 // Since we cannot know what young gen sizes are used in the future, we will just
122 124 // use the current one. We expect that this one will be one with a fairly large size,
123 125 // as there is no marking or mixed gc that could impact its size too much.
124 126 size_t _last_unrestrained_young_size;
125 127
126 128 // Get a new prediction bounded below by zero from the given sequence.
127 129 double predict(TruncatedSeq const* seq) const;
128 130
129 131 bool have_enough_data_for_prediction() const;
130 132
131 133 // The "actual" target threshold the algorithm wants to keep during and at the
132 134 // end of marking. This is typically lower than the requested threshold, as the
133 135 // algorithm needs to consider restrictions by the environment.
134 136 size_t actual_target_threshold() const;
135 137 protected:
136 138 virtual double last_marking_length_s() const { return _marking_times_s.last(); }
137 139 public:
138 140 G1AdaptiveIHOPControl(double ihop_percent,
139 141 G1Predictions const* predictor,
↓ open down ↓ |
50 lines elided |
↑ open up ↑ |
140 142 size_t heap_reserve_percent, // The percentage of total heap capacity that should not be tapped into.
141 143 size_t heap_waste_percent); // The percentage of the free space in the heap that we think is not usable for allocation.
142 144
143 145 virtual size_t get_conc_mark_start_threshold();
144 146
145 147 virtual void update_allocation_info(double allocation_time_s, size_t allocated_bytes, size_t additional_buffer_size);
146 148 virtual void update_marking_length(double marking_length_s);
147 149
148 150 virtual void print();
149 151 virtual void send_trace_event(G1NewTracer* tracer);
152 + virtual size_t predict_unstrained_buffer_size() const;
150 153 };
151 154
152 155 #endif // SHARE_GC_G1_G1IHOPCONTROL_HPP
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX