author | stuefe |
Sun, 11 Mar 2018 07:11:03 +0100 | |
changeset 49389 | 9ef2eee8ca7c |
parent 49033 | 3acc342c0738 |
child 49980 | 57dd7b4ba338 |
permissions | -rw-r--r-- |
13195 | 1 |
/* |
48884
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
2 |
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. |
13195 | 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 |
#include "precompiled.hpp" |
|
25946 | 25 |
|
26 |
#include "memory/allocation.hpp" |
|
27 |
#include "services/mallocTracker.hpp" |
|
13195 | 28 |
#include "services/memReporter.hpp" |
25946 | 29 |
#include "services/virtualMemoryTracker.hpp" |
30 |
#include "utilities/globalDefinitions.hpp" |
|
31 |
||
32 |
size_t MemReporterBase::reserved_total(const MallocMemory* malloc, const VirtualMemory* vm) const { |
|
33 |
return malloc->malloc_size() + malloc->arena_size() + vm->reserved(); |
|
34 |
} |
|
35 |
||
36 |
size_t MemReporterBase::committed_total(const MallocMemory* malloc, const VirtualMemory* vm) const { |
|
37 |
return malloc->malloc_size() + malloc->arena_size() + vm->committed(); |
|
38 |
} |
|
13195 | 39 |
|
25946 | 40 |
void MemReporterBase::print_total(size_t reserved, size_t committed) const { |
41 |
const char* scale = current_scale(); |
|
42 |
output()->print("reserved=" SIZE_FORMAT "%s, committed=" SIZE_FORMAT "%s", |
|
43 |
amount_in_current_scale(reserved), scale, amount_in_current_scale(committed), scale); |
|
44 |
} |
|
45 |
||
46489
40abcea5a9d5
8139673: NMT stack traces in output should show mtcomponent
zgu
parents:
25946
diff
changeset
|
46 |
void MemReporterBase::print_malloc(size_t amount, size_t count, MEMFLAGS flag) const { |
25946 | 47 |
const char* scale = current_scale(); |
48 |
outputStream* out = output(); |
|
46489
40abcea5a9d5
8139673: NMT stack traces in output should show mtcomponent
zgu
parents:
25946
diff
changeset
|
49 |
if (flag != mtNone) { |
40abcea5a9d5
8139673: NMT stack traces in output should show mtcomponent
zgu
parents:
25946
diff
changeset
|
50 |
out->print("(malloc=" SIZE_FORMAT "%s type=%s", |
40abcea5a9d5
8139673: NMT stack traces in output should show mtcomponent
zgu
parents:
25946
diff
changeset
|
51 |
amount_in_current_scale(amount), scale, NMTUtil::flag_to_name(flag)); |
40abcea5a9d5
8139673: NMT stack traces in output should show mtcomponent
zgu
parents:
25946
diff
changeset
|
52 |
} else { |
40abcea5a9d5
8139673: NMT stack traces in output should show mtcomponent
zgu
parents:
25946
diff
changeset
|
53 |
out->print("(malloc=" SIZE_FORMAT "%s", |
40abcea5a9d5
8139673: NMT stack traces in output should show mtcomponent
zgu
parents:
25946
diff
changeset
|
54 |
amount_in_current_scale(amount), scale); |
40abcea5a9d5
8139673: NMT stack traces in output should show mtcomponent
zgu
parents:
25946
diff
changeset
|
55 |
} |
25946 | 56 |
|
57 |
if (count > 0) { |
|
58 |
out->print(" #" SIZE_FORMAT "", count); |
|
59 |
} |
|
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
22234
diff
changeset
|
60 |
|
25946 | 61 |
out->print(")"); |
62 |
} |
|
63 |
||
64 |
void MemReporterBase::print_virtual_memory(size_t reserved, size_t committed) const { |
|
65 |
const char* scale = current_scale(); |
|
66 |
output()->print("(mmap: reserved=" SIZE_FORMAT "%s, committed=" SIZE_FORMAT "%s)", |
|
67 |
amount_in_current_scale(reserved), scale, amount_in_current_scale(committed), scale); |
|
68 |
} |
|
69 |
||
70 |
void MemReporterBase::print_malloc_line(size_t amount, size_t count) const { |
|
71 |
output()->print("%28s", " "); |
|
72 |
print_malloc(amount, count); |
|
73 |
output()->print_cr(" "); |
|
74 |
} |
|
75 |
||
76 |
void MemReporterBase::print_virtual_memory_line(size_t reserved, size_t committed) const { |
|
77 |
output()->print("%28s", " "); |
|
78 |
print_virtual_memory(reserved, committed); |
|
79 |
output()->print_cr(" "); |
|
80 |
} |
|
81 |
||
82 |
void MemReporterBase::print_arena_line(size_t amount, size_t count) const { |
|
83 |
const char* scale = current_scale(); |
|
84 |
output()->print_cr("%27s (arena=" SIZE_FORMAT "%s #" SIZE_FORMAT ")", " ", |
|
85 |
amount_in_current_scale(amount), scale, count); |
|
86 |
} |
|
87 |
||
88 |
void MemReporterBase::print_virtual_memory_region(const char* type, address base, size_t size) const { |
|
89 |
const char* scale = current_scale(); |
|
90 |
output()->print("[" PTR_FORMAT " - " PTR_FORMAT "] %s " SIZE_FORMAT "%s", |
|
91 |
p2i(base), p2i(base + size), type, amount_in_current_scale(size), scale); |
|
13195 | 92 |
} |
93 |
||
94 |
||
25946 | 95 |
void MemSummaryReporter::report() { |
96 |
const char* scale = current_scale(); |
|
97 |
outputStream* out = output(); |
|
98 |
size_t total_reserved_amount = _malloc_snapshot->total() + |
|
99 |
_vm_snapshot->total_reserved(); |
|
100 |
size_t total_committed_amount = _malloc_snapshot->total() + |
|
101 |
_vm_snapshot->total_committed(); |
|
13195 | 102 |
|
25946 | 103 |
// Overall total |
104 |
out->print_cr("\nNative Memory Tracking:\n"); |
|
105 |
out->print("Total: "); |
|
106 |
print_total(total_reserved_amount, total_committed_amount); |
|
107 |
out->print("\n"); |
|
13195 | 108 |
|
25946 | 109 |
// Summary by memory type |
110 |
for (int index = 0; index < mt_number_of_types; index ++) { |
|
111 |
MEMFLAGS flag = NMTUtil::index_to_flag(index); |
|
112 |
// thread stack is reported as part of thread category |
|
113 |
if (flag == mtThreadStack) continue; |
|
114 |
MallocMemory* malloc_memory = _malloc_snapshot->by_type(flag); |
|
115 |
VirtualMemory* virtual_memory = _vm_snapshot->by_type(flag); |
|
116 |
||
117 |
report_summary_of_type(flag, malloc_memory, virtual_memory); |
|
14120
7d298141c258
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
13195
diff
changeset
|
118 |
} |
7d298141c258
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
13195
diff
changeset
|
119 |
} |
7d298141c258
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
13195
diff
changeset
|
120 |
|
25946 | 121 |
void MemSummaryReporter::report_summary_of_type(MEMFLAGS flag, |
122 |
MallocMemory* malloc_memory, VirtualMemory* virtual_memory) { |
|
13195 | 123 |
|
25946 | 124 |
size_t reserved_amount = reserved_total (malloc_memory, virtual_memory); |
125 |
size_t committed_amount = committed_total(malloc_memory, virtual_memory); |
|
13195 | 126 |
|
25946 | 127 |
// Count thread's native stack in "Thread" category |
128 |
if (flag == mtThread) { |
|
129 |
const VirtualMemory* thread_stack_usage = |
|
130 |
(const VirtualMemory*)_vm_snapshot->by_type(mtThreadStack); |
|
131 |
reserved_amount += thread_stack_usage->reserved(); |
|
132 |
committed_amount += thread_stack_usage->committed(); |
|
133 |
} else if (flag == mtNMT) { |
|
134 |
// Count malloc headers in "NMT" category |
|
135 |
reserved_amount += _malloc_snapshot->malloc_overhead()->size(); |
|
136 |
committed_amount += _malloc_snapshot->malloc_overhead()->size(); |
|
13195 | 137 |
} |
138 |
||
25946 | 139 |
if (amount_in_current_scale(reserved_amount) > 0) { |
140 |
outputStream* out = output(); |
|
141 |
const char* scale = current_scale(); |
|
142 |
out->print("-%26s (", NMTUtil::flag_to_name(flag)); |
|
143 |
print_total(reserved_amount, committed_amount); |
|
144 |
out->print_cr(")"); |
|
13195 | 145 |
|
25946 | 146 |
if (flag == mtClass) { |
147 |
// report class count |
|
48884
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
148 |
out->print_cr("%27s (classes #" SIZE_FORMAT ")", |
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
149 |
" ", (_instance_class_count + _array_class_count)); |
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
150 |
out->print_cr("%27s ( instance classes #" SIZE_FORMAT ", array classes #" SIZE_FORMAT ")", |
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
151 |
" ", _instance_class_count, _array_class_count); |
25946 | 152 |
} else if (flag == mtThread) { |
153 |
// report thread count |
|
154 |
out->print_cr("%27s (thread #" SIZE_FORMAT ")", " ", _malloc_snapshot->thread_count()); |
|
155 |
const VirtualMemory* thread_stack_usage = |
|
156 |
_vm_snapshot->by_type(mtThreadStack); |
|
157 |
out->print("%27s (stack: ", " "); |
|
158 |
print_total(thread_stack_usage->reserved(), thread_stack_usage->committed()); |
|
159 |
out->print_cr(")"); |
|
160 |
} |
|
13195 | 161 |
|
25946 | 162 |
// report malloc'd memory |
163 |
if (amount_in_current_scale(malloc_memory->malloc_size()) > 0) { |
|
164 |
// We don't know how many arena chunks are in used, so don't report the count |
|
165 |
size_t count = (flag == mtChunk) ? 0 : malloc_memory->malloc_count(); |
|
166 |
print_malloc_line(malloc_memory->malloc_size(), count); |
|
167 |
} |
|
13195 | 168 |
|
25946 | 169 |
if (amount_in_current_scale(virtual_memory->reserved()) > 0) { |
170 |
print_virtual_memory_line(virtual_memory->reserved(), virtual_memory->committed()); |
|
171 |
} |
|
13195 | 172 |
|
25946 | 173 |
if (amount_in_current_scale(malloc_memory->arena_size()) > 0) { |
174 |
print_arena_line(malloc_memory->arena_size(), malloc_memory->arena_count()); |
|
175 |
} |
|
176 |
||
177 |
if (flag == mtNMT && |
|
178 |
amount_in_current_scale(_malloc_snapshot->malloc_overhead()->size()) > 0) { |
|
179 |
out->print_cr("%27s (tracking overhead=" SIZE_FORMAT "%s)", " ", |
|
180 |
amount_in_current_scale(_malloc_snapshot->malloc_overhead()->size()), scale); |
|
47553
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
181 |
} else if (flag == mtClass) { |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
182 |
// Metadata information |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
183 |
report_metadata(Metaspace::NonClassType); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
184 |
if (Metaspace::using_class_space()) { |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
185 |
report_metadata(Metaspace::ClassType); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
186 |
} |
25946 | 187 |
} |
188 |
out->print_cr(" "); |
|
13195 | 189 |
} |
190 |
} |
|
191 |
||
47553
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
192 |
void MemSummaryReporter::report_metadata(Metaspace::MetadataType type) const { |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
193 |
assert(type == Metaspace::NonClassType || type == Metaspace::ClassType, |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
194 |
"Invalid metadata type"); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
195 |
const char* name = (type == Metaspace::NonClassType) ? |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
196 |
"Metadata: " : "Class space:"; |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
197 |
|
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
198 |
outputStream* out = output(); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
199 |
const char* scale = current_scale(); |
49389
9ef2eee8ca7c
8199430: Rename MetaspaceAux to something more meaningful
stuefe
parents:
49033
diff
changeset
|
200 |
size_t committed = MetaspaceUtils::committed_bytes(type); |
9ef2eee8ca7c
8199430: Rename MetaspaceAux to something more meaningful
stuefe
parents:
49033
diff
changeset
|
201 |
size_t used = MetaspaceUtils::used_bytes(type); |
9ef2eee8ca7c
8199430: Rename MetaspaceAux to something more meaningful
stuefe
parents:
49033
diff
changeset
|
202 |
size_t free = (MetaspaceUtils::capacity_bytes(type) - used) |
9ef2eee8ca7c
8199430: Rename MetaspaceAux to something more meaningful
stuefe
parents:
49033
diff
changeset
|
203 |
+ MetaspaceUtils::free_chunks_total_bytes(type) |
9ef2eee8ca7c
8199430: Rename MetaspaceAux to something more meaningful
stuefe
parents:
49033
diff
changeset
|
204 |
+ MetaspaceUtils::free_bytes(type); |
47553
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
205 |
|
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
206 |
assert(committed >= used + free, "Sanity"); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
207 |
size_t waste = committed - (used + free); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
208 |
|
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
209 |
out->print_cr("%27s ( %s)", " ", name); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
210 |
out->print("%27s ( ", " "); |
49389
9ef2eee8ca7c
8199430: Rename MetaspaceAux to something more meaningful
stuefe
parents:
49033
diff
changeset
|
211 |
print_total(MetaspaceUtils::reserved_bytes(type), committed); |
47553
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
212 |
out->print_cr(")"); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
213 |
out->print_cr("%27s ( used=" SIZE_FORMAT "%s)", " ", amount_in_current_scale(used), scale); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
214 |
out->print_cr("%27s ( free=" SIZE_FORMAT "%s)", " ", amount_in_current_scale(free), scale); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
215 |
out->print_cr("%27s ( waste=" SIZE_FORMAT "%s =%2.2f%%)", " ", amount_in_current_scale(waste), |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
216 |
scale, ((float)waste * 100)/committed); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
217 |
} |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
218 |
|
25946 | 219 |
void MemDetailReporter::report_detail() { |
220 |
// Start detail report |
|
221 |
outputStream* out = output(); |
|
222 |
out->print_cr("Details:\n"); |
|
223 |
||
224 |
report_malloc_sites(); |
|
225 |
report_virtual_memory_allocation_sites(); |
|
226 |
} |
|
227 |
||
228 |
void MemDetailReporter::report_malloc_sites() { |
|
229 |
MallocSiteIterator malloc_itr = _baseline.malloc_sites(MemBaseline::by_size); |
|
230 |
if (malloc_itr.is_empty()) return; |
|
231 |
||
232 |
outputStream* out = output(); |
|
13195 | 233 |
|
25946 | 234 |
const MallocSite* malloc_site; |
235 |
while ((malloc_site = malloc_itr.next()) != NULL) { |
|
236 |
// Don't report if size is too small |
|
237 |
if (amount_in_current_scale(malloc_site->size()) == 0) |
|
238 |
continue; |
|
13195 | 239 |
|
25946 | 240 |
const NativeCallStack* stack = malloc_site->call_stack(); |
241 |
stack->print_on(out); |
|
242 |
out->print("%29s", " "); |
|
46489
40abcea5a9d5
8139673: NMT stack traces in output should show mtcomponent
zgu
parents:
25946
diff
changeset
|
243 |
MEMFLAGS flag = malloc_site->flags(); |
40abcea5a9d5
8139673: NMT stack traces in output should show mtcomponent
zgu
parents:
25946
diff
changeset
|
244 |
assert((flag >= 0 && flag < (int)mt_number_of_types) && flag != mtNone, |
40abcea5a9d5
8139673: NMT stack traces in output should show mtcomponent
zgu
parents:
25946
diff
changeset
|
245 |
"Must have a valid memory type"); |
40abcea5a9d5
8139673: NMT stack traces in output should show mtcomponent
zgu
parents:
25946
diff
changeset
|
246 |
print_malloc(malloc_site->size(), malloc_site->count(),flag); |
25946 | 247 |
out->print_cr("\n"); |
248 |
} |
|
249 |
} |
|
250 |
||
251 |
void MemDetailReporter::report_virtual_memory_allocation_sites() { |
|
252 |
VirtualMemorySiteIterator virtual_memory_itr = |
|
253 |
_baseline.virtual_memory_sites(MemBaseline::by_size); |
|
254 |
||
255 |
if (virtual_memory_itr.is_empty()) return; |
|
256 |
||
257 |
outputStream* out = output(); |
|
258 |
const VirtualMemoryAllocationSite* virtual_memory_site; |
|
13195 | 259 |
|
25946 | 260 |
while ((virtual_memory_site = virtual_memory_itr.next()) != NULL) { |
261 |
// Don't report if size is too small |
|
262 |
if (amount_in_current_scale(virtual_memory_site->reserved()) == 0) |
|
263 |
continue; |
|
264 |
||
265 |
const NativeCallStack* stack = virtual_memory_site->call_stack(); |
|
266 |
stack->print_on(out); |
|
267 |
out->print("%28s (", " "); |
|
268 |
print_total(virtual_memory_site->reserved(), virtual_memory_site->committed()); |
|
269 |
out->print_cr(")\n"); |
|
270 |
} |
|
271 |
} |
|
272 |
||
273 |
||
274 |
void MemDetailReporter::report_virtual_memory_map() { |
|
275 |
// Virtual memory map always in base address order |
|
276 |
VirtualMemoryAllocationIterator itr = _baseline.virtual_memory_allocations(); |
|
277 |
const ReservedMemoryRegion* rgn; |
|
278 |
||
279 |
output()->print_cr("Virtual memory map:"); |
|
280 |
while ((rgn = itr.next()) != NULL) { |
|
281 |
report_virtual_memory_region(rgn); |
|
282 |
} |
|
283 |
} |
|
284 |
||
285 |
void MemDetailReporter::report_virtual_memory_region(const ReservedMemoryRegion* reserved_rgn) { |
|
286 |
assert(reserved_rgn != NULL, "NULL pointer"); |
|
287 |
||
288 |
// Don't report if size is too small |
|
289 |
if (amount_in_current_scale(reserved_rgn->size()) == 0) return; |
|
290 |
||
291 |
outputStream* out = output(); |
|
292 |
const char* scale = current_scale(); |
|
293 |
const NativeCallStack* stack = reserved_rgn->call_stack(); |
|
49033
3acc342c0738
8196405: [REDO] NMT: add_committed_regions doesn't merge succeeding regions
stefank
parents:
48884
diff
changeset
|
294 |
bool all_committed = reserved_rgn->size() == reserved_rgn->committed_size(); |
25946 | 295 |
const char* region_type = (all_committed ? "reserved and committed" : "reserved"); |
296 |
out->print_cr(" "); |
|
297 |
print_virtual_memory_region(region_type, reserved_rgn->base(), reserved_rgn->size()); |
|
298 |
out->print(" for %s", NMTUtil::flag_to_name(reserved_rgn->flag())); |
|
299 |
if (stack->is_empty()) { |
|
300 |
out->print_cr(" "); |
|
301 |
} else { |
|
302 |
out->print_cr(" from"); |
|
303 |
stack->print_on(out, 4); |
|
13195 | 304 |
} |
305 |
||
49033
3acc342c0738
8196405: [REDO] NMT: add_committed_regions doesn't merge succeeding regions
stefank
parents:
48884
diff
changeset
|
306 |
if (all_committed) { |
3acc342c0738
8196405: [REDO] NMT: add_committed_regions doesn't merge succeeding regions
stefank
parents:
48884
diff
changeset
|
307 |
CommittedRegionIterator itr = reserved_rgn->iterate_committed_regions(); |
3acc342c0738
8196405: [REDO] NMT: add_committed_regions doesn't merge succeeding regions
stefank
parents:
48884
diff
changeset
|
308 |
const CommittedMemoryRegion* committed_rgn = itr.next(); |
3acc342c0738
8196405: [REDO] NMT: add_committed_regions doesn't merge succeeding regions
stefank
parents:
48884
diff
changeset
|
309 |
if (committed_rgn->size() == reserved_rgn->size() && committed_rgn->call_stack()->equals(*stack)) { |
3acc342c0738
8196405: [REDO] NMT: add_committed_regions doesn't merge succeeding regions
stefank
parents:
48884
diff
changeset
|
310 |
// One region spanning the entire reserved region, with the same stack trace. |
3acc342c0738
8196405: [REDO] NMT: add_committed_regions doesn't merge succeeding regions
stefank
parents:
48884
diff
changeset
|
311 |
// Don't print this regions because the "reserved and committed" line above |
3acc342c0738
8196405: [REDO] NMT: add_committed_regions doesn't merge succeeding regions
stefank
parents:
48884
diff
changeset
|
312 |
// already indicates that the region is comitted. |
3acc342c0738
8196405: [REDO] NMT: add_committed_regions doesn't merge succeeding regions
stefank
parents:
48884
diff
changeset
|
313 |
assert(itr.next() == NULL, "Unexpectedly more than one regions"); |
3acc342c0738
8196405: [REDO] NMT: add_committed_regions doesn't merge succeeding regions
stefank
parents:
48884
diff
changeset
|
314 |
return; |
3acc342c0738
8196405: [REDO] NMT: add_committed_regions doesn't merge succeeding regions
stefank
parents:
48884
diff
changeset
|
315 |
} |
3acc342c0738
8196405: [REDO] NMT: add_committed_regions doesn't merge succeeding regions
stefank
parents:
48884
diff
changeset
|
316 |
} |
13195 | 317 |
|
25946 | 318 |
CommittedRegionIterator itr = reserved_rgn->iterate_committed_regions(); |
319 |
const CommittedMemoryRegion* committed_rgn; |
|
320 |
while ((committed_rgn = itr.next()) != NULL) { |
|
321 |
// Don't report if size is too small |
|
322 |
if (amount_in_current_scale(committed_rgn->size()) == 0) continue; |
|
323 |
stack = committed_rgn->call_stack(); |
|
324 |
out->print("\n\t"); |
|
325 |
print_virtual_memory_region("committed", committed_rgn->base(), committed_rgn->size()); |
|
326 |
if (stack->is_empty()) { |
|
327 |
out->print_cr(" "); |
|
328 |
} else { |
|
329 |
out->print_cr(" from"); |
|
330 |
stack->print_on(out, 12); |
|
13195 | 331 |
} |
332 |
} |
|
333 |
} |
|
334 |
||
25946 | 335 |
void MemSummaryDiffReporter::report_diff() { |
336 |
const char* scale = current_scale(); |
|
337 |
outputStream* out = output(); |
|
338 |
out->print_cr("\nNative Memory Tracking:\n"); |
|
13195 | 339 |
|
25946 | 340 |
// Overall diff |
341 |
out->print("Total: "); |
|
342 |
print_virtual_memory_diff(_current_baseline.total_reserved_memory(), |
|
343 |
_current_baseline.total_committed_memory(), _early_baseline.total_reserved_memory(), |
|
344 |
_early_baseline.total_committed_memory()); |
|
14120
7d298141c258
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
13195
diff
changeset
|
345 |
|
25946 | 346 |
out->print_cr("\n"); |
14120
7d298141c258
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
13195
diff
changeset
|
347 |
|
25946 | 348 |
// Summary diff by memory type |
349 |
for (int index = 0; index < mt_number_of_types; index ++) { |
|
350 |
MEMFLAGS flag = NMTUtil::index_to_flag(index); |
|
351 |
// thread stack is reported as part of thread category |
|
352 |
if (flag == mtThreadStack) continue; |
|
47553
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
353 |
diff_summary_of_type(flag, |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
354 |
_early_baseline.malloc_memory(flag), |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
355 |
_early_baseline.virtual_memory(flag), |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
356 |
_early_baseline.metaspace_snapshot(), |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
357 |
_current_baseline.malloc_memory(flag), |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
358 |
_current_baseline.virtual_memory(flag), |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
359 |
_current_baseline.metaspace_snapshot()); |
14120
7d298141c258
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
13195
diff
changeset
|
360 |
} |
7d298141c258
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
13195
diff
changeset
|
361 |
} |
7d298141c258
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
13195
diff
changeset
|
362 |
|
25946 | 363 |
void MemSummaryDiffReporter::print_malloc_diff(size_t current_amount, size_t current_count, |
46711
0ccef2260315
8184991: NMT detail diff should take memory type into account
zgu
parents:
46489
diff
changeset
|
364 |
size_t early_amount, size_t early_count, MEMFLAGS flags) const { |
25946 | 365 |
const char* scale = current_scale(); |
366 |
outputStream* out = output(); |
|
13195 | 367 |
|
25946 | 368 |
out->print("malloc=" SIZE_FORMAT "%s", amount_in_current_scale(current_amount), scale); |
46711
0ccef2260315
8184991: NMT detail diff should take memory type into account
zgu
parents:
46489
diff
changeset
|
369 |
// Report type only if it is valid |
0ccef2260315
8184991: NMT detail diff should take memory type into account
zgu
parents:
46489
diff
changeset
|
370 |
if (flags != mtNone) { |
0ccef2260315
8184991: NMT detail diff should take memory type into account
zgu
parents:
46489
diff
changeset
|
371 |
out->print(" type=%s", NMTUtil::flag_to_name(flags)); |
0ccef2260315
8184991: NMT detail diff should take memory type into account
zgu
parents:
46489
diff
changeset
|
372 |
} |
0ccef2260315
8184991: NMT detail diff should take memory type into account
zgu
parents:
46489
diff
changeset
|
373 |
|
25946 | 374 |
long amount_diff = diff_in_current_scale(current_amount, early_amount); |
375 |
if (amount_diff != 0) { |
|
376 |
out->print(" %+ld%s", amount_diff, scale); |
|
377 |
} |
|
378 |
if (current_count > 0) { |
|
379 |
out->print(" #" SIZE_FORMAT "", current_count); |
|
380 |
if (current_count != early_count) { |
|
381 |
out->print(" %+d", (int)(current_count - early_count)); |
|
13195 | 382 |
} |
383 |
} |
|
384 |
} |
|
385 |
||
25946 | 386 |
void MemSummaryDiffReporter::print_arena_diff(size_t current_amount, size_t current_count, |
387 |
size_t early_amount, size_t early_count) const { |
|
388 |
const char* scale = current_scale(); |
|
389 |
outputStream* out = output(); |
|
390 |
out->print("arena=" SIZE_FORMAT "%s", amount_in_current_scale(current_amount), scale); |
|
391 |
if (diff_in_current_scale(current_amount, early_amount) != 0) { |
|
392 |
out->print(" %+ld", diff_in_current_scale(current_amount, early_amount)); |
|
393 |
} |
|
394 |
||
395 |
out->print(" #" SIZE_FORMAT "", current_count); |
|
396 |
if (current_count != early_count) { |
|
397 |
out->print(" %+d", (int)(current_count - early_count)); |
|
398 |
} |
|
399 |
} |
|
13195 | 400 |
|
25946 | 401 |
void MemSummaryDiffReporter::print_virtual_memory_diff(size_t current_reserved, size_t current_committed, |
402 |
size_t early_reserved, size_t early_committed) const { |
|
403 |
const char* scale = current_scale(); |
|
404 |
outputStream* out = output(); |
|
405 |
out->print("reserved=" SIZE_FORMAT "%s", amount_in_current_scale(current_reserved), scale); |
|
406 |
long reserved_diff = diff_in_current_scale(current_reserved, early_reserved); |
|
407 |
if (reserved_diff != 0) { |
|
408 |
out->print(" %+ld%s", reserved_diff, scale); |
|
409 |
} |
|
410 |
||
411 |
out->print(", committed=" SIZE_FORMAT "%s", amount_in_current_scale(current_committed), scale); |
|
412 |
long committed_diff = diff_in_current_scale(current_committed, early_committed); |
|
413 |
if (committed_diff != 0) { |
|
414 |
out->print(" %+ld%s", committed_diff, scale); |
|
13195 | 415 |
} |
416 |
} |
|
417 |
||
25946 | 418 |
|
47553
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
419 |
void MemSummaryDiffReporter::diff_summary_of_type(MEMFLAGS flag, |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
420 |
const MallocMemory* early_malloc, const VirtualMemory* early_vm, |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
421 |
const MetaspaceSnapshot* early_ms, |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
422 |
const MallocMemory* current_malloc, const VirtualMemory* current_vm, |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
423 |
const MetaspaceSnapshot* current_ms) const { |
25946 | 424 |
|
425 |
outputStream* out = output(); |
|
426 |
const char* scale = current_scale(); |
|
427 |
||
428 |
// Total reserved and committed memory in current baseline |
|
429 |
size_t current_reserved_amount = reserved_total (current_malloc, current_vm); |
|
430 |
size_t current_committed_amount = committed_total(current_malloc, current_vm); |
|
431 |
||
432 |
// Total reserved and committed memory in early baseline |
|
433 |
size_t early_reserved_amount = reserved_total(early_malloc, early_vm); |
|
434 |
size_t early_committed_amount = committed_total(early_malloc, early_vm); |
|
13195 | 435 |
|
25946 | 436 |
// Adjust virtual memory total |
437 |
if (flag == mtThread) { |
|
438 |
const VirtualMemory* early_thread_stack_usage = |
|
439 |
_early_baseline.virtual_memory(mtThreadStack); |
|
440 |
const VirtualMemory* current_thread_stack_usage = |
|
441 |
_current_baseline.virtual_memory(mtThreadStack); |
|
442 |
||
443 |
early_reserved_amount += early_thread_stack_usage->reserved(); |
|
444 |
early_committed_amount += early_thread_stack_usage->committed(); |
|
445 |
||
446 |
current_reserved_amount += current_thread_stack_usage->reserved(); |
|
447 |
current_committed_amount += current_thread_stack_usage->committed(); |
|
448 |
} else if (flag == mtNMT) { |
|
449 |
early_reserved_amount += _early_baseline.malloc_tracking_overhead(); |
|
450 |
early_committed_amount += _early_baseline.malloc_tracking_overhead(); |
|
451 |
||
452 |
current_reserved_amount += _current_baseline.malloc_tracking_overhead(); |
|
453 |
current_committed_amount += _current_baseline.malloc_tracking_overhead(); |
|
454 |
} |
|
13195 | 455 |
|
25946 | 456 |
if (amount_in_current_scale(current_reserved_amount) > 0 || |
457 |
diff_in_current_scale(current_reserved_amount, early_reserved_amount) != 0) { |
|
458 |
||
459 |
// print summary line |
|
460 |
out->print("-%26s (", NMTUtil::flag_to_name(flag)); |
|
461 |
print_virtual_memory_diff(current_reserved_amount, current_committed_amount, |
|
462 |
early_reserved_amount, early_committed_amount); |
|
463 |
out->print_cr(")"); |
|
13195 | 464 |
|
25946 | 465 |
// detail lines |
466 |
if (flag == mtClass) { |
|
467 |
// report class count |
|
468 |
out->print("%27s (classes #" SIZE_FORMAT "", " ", _current_baseline.class_count()); |
|
469 |
int class_count_diff = (int)(_current_baseline.class_count() - |
|
470 |
_early_baseline.class_count()); |
|
471 |
if (_current_baseline.class_count() != _early_baseline.class_count()) { |
|
472 |
out->print(" %+d", (int)(_current_baseline.class_count() - _early_baseline.class_count())); |
|
473 |
} |
|
474 |
out->print_cr(")"); |
|
48884
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
475 |
|
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
476 |
out->print("%27s ( instance classes #" SIZE_FORMAT, " ", _current_baseline.instance_class_count()); |
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
477 |
if (_current_baseline.instance_class_count() != _early_baseline.instance_class_count()) { |
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
478 |
out->print(" %+d", (int)(_current_baseline.instance_class_count() - _early_baseline.instance_class_count())); |
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
479 |
} |
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
480 |
out->print(", array classes #" SIZE_FORMAT, _current_baseline.array_class_count()); |
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
481 |
if (_current_baseline.array_class_count() != _early_baseline.array_class_count()) { |
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
482 |
out->print(" %+d", (int)(_current_baseline.array_class_count() - _early_baseline.array_class_count())); |
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
483 |
} |
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
484 |
out->print_cr(")"); |
7e17b00dc245
8196923: [REDO] NMT: Report array class count in NMT summary
zgu
parents:
48874
diff
changeset
|
485 |
|
25946 | 486 |
} else if (flag == mtThread) { |
487 |
// report thread count |
|
488 |
out->print("%27s (thread #" SIZE_FORMAT "", " ", _current_baseline.thread_count()); |
|
489 |
int thread_count_diff = (int)(_current_baseline.thread_count() - |
|
490 |
_early_baseline.thread_count()); |
|
491 |
if (thread_count_diff != 0) { |
|
492 |
out->print(" %+d", thread_count_diff); |
|
493 |
} |
|
494 |
out->print_cr(")"); |
|
13195 | 495 |
|
25946 | 496 |
// report thread stack |
497 |
const VirtualMemory* current_thread_stack = |
|
498 |
_current_baseline.virtual_memory(mtThreadStack); |
|
499 |
const VirtualMemory* early_thread_stack = |
|
500 |
_early_baseline.virtual_memory(mtThreadStack); |
|
13195 | 501 |
|
25946 | 502 |
out->print("%27s (stack: ", " "); |
503 |
print_virtual_memory_diff(current_thread_stack->reserved(), current_thread_stack->committed(), |
|
504 |
early_thread_stack->reserved(), early_thread_stack->committed()); |
|
505 |
out->print_cr(")"); |
|
13195 | 506 |
} |
507 |
||
25946 | 508 |
// Report malloc'd memory |
509 |
size_t current_malloc_amount = current_malloc->malloc_size(); |
|
510 |
size_t early_malloc_amount = early_malloc->malloc_size(); |
|
511 |
if (amount_in_current_scale(current_malloc_amount) > 0 || |
|
512 |
diff_in_current_scale(current_malloc_amount, early_malloc_amount) != 0) { |
|
513 |
out->print("%28s(", " "); |
|
514 |
print_malloc_diff(current_malloc_amount, (flag == mtChunk) ? 0 : current_malloc->malloc_count(), |
|
46711
0ccef2260315
8184991: NMT detail diff should take memory type into account
zgu
parents:
46489
diff
changeset
|
515 |
early_malloc_amount, early_malloc->malloc_count(), mtNone); |
25946 | 516 |
out->print_cr(")"); |
517 |
} |
|
13195 | 518 |
|
25946 | 519 |
// Report virtual memory |
520 |
if (amount_in_current_scale(current_vm->reserved()) > 0 || |
|
521 |
diff_in_current_scale(current_vm->reserved(), early_vm->reserved()) != 0) { |
|
522 |
out->print("%27s (mmap: ", " "); |
|
523 |
print_virtual_memory_diff(current_vm->reserved(), current_vm->committed(), |
|
524 |
early_vm->reserved(), early_vm->committed()); |
|
525 |
out->print_cr(")"); |
|
13195 | 526 |
} |
527 |
||
25946 | 528 |
// Report arena memory |
529 |
if (amount_in_current_scale(current_malloc->arena_size()) > 0 || |
|
530 |
diff_in_current_scale(current_malloc->arena_size(), early_malloc->arena_size()) != 0) { |
|
531 |
out->print("%28s(", " "); |
|
532 |
print_arena_diff(current_malloc->arena_size(), current_malloc->arena_count(), |
|
533 |
early_malloc->arena_size(), early_malloc->arena_count()); |
|
534 |
out->print_cr(")"); |
|
13195 | 535 |
} |
536 |
||
25946 | 537 |
// Report native memory tracking overhead |
538 |
if (flag == mtNMT) { |
|
539 |
size_t current_tracking_overhead = amount_in_current_scale(_current_baseline.malloc_tracking_overhead()); |
|
540 |
size_t early_tracking_overhead = amount_in_current_scale(_early_baseline.malloc_tracking_overhead()); |
|
13195 | 541 |
|
25946 | 542 |
out->print("%27s (tracking overhead=" SIZE_FORMAT "%s", " ", |
543 |
amount_in_current_scale(_current_baseline.malloc_tracking_overhead()), scale); |
|
13195 | 544 |
|
25946 | 545 |
long overhead_diff = diff_in_current_scale(_current_baseline.malloc_tracking_overhead(), |
546 |
_early_baseline.malloc_tracking_overhead()); |
|
547 |
if (overhead_diff != 0) { |
|
548 |
out->print(" %+ld%s", overhead_diff, scale); |
|
13195 | 549 |
} |
25946 | 550 |
out->print_cr(")"); |
47553
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
551 |
} else if (flag == mtClass) { |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
552 |
assert(current_ms != NULL && early_ms != NULL, "Sanity"); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
553 |
print_metaspace_diff(current_ms, early_ms); |
13195 | 554 |
} |
25946 | 555 |
out->print_cr(" "); |
13195 | 556 |
} |
557 |
} |
|
558 |
||
47553
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
559 |
void MemSummaryDiffReporter::print_metaspace_diff(const MetaspaceSnapshot* current_ms, |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
560 |
const MetaspaceSnapshot* early_ms) const { |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
561 |
print_metaspace_diff(Metaspace::NonClassType, current_ms, early_ms); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
562 |
if (Metaspace::using_class_space()) { |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
563 |
print_metaspace_diff(Metaspace::ClassType, current_ms, early_ms); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
564 |
} |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
565 |
} |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
566 |
|
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
567 |
void MemSummaryDiffReporter::print_metaspace_diff(Metaspace::MetadataType type, |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
568 |
const MetaspaceSnapshot* current_ms, |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
569 |
const MetaspaceSnapshot* early_ms) const { |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
570 |
const char* name = (type == Metaspace::NonClassType) ? |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
571 |
"Metadata: " : "Class space:"; |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
572 |
|
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
573 |
outputStream* out = output(); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
574 |
const char* scale = current_scale(); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
575 |
|
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
576 |
out->print_cr("%27s ( %s)", " ", name); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
577 |
out->print("%27s ( ", " "); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
578 |
print_virtual_memory_diff(current_ms->reserved_in_bytes(type), |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
579 |
current_ms->committed_in_bytes(type), |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
580 |
early_ms->reserved_in_bytes(type), |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
581 |
early_ms->committed_in_bytes(type)); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
582 |
out->print_cr(")"); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
583 |
|
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
584 |
long diff_used = diff_in_current_scale(current_ms->used_in_bytes(type), |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
585 |
early_ms->used_in_bytes(type)); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
586 |
long diff_free = diff_in_current_scale(current_ms->free_in_bytes(type), |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
587 |
early_ms->free_in_bytes(type)); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
588 |
|
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
589 |
size_t current_waste = current_ms->committed_in_bytes(type) |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
590 |
- (current_ms->used_in_bytes(type) + current_ms->free_in_bytes(type)); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
591 |
size_t early_waste = early_ms->committed_in_bytes(type) |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
592 |
- (early_ms->used_in_bytes(type) + early_ms->free_in_bytes(type)); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
593 |
long diff_waste = diff_in_current_scale(current_waste, early_waste); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
594 |
|
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
595 |
// Diff used |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
596 |
out->print("%27s ( used=" SIZE_FORMAT "%s", " ", |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
597 |
amount_in_current_scale(current_ms->used_in_bytes(type)), scale); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
598 |
if (diff_used != 0) { |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
599 |
out->print(" %+ld%s", diff_used, scale); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
600 |
} |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
601 |
out->print_cr(")"); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
602 |
|
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
603 |
// Diff free |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
604 |
out->print("%27s ( free=" SIZE_FORMAT "%s", " ", |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
605 |
amount_in_current_scale(current_ms->free_in_bytes(type)), scale); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
606 |
if (diff_free != 0) { |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
607 |
out->print(" %+ld%s", diff_free, scale); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
608 |
} |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
609 |
out->print_cr(")"); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
610 |
|
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
611 |
|
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
612 |
// Diff waste |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
613 |
out->print("%27s ( waste=" SIZE_FORMAT "%s =%2.2f%%", " ", |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
614 |
amount_in_current_scale(current_waste), scale, |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
615 |
((float)current_waste * 100) / current_ms->committed_in_bytes(type)); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
616 |
if (diff_waste != 0) { |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
617 |
out->print(" %+ld%s", diff_waste, scale); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
618 |
} |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
619 |
out->print_cr(")"); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
620 |
} |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
621 |
|
25946 | 622 |
void MemDetailDiffReporter::report_diff() { |
623 |
MemSummaryDiffReporter::report_diff(); |
|
624 |
diff_malloc_sites(); |
|
625 |
diff_virtual_memory_sites(); |
|
626 |
} |
|
627 |
||
628 |
void MemDetailDiffReporter::diff_malloc_sites() const { |
|
46711
0ccef2260315
8184991: NMT detail diff should take memory type into account
zgu
parents:
46489
diff
changeset
|
629 |
MallocSiteIterator early_itr = _early_baseline.malloc_sites(MemBaseline::by_site_and_type); |
0ccef2260315
8184991: NMT detail diff should take memory type into account
zgu
parents:
46489
diff
changeset
|
630 |
MallocSiteIterator current_itr = _current_baseline.malloc_sites(MemBaseline::by_site_and_type); |
25946 | 631 |
|
632 |
const MallocSite* early_site = early_itr.next(); |
|
633 |
const MallocSite* current_site = current_itr.next(); |
|
634 |
||
635 |
while (early_site != NULL || current_site != NULL) { |
|
636 |
if (early_site == NULL) { |
|
637 |
new_malloc_site(current_site); |
|
638 |
current_site = current_itr.next(); |
|
639 |
} else if (current_site == NULL) { |
|
640 |
old_malloc_site(early_site); |
|
641 |
early_site = early_itr.next(); |
|
13195 | 642 |
} else { |
25946 | 643 |
int compVal = current_site->call_stack()->compare(*early_site->call_stack()); |
644 |
if (compVal < 0) { |
|
645 |
new_malloc_site(current_site); |
|
646 |
current_site = current_itr.next(); |
|
647 |
} else if (compVal > 0) { |
|
648 |
old_malloc_site(early_site); |
|
649 |
early_site = early_itr.next(); |
|
13195 | 650 |
} else { |
25946 | 651 |
diff_malloc_site(early_site, current_site); |
652 |
early_site = early_itr.next(); |
|
653 |
current_site = current_itr.next(); |
|
13195 | 654 |
} |
655 |
} |
|
25946 | 656 |
} |
657 |
} |
|
13195 | 658 |
|
25946 | 659 |
void MemDetailDiffReporter::diff_virtual_memory_sites() const { |
660 |
VirtualMemorySiteIterator early_itr = _early_baseline.virtual_memory_sites(MemBaseline::by_site); |
|
661 |
VirtualMemorySiteIterator current_itr = _current_baseline.virtual_memory_sites(MemBaseline::by_site); |
|
662 |
||
663 |
const VirtualMemoryAllocationSite* early_site = early_itr.next(); |
|
664 |
const VirtualMemoryAllocationSite* current_site = current_itr.next(); |
|
665 |
||
666 |
while (early_site != NULL || current_site != NULL) { |
|
667 |
if (early_site == NULL) { |
|
668 |
new_virtual_memory_site(current_site); |
|
669 |
current_site = current_itr.next(); |
|
670 |
} else if (current_site == NULL) { |
|
671 |
old_virtual_memory_site(early_site); |
|
672 |
early_site = early_itr.next(); |
|
673 |
} else { |
|
674 |
int compVal = current_site->call_stack()->compare(*early_site->call_stack()); |
|
675 |
if (compVal < 0) { |
|
676 |
new_virtual_memory_site(current_site); |
|
677 |
current_site = current_itr.next(); |
|
678 |
} else if (compVal > 0) { |
|
679 |
old_virtual_memory_site(early_site); |
|
680 |
early_site = early_itr.next(); |
|
681 |
} else { |
|
682 |
diff_virtual_memory_site(early_site, current_site); |
|
683 |
early_site = early_itr.next(); |
|
684 |
current_site = current_itr.next(); |
|
685 |
} |
|
13195 | 686 |
} |
687 |
} |
|
688 |
} |
|
689 |
||
25946 | 690 |
|
691 |
void MemDetailDiffReporter::new_malloc_site(const MallocSite* malloc_site) const { |
|
692 |
diff_malloc_site(malloc_site->call_stack(), malloc_site->size(), malloc_site->count(), |
|
46711
0ccef2260315
8184991: NMT detail diff should take memory type into account
zgu
parents:
46489
diff
changeset
|
693 |
0, 0, malloc_site->flags()); |
25946 | 694 |
} |
695 |
||
696 |
void MemDetailDiffReporter::old_malloc_site(const MallocSite* malloc_site) const { |
|
697 |
diff_malloc_site(malloc_site->call_stack(), 0, 0, malloc_site->size(), |
|
46711
0ccef2260315
8184991: NMT detail diff should take memory type into account
zgu
parents:
46489
diff
changeset
|
698 |
malloc_site->count(), malloc_site->flags()); |
25946 | 699 |
} |
700 |
||
701 |
void MemDetailDiffReporter::diff_malloc_site(const MallocSite* early, |
|
702 |
const MallocSite* current) const { |
|
46711
0ccef2260315
8184991: NMT detail diff should take memory type into account
zgu
parents:
46489
diff
changeset
|
703 |
assert(early->flags() == current->flags(), "Must be the same memory type"); |
25946 | 704 |
diff_malloc_site(current->call_stack(), current->size(), current->count(), |
46711
0ccef2260315
8184991: NMT detail diff should take memory type into account
zgu
parents:
46489
diff
changeset
|
705 |
early->size(), early->count(), early->flags()); |
25946 | 706 |
} |
707 |
||
708 |
void MemDetailDiffReporter::diff_malloc_site(const NativeCallStack* stack, size_t current_size, |
|
46711
0ccef2260315
8184991: NMT detail diff should take memory type into account
zgu
parents:
46489
diff
changeset
|
709 |
size_t current_count, size_t early_size, size_t early_count, MEMFLAGS flags) const { |
25946 | 710 |
outputStream* out = output(); |
711 |
||
712 |
assert(stack != NULL, "NULL stack"); |
|
713 |
||
714 |
if (diff_in_current_scale(current_size, early_size) == 0) { |
|
715 |
return; |
|
716 |
} |
|
717 |
||
718 |
stack->print_on(out); |
|
719 |
out->print("%28s (", " "); |
|
720 |
print_malloc_diff(current_size, current_count, |
|
46711
0ccef2260315
8184991: NMT detail diff should take memory type into account
zgu
parents:
46489
diff
changeset
|
721 |
early_size, early_count, flags); |
13195 | 722 |
|
25946 | 723 |
out->print_cr(")\n"); |
724 |
} |
|
725 |
||
726 |
||
727 |
void MemDetailDiffReporter::new_virtual_memory_site(const VirtualMemoryAllocationSite* site) const { |
|
728 |
diff_virtual_memory_site(site->call_stack(), site->reserved(), site->committed(), 0, 0); |
|
729 |
} |
|
730 |
||
731 |
void MemDetailDiffReporter::old_virtual_memory_site(const VirtualMemoryAllocationSite* site) const { |
|
732 |
diff_virtual_memory_site(site->call_stack(), 0, 0, site->reserved(), site->committed()); |
|
733 |
} |
|
734 |
||
735 |
void MemDetailDiffReporter::diff_virtual_memory_site(const VirtualMemoryAllocationSite* early, |
|
736 |
const VirtualMemoryAllocationSite* current) const { |
|
737 |
diff_virtual_memory_site(current->call_stack(), current->reserved(), current->committed(), |
|
738 |
early->reserved(), early->committed()); |
|
739 |
} |
|
740 |
||
741 |
void MemDetailDiffReporter::diff_virtual_memory_site(const NativeCallStack* stack, size_t current_reserved, |
|
742 |
size_t current_committed, size_t early_reserved, size_t early_committed) const { |
|
743 |
outputStream* out = output(); |
|
744 |
||
745 |
// no change |
|
746 |
if (diff_in_current_scale(current_reserved, early_reserved) == 0 && |
|
747 |
diff_in_current_scale(current_committed, early_committed) == 0) { |
|
748 |
return; |
|
13195 | 749 |
} |
25946 | 750 |
|
751 |
stack->print_on(out); |
|
752 |
out->print("%28s (mmap: ", " "); |
|
753 |
print_virtual_memory_diff(current_reserved, current_committed, |
|
754 |
early_reserved, early_committed); |
|
755 |
||
756 |
out->print_cr(")\n"); |
|
757 |
} |