1 /*
2 * Copyright (c) 2011, 2015, Oracle and/or its affiliates. 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 *
107 //
108 // We update all the above synchronously and we store the results in
109 // fields so that we just read said fields when needed. A subtle point
110 // is that all the above sizes need to be recalculated when the old
111 // gen changes capacity (after a GC or after a humongous allocation)
112 // but only the eden occupancy changes when a new eden region is
113 // allocated. So, in the latter case we have minimal recalculation to
114 // do which is important as we want to keep the eden region allocation
115 // path as low-overhead as possible.
116
117 class G1MonitoringSupport : public CHeapObj<mtGC> {
118 friend class VMStructs;
119
120 G1CollectedHeap* _g1h;
121
122 // jstat performance counters
123 // incremental collections both young and mixed
124 CollectorCounters* _incremental_collection_counters;
125 // full stop-the-world collections
126 CollectorCounters* _full_collection_counters;
127 // young collection set counters. The _eden_counters,
128 // _from_counters, and _to_counters are associated with
129 // this "generational" counter.
130 GenerationCounters* _young_collection_counters;
131 // old collection set counters. The _old_space_counters
132 // below are associated with this "generational" counter.
133 GenerationCounters* _old_collection_counters;
134 // Counters for the capacity and used for
135 // the whole heap
136 HSpaceCounters* _old_space_counters;
137 // the young collection
138 HSpaceCounters* _eden_counters;
139 // the survivor collection (only one, _to_counters, is actively used)
140 HSpaceCounters* _from_counters;
141 HSpaceCounters* _to_counters;
142
143 // When it's appropriate to recalculate the various sizes (at the
144 // end of a GC, when a new eden region is allocated, etc.) we store
145 // them here so that we can easily report them when needed and not
146 // have to recalculate them every time.
194 // report a capacity of a generation that contains several spaces
195 // (e.g., young gen includes one eden, two survivor spaces), the
196 // mult parameter is provided in order to adding the appropriate
197 // padding multiple times so that the capacities add up correctly.
198 static size_t pad_capacity(size_t size_bytes, size_t mult = 1) {
199 return size_bytes + MinObjAlignmentInBytes * mult;
200 }
201
202 // Recalculate all the sizes from scratch and update all the jstat
203 // counters accordingly.
204 void update_sizes();
205 // Recalculate only what's necessary when a new eden region is
206 // allocated and update any jstat counters that need to be updated.
207 void update_eden_size();
208
209 CollectorCounters* incremental_collection_counters() {
210 return _incremental_collection_counters;
211 }
212 CollectorCounters* full_collection_counters() {
213 return _full_collection_counters;
214 }
215 GenerationCounters* young_collection_counters() {
216 return _young_collection_counters;
217 }
218 GenerationCounters* old_collection_counters() {
219 return _old_collection_counters;
220 }
221 HSpaceCounters* old_space_counters() { return _old_space_counters; }
222 HSpaceCounters* eden_counters() { return _eden_counters; }
223 HSpaceCounters* from_counters() { return _from_counters; }
224 HSpaceCounters* to_counters() { return _to_counters; }
225
226 // Monitoring support used by
227 // MemoryService
228 // jstat counters
229 // Tracing
230
231 size_t overall_reserved() { return _overall_reserved; }
232 size_t overall_committed() { return _overall_committed; }
233 size_t overall_used() { return _overall_used; }
|
1 /*
2 * Copyright (c) 2011, 2018, Oracle and/or its affiliates. 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 *
107 //
108 // We update all the above synchronously and we store the results in
109 // fields so that we just read said fields when needed. A subtle point
110 // is that all the above sizes need to be recalculated when the old
111 // gen changes capacity (after a GC or after a humongous allocation)
112 // but only the eden occupancy changes when a new eden region is
113 // allocated. So, in the latter case we have minimal recalculation to
114 // do which is important as we want to keep the eden region allocation
115 // path as low-overhead as possible.
116
117 class G1MonitoringSupport : public CHeapObj<mtGC> {
118 friend class VMStructs;
119
120 G1CollectedHeap* _g1h;
121
122 // jstat performance counters
123 // incremental collections both young and mixed
124 CollectorCounters* _incremental_collection_counters;
125 // full stop-the-world collections
126 CollectorCounters* _full_collection_counters;
127 // stop-the-world phases in G1
128 CollectorCounters* _conc_collection_counters;
129 // young collection set counters. The _eden_counters,
130 // _from_counters, and _to_counters are associated with
131 // this "generational" counter.
132 GenerationCounters* _young_collection_counters;
133 // old collection set counters. The _old_space_counters
134 // below are associated with this "generational" counter.
135 GenerationCounters* _old_collection_counters;
136 // Counters for the capacity and used for
137 // the whole heap
138 HSpaceCounters* _old_space_counters;
139 // the young collection
140 HSpaceCounters* _eden_counters;
141 // the survivor collection (only one, _to_counters, is actively used)
142 HSpaceCounters* _from_counters;
143 HSpaceCounters* _to_counters;
144
145 // When it's appropriate to recalculate the various sizes (at the
146 // end of a GC, when a new eden region is allocated, etc.) we store
147 // them here so that we can easily report them when needed and not
148 // have to recalculate them every time.
196 // report a capacity of a generation that contains several spaces
197 // (e.g., young gen includes one eden, two survivor spaces), the
198 // mult parameter is provided in order to adding the appropriate
199 // padding multiple times so that the capacities add up correctly.
200 static size_t pad_capacity(size_t size_bytes, size_t mult = 1) {
201 return size_bytes + MinObjAlignmentInBytes * mult;
202 }
203
204 // Recalculate all the sizes from scratch and update all the jstat
205 // counters accordingly.
206 void update_sizes();
207 // Recalculate only what's necessary when a new eden region is
208 // allocated and update any jstat counters that need to be updated.
209 void update_eden_size();
210
211 CollectorCounters* incremental_collection_counters() {
212 return _incremental_collection_counters;
213 }
214 CollectorCounters* full_collection_counters() {
215 return _full_collection_counters;
216 }
217 CollectorCounters* conc_collection_counters() {
218 return _conc_collection_counters;
219 }
220 GenerationCounters* young_collection_counters() {
221 return _young_collection_counters;
222 }
223 GenerationCounters* old_collection_counters() {
224 return _old_collection_counters;
225 }
226 HSpaceCounters* old_space_counters() { return _old_space_counters; }
227 HSpaceCounters* eden_counters() { return _eden_counters; }
228 HSpaceCounters* from_counters() { return _from_counters; }
229 HSpaceCounters* to_counters() { return _to_counters; }
230
231 // Monitoring support used by
232 // MemoryService
233 // jstat counters
234 // Tracing
235
236 size_t overall_reserved() { return _overall_reserved; }
237 size_t overall_committed() { return _overall_committed; }
238 size_t overall_used() { return _overall_used; }
|