File: | jdk/src/hotspot/share/gc/g1/g1RemSetSummary.cpp |
Warning: | line 265, column 5 Called C++ object pointer is null |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* | |||
2 | * Copyright (c) 2013, 2020, 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 | * | |||
23 | */ | |||
24 | ||||
25 | #include "precompiled.hpp" | |||
26 | #include "gc/g1/g1BarrierSet.hpp" | |||
27 | #include "gc/g1/g1CardSetMemory.hpp" | |||
28 | #include "gc/g1/g1CollectedHeap.inline.hpp" | |||
29 | #include "gc/g1/g1ConcurrentRefine.hpp" | |||
30 | #include "gc/g1/g1ConcurrentRefineThread.hpp" | |||
31 | #include "gc/g1/g1DirtyCardQueue.hpp" | |||
32 | #include "gc/g1/g1RemSet.hpp" | |||
33 | #include "gc/g1/g1RemSetSummary.hpp" | |||
34 | #include "gc/g1/heapRegion.hpp" | |||
35 | #include "gc/g1/heapRegionRemSet.inline.hpp" | |||
36 | #include "memory/allocation.inline.hpp" | |||
37 | #include "memory/iterator.hpp" | |||
38 | #include "runtime/thread.inline.hpp" | |||
39 | ||||
40 | void G1RemSetSummary::update() { | |||
41 | class CollectData : public ThreadClosure { | |||
42 | G1RemSetSummary* _summary; | |||
43 | uint _counter; | |||
44 | public: | |||
45 | CollectData(G1RemSetSummary * summary) : _summary(summary), _counter(0) {} | |||
46 | virtual void do_thread(Thread* t) { | |||
47 | G1ConcurrentRefineThread* crt = static_cast<G1ConcurrentRefineThread*>(t); | |||
48 | _summary->set_rs_thread_vtime(_counter, crt->vtime_accum()); | |||
49 | _counter++; | |||
50 | } | |||
51 | } collector(this); | |||
52 | ||||
53 | G1CollectedHeap* g1h = G1CollectedHeap::heap(); | |||
54 | g1h->concurrent_refine()->threads_do(&collector); | |||
55 | _coarsenings = HeapRegionRemSet::coarsen_stats(); | |||
56 | ||||
57 | set_sampling_task_vtime(g1h->rem_set()->sampling_task_vtime()); | |||
58 | } | |||
59 | ||||
60 | void G1RemSetSummary::set_rs_thread_vtime(uint thread, double value) { | |||
61 | assert(_rs_threads_vtimes != NULL, "just checking")do { if (!(_rs_threads_vtimes != __null)) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/g1/g1RemSetSummary.cpp" , 61, "assert(" "_rs_threads_vtimes != __null" ") failed", "just checking" ); ::breakpoint(); } } while (0); | |||
62 | assert(thread < _num_vtimes, "just checking")do { if (!(thread < _num_vtimes)) { (*g_assert_poison) = 'X' ;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/g1/g1RemSetSummary.cpp" , 62, "assert(" "thread < _num_vtimes" ") failed", "just checking" ); ::breakpoint(); } } while (0); | |||
63 | _rs_threads_vtimes[thread] = value; | |||
64 | } | |||
65 | ||||
66 | double G1RemSetSummary::rs_thread_vtime(uint thread) const { | |||
67 | assert(_rs_threads_vtimes != NULL, "just checking")do { if (!(_rs_threads_vtimes != __null)) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/g1/g1RemSetSummary.cpp" , 67, "assert(" "_rs_threads_vtimes != __null" ") failed", "just checking" ); ::breakpoint(); } } while (0); | |||
68 | assert(thread < _num_vtimes, "just checking")do { if (!(thread < _num_vtimes)) { (*g_assert_poison) = 'X' ;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/g1/g1RemSetSummary.cpp" , 68, "assert(" "thread < _num_vtimes" ") failed", "just checking" ); ::breakpoint(); } } while (0); | |||
69 | return _rs_threads_vtimes[thread]; | |||
70 | } | |||
71 | ||||
72 | G1RemSetSummary::G1RemSetSummary(bool should_update) : | |||
73 | _coarsenings(), | |||
74 | _num_vtimes(G1ConcurrentRefine::max_num_threads()), | |||
75 | _rs_threads_vtimes(NEW_C_HEAP_ARRAY(double, _num_vtimes, mtGC)(double*) (AllocateHeap((_num_vtimes) * sizeof(double), mtGC) )), | |||
76 | _sampling_task_vtime(0.0f) { | |||
77 | ||||
78 | memset(_rs_threads_vtimes, 0, sizeof(double) * _num_vtimes); | |||
79 | ||||
80 | if (should_update) { | |||
81 | update(); | |||
82 | } | |||
83 | } | |||
84 | ||||
85 | G1RemSetSummary::~G1RemSetSummary() { | |||
86 | FREE_C_HEAP_ARRAY(double, _rs_threads_vtimes)FreeHeap((char*)(_rs_threads_vtimes)); | |||
87 | } | |||
88 | ||||
89 | void G1RemSetSummary::set(G1RemSetSummary* other) { | |||
90 | assert(other != NULL, "just checking")do { if (!(other != __null)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/g1/g1RemSetSummary.cpp" , 90, "assert(" "other != __null" ") failed", "just checking" ); ::breakpoint(); } } while (0); | |||
91 | assert(_num_vtimes == other->_num_vtimes, "just checking")do { if (!(_num_vtimes == other->_num_vtimes)) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/g1/g1RemSetSummary.cpp" , 91, "assert(" "_num_vtimes == other->_num_vtimes" ") failed" , "just checking"); ::breakpoint(); } } while (0); | |||
92 | ||||
93 | _coarsenings = other->_coarsenings; | |||
94 | ||||
95 | memcpy(_rs_threads_vtimes, other->_rs_threads_vtimes, sizeof(double) * _num_vtimes); | |||
96 | ||||
97 | set_sampling_task_vtime(other->sampling_task_vtime()); | |||
98 | } | |||
99 | ||||
100 | void G1RemSetSummary::subtract_from(G1RemSetSummary* other) { | |||
101 | assert(other != NULL, "just checking")do { if (!(other != __null)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/g1/g1RemSetSummary.cpp" , 101, "assert(" "other != __null" ") failed", "just checking" ); ::breakpoint(); } } while (0); | |||
102 | assert(_num_vtimes == other->_num_vtimes, "just checking")do { if (!(_num_vtimes == other->_num_vtimes)) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/g1/g1RemSetSummary.cpp" , 102, "assert(" "_num_vtimes == other->_num_vtimes" ") failed" , "just checking"); ::breakpoint(); } } while (0); | |||
103 | ||||
104 | _coarsenings.subtract_from(other->_coarsenings); | |||
105 | ||||
106 | for (uint i = 0; i < _num_vtimes; i++) { | |||
107 | set_rs_thread_vtime(i, other->rs_thread_vtime(i) - rs_thread_vtime(i)); | |||
108 | } | |||
109 | ||||
110 | _sampling_task_vtime = other->sampling_task_vtime() - _sampling_task_vtime; | |||
111 | } | |||
112 | ||||
113 | class RegionTypeCounter { | |||
114 | private: | |||
115 | const char* _name; | |||
116 | ||||
117 | size_t _rs_wasted_mem_size; | |||
118 | size_t _rs_mem_size; | |||
119 | size_t _cards_occupied; | |||
120 | size_t _amount; | |||
121 | size_t _amount_tracked; | |||
122 | ||||
123 | size_t _code_root_mem_size; | |||
124 | size_t _code_root_elems; | |||
125 | ||||
126 | double rs_mem_size_percent_of(size_t total) { | |||
127 | return percent_of(_rs_mem_size, total); | |||
128 | } | |||
129 | ||||
130 | double cards_occupied_percent_of(size_t total) { | |||
131 | return percent_of(_cards_occupied, total); | |||
132 | } | |||
133 | ||||
134 | double code_root_mem_size_percent_of(size_t total) { | |||
135 | return percent_of(_code_root_mem_size, total); | |||
136 | } | |||
137 | ||||
138 | double code_root_elems_percent_of(size_t total) { | |||
139 | return percent_of(_code_root_elems, total); | |||
140 | } | |||
141 | ||||
142 | size_t amount() const { return _amount; } | |||
143 | size_t amount_tracked() const { return _amount_tracked; } | |||
144 | ||||
145 | public: | |||
146 | ||||
147 | RegionTypeCounter(const char* name) : _name(name), _rs_wasted_mem_size(0), _rs_mem_size(0), _cards_occupied(0), | |||
148 | _amount(0), _amount_tracked(0), _code_root_mem_size(0), _code_root_elems(0) { } | |||
149 | ||||
150 | void add(size_t rs_wasted_mem_size, size_t rs_mem_size, size_t cards_occupied, | |||
151 | size_t code_root_mem_size, size_t code_root_elems, bool tracked) { | |||
152 | _rs_wasted_mem_size += rs_wasted_mem_size; | |||
153 | _rs_mem_size += rs_mem_size; | |||
154 | _cards_occupied += cards_occupied; | |||
155 | _code_root_mem_size += code_root_mem_size; | |||
156 | _code_root_elems += code_root_elems; | |||
157 | _amount++; | |||
158 | _amount_tracked += tracked ? 1 : 0; | |||
159 | } | |||
160 | ||||
161 | size_t rs_wasted_mem_size() const { return _rs_wasted_mem_size; } | |||
162 | size_t rs_mem_size() const { return _rs_mem_size; } | |||
163 | size_t cards_occupied() const { return _cards_occupied; } | |||
164 | ||||
165 | size_t code_root_mem_size() const { return _code_root_mem_size; } | |||
166 | size_t code_root_elems() const { return _code_root_elems; } | |||
167 | ||||
168 | void print_rs_mem_info_on(outputStream * out, size_t total) { | |||
169 | out->print_cr(" " SIZE_FORMAT_W(8)"%" "8" "l" "u" " (%5.1f%%) by " SIZE_FORMAT"%" "l" "u" " " | |||
170 | "(" SIZE_FORMAT"%" "l" "u" ") %s regions wasted " SIZE_FORMAT"%" "l" "u", | |||
171 | rs_mem_size(), rs_mem_size_percent_of(total), | |||
172 | amount_tracked(), amount(), | |||
173 | _name, rs_wasted_mem_size()); | |||
174 | } | |||
175 | ||||
176 | void print_cards_occupied_info_on(outputStream * out, size_t total) { | |||
177 | out->print_cr(" " SIZE_FORMAT_W(8)"%" "8" "l" "u" " (%5.1f%%) entries by " SIZE_FORMAT"%" "l" "u" " " | |||
178 | "(" SIZE_FORMAT"%" "l" "u" ") %s regions", | |||
179 | cards_occupied(), cards_occupied_percent_of(total), | |||
180 | amount_tracked(), amount(), _name); | |||
181 | } | |||
182 | ||||
183 | void print_code_root_mem_info_on(outputStream * out, size_t total) { | |||
184 | out->print_cr(" " SIZE_FORMAT_W(8)"%" "8" "l" "u" "%s (%5.1f%%) by " SIZE_FORMAT"%" "l" "u" " %s regions", | |||
185 | byte_size_in_proper_unit(code_root_mem_size()), | |||
186 | proper_unit_for_byte_size(code_root_mem_size()), | |||
187 | code_root_mem_size_percent_of(total), amount(), _name); | |||
188 | } | |||
189 | ||||
190 | void print_code_root_elems_info_on(outputStream * out, size_t total) { | |||
191 | out->print_cr(" " SIZE_FORMAT_W(8)"%" "8" "l" "u" " (%5.1f%%) elements by " SIZE_FORMAT"%" "l" "u" " %s regions", | |||
192 | code_root_elems(), code_root_elems_percent_of(total), amount(), _name); | |||
193 | } | |||
194 | }; | |||
195 | ||||
196 | ||||
197 | class HRRSStatsIter: public HeapRegionClosure { | |||
198 | private: | |||
199 | RegionTypeCounter _young; | |||
200 | RegionTypeCounter _humongous; | |||
201 | RegionTypeCounter _free; | |||
202 | RegionTypeCounter _old; | |||
203 | RegionTypeCounter _archive; | |||
204 | RegionTypeCounter _all; | |||
205 | ||||
206 | size_t _max_rs_mem_sz; | |||
207 | HeapRegion* _max_rs_mem_sz_region; | |||
208 | ||||
209 | size_t total_rs_wasted_mem_sz() const { return _all.rs_wasted_mem_size(); } | |||
210 | size_t total_rs_mem_sz() const { return _all.rs_mem_size(); } | |||
211 | size_t total_cards_occupied() const { return _all.cards_occupied(); } | |||
212 | ||||
213 | size_t max_rs_mem_sz() const { return _max_rs_mem_sz; } | |||
214 | HeapRegion* max_rs_mem_sz_region() const { return _max_rs_mem_sz_region; } | |||
215 | ||||
216 | size_t _max_code_root_mem_sz; | |||
217 | HeapRegion* _max_code_root_mem_sz_region; | |||
218 | ||||
219 | size_t total_code_root_mem_sz() const { return _all.code_root_mem_size(); } | |||
220 | size_t total_code_root_elems() const { return _all.code_root_elems(); } | |||
221 | ||||
222 | size_t max_code_root_mem_sz() const { return _max_code_root_mem_sz; } | |||
223 | HeapRegion* max_code_root_mem_sz_region() const { return _max_code_root_mem_sz_region; } | |||
224 | ||||
225 | public: | |||
226 | HRRSStatsIter() : _young("Young"), _humongous("Humongous"), | |||
227 | _free("Free"), _old("Old"), _archive("Archive"), _all("All"), | |||
228 | _max_rs_mem_sz(0), _max_rs_mem_sz_region(NULL__null), | |||
229 | _max_code_root_mem_sz(0), _max_code_root_mem_sz_region(NULL__null) | |||
230 | {} | |||
231 | ||||
232 | bool do_heap_region(HeapRegion* r) { | |||
233 | HeapRegionRemSet* hrrs = r->rem_set(); | |||
234 | ||||
235 | // HeapRegionRemSet::mem_size() includes the | |||
236 | // size of the strong code roots | |||
237 | size_t rs_wasted_mem_sz = hrrs->wasted_mem_size(); | |||
238 | size_t rs_mem_sz = hrrs->mem_size(); | |||
239 | if (rs_mem_sz > _max_rs_mem_sz) { | |||
| ||||
240 | _max_rs_mem_sz = rs_mem_sz; | |||
241 | _max_rs_mem_sz_region = r; | |||
242 | } | |||
243 | size_t occupied_cards = hrrs->occupied(); | |||
244 | size_t code_root_mem_sz = hrrs->strong_code_roots_mem_size(); | |||
245 | if (code_root_mem_sz > max_code_root_mem_sz()) { | |||
246 | _max_code_root_mem_sz = code_root_mem_sz; | |||
247 | _max_code_root_mem_sz_region = r; | |||
248 | } | |||
249 | size_t code_root_elems = hrrs->strong_code_roots_list_length(); | |||
250 | ||||
251 | RegionTypeCounter* current = NULL__null; | |||
252 | if (r->is_free()) { | |||
253 | current = &_free; | |||
254 | } else if (r->is_young()) { | |||
255 | current = &_young; | |||
256 | } else if (r->is_humongous()) { | |||
257 | current = &_humongous; | |||
258 | } else if (r->is_old()) { | |||
259 | current = &_old; | |||
260 | } else if (r->is_archive()) { | |||
261 | current = &_archive; | |||
262 | } else { | |||
263 | ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here( "/home/daniel/Projects/java/jdk/src/hotspot/share/gc/g1/g1RemSetSummary.cpp" , 263); ::breakpoint(); } while (0); | |||
264 | } | |||
265 | current->add(rs_wasted_mem_sz, rs_mem_sz, occupied_cards, | |||
| ||||
266 | code_root_mem_sz, code_root_elems, r->rem_set()->is_tracked()); | |||
267 | _all.add(rs_wasted_mem_sz, rs_mem_sz, occupied_cards, | |||
268 | code_root_mem_sz, code_root_elems, r->rem_set()->is_tracked()); | |||
269 | ||||
270 | return false; | |||
271 | } | |||
272 | ||||
273 | void print_summary_on(outputStream* out) { | |||
274 | RegionTypeCounter* counters[] = { &_young, &_humongous, &_free, &_old, &_archive, NULL__null }; | |||
275 | ||||
276 | out->print_cr(" Current rem set statistics"); | |||
277 | out->print_cr(" Total per region rem sets sizes = " SIZE_FORMAT"%" "l" "u" | |||
278 | " Max = " SIZE_FORMAT"%" "l" "u" " wasted = " SIZE_FORMAT"%" "l" "u", | |||
279 | total_rs_mem_sz(), | |||
280 | max_rs_mem_sz(), | |||
281 | total_rs_wasted_mem_sz()); | |||
282 | for (RegionTypeCounter** current = &counters[0]; *current != NULL__null; current++) { | |||
283 | (*current)->print_rs_mem_info_on(out, total_rs_mem_sz()); | |||
284 | } | |||
285 | ||||
286 | out->print_cr(" " SIZE_FORMAT"%" "l" "u" " occupied cards represented.", | |||
287 | total_cards_occupied()); | |||
288 | for (RegionTypeCounter** current = &counters[0]; *current != NULL__null; current++) { | |||
289 | (*current)->print_cards_occupied_info_on(out, total_cards_occupied()); | |||
290 | } | |||
291 | ||||
292 | // Largest sized rem set region statistics | |||
293 | HeapRegionRemSet* rem_set = max_rs_mem_sz_region()->rem_set(); | |||
294 | out->print_cr(" Region with largest rem set = " HR_FORMAT"%u:(%s)[" "0x%016" "l" "x" "," "0x%016" "l" "x" "," "0x%016" "l" "x" "]" ", " | |||
295 | "size = " SIZE_FORMAT"%" "l" "u" " occupied = " SIZE_FORMAT"%" "l" "u", | |||
296 | HR_FORMAT_PARAMS(max_rs_mem_sz_region())(max_rs_mem_sz_region())->hrm_index(), (max_rs_mem_sz_region ())->get_short_type_str(), p2i((max_rs_mem_sz_region())-> bottom()), p2i((max_rs_mem_sz_region())->top()), p2i((max_rs_mem_sz_region ())->end()), | |||
297 | rem_set->mem_size(), | |||
298 | rem_set->occupied()); | |||
299 | ||||
300 | HeapRegionRemSet::print_static_mem_size(out); | |||
301 | G1CardSetFreePool::free_list_pool()->print_on(out); | |||
302 | ||||
303 | // Strong code root statistics | |||
304 | HeapRegionRemSet* max_code_root_rem_set = max_code_root_mem_sz_region()->rem_set(); | |||
305 | out->print_cr(" Total heap region code root sets sizes = " SIZE_FORMAT"%" "l" "u" "%s." | |||
306 | " Max = " SIZE_FORMAT"%" "l" "u" "%s.", | |||
307 | byte_size_in_proper_unit(total_code_root_mem_sz()), | |||
308 | proper_unit_for_byte_size(total_code_root_mem_sz()), | |||
309 | byte_size_in_proper_unit(max_code_root_rem_set->strong_code_roots_mem_size()), | |||
310 | proper_unit_for_byte_size(max_code_root_rem_set->strong_code_roots_mem_size())); | |||
311 | for (RegionTypeCounter** current = &counters[0]; *current != NULL__null; current++) { | |||
312 | (*current)->print_code_root_mem_info_on(out, total_code_root_mem_sz()); | |||
313 | } | |||
314 | ||||
315 | out->print_cr(" " SIZE_FORMAT"%" "l" "u" " code roots represented.", | |||
316 | total_code_root_elems()); | |||
317 | for (RegionTypeCounter** current = &counters[0]; *current != NULL__null; current++) { | |||
318 | (*current)->print_code_root_elems_info_on(out, total_code_root_elems()); | |||
319 | } | |||
320 | ||||
321 | out->print_cr(" Region with largest amount of code roots = " HR_FORMAT"%u:(%s)[" "0x%016" "l" "x" "," "0x%016" "l" "x" "," "0x%016" "l" "x" "]" ", " | |||
322 | "size = " SIZE_FORMAT"%" "l" "u" "%s, num_slots = " SIZE_FORMAT"%" "l" "u" ".", | |||
323 | HR_FORMAT_PARAMS(max_code_root_mem_sz_region())(max_code_root_mem_sz_region())->hrm_index(), (max_code_root_mem_sz_region ())->get_short_type_str(), p2i((max_code_root_mem_sz_region ())->bottom()), p2i((max_code_root_mem_sz_region())->top ()), p2i((max_code_root_mem_sz_region())->end()), | |||
324 | byte_size_in_proper_unit(max_code_root_rem_set->strong_code_roots_mem_size()), | |||
325 | proper_unit_for_byte_size(max_code_root_rem_set->strong_code_roots_mem_size()), | |||
326 | max_code_root_rem_set->strong_code_roots_list_length()); | |||
327 | } | |||
328 | }; | |||
329 | ||||
330 | void G1RemSetSummary::print_on(outputStream* out) { | |||
331 | out->print("Coarsening: "); | |||
332 | _coarsenings.print_on(out); | |||
333 | out->print_cr(" Concurrent refinement threads times (s)"); | |||
334 | out->print(" "); | |||
335 | for (uint i = 0; i < _num_vtimes; i++) { | |||
336 | out->print(" %5.2f", rs_thread_vtime(i)); | |||
337 | } | |||
338 | out->cr(); | |||
339 | out->print_cr(" Sampling task time (ms)"); | |||
340 | out->print_cr(" %5.3f", sampling_task_vtime() * MILLIUNITS); | |||
341 | ||||
342 | HRRSStatsIter blk; | |||
343 | G1CollectedHeap::heap()->heap_region_iterate(&blk); | |||
344 | blk.print_summary_on(out); | |||
345 | } |