author | zgu |
Thu, 28 Sep 2017 09:56:54 -0400 | |
changeset 47553 | 5d20359dd938 |
parent 47216 | 71c04702a3d5 |
child 48873 | 9536c39ac6de |
permissions | -rw-r--r-- |
13195 | 1 |
/* |
46489
40abcea5a9d5
8139673: NMT stack traces in output should show mtcomponent
zgu
parents:
25946
diff
changeset
|
2 |
* Copyright (c) 2012, 2017, 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 |
|
148 |
out->print_cr("%27s (classes #" SIZE_FORMAT ")", " ", _class_count); |
|
149 |
} else if (flag == mtThread) { |
|
150 |
// report thread count |
|
151 |
out->print_cr("%27s (thread #" SIZE_FORMAT ")", " ", _malloc_snapshot->thread_count()); |
|
152 |
const VirtualMemory* thread_stack_usage = |
|
153 |
_vm_snapshot->by_type(mtThreadStack); |
|
154 |
out->print("%27s (stack: ", " "); |
|
155 |
print_total(thread_stack_usage->reserved(), thread_stack_usage->committed()); |
|
156 |
out->print_cr(")"); |
|
157 |
} |
|
13195 | 158 |
|
25946 | 159 |
// report malloc'd memory |
160 |
if (amount_in_current_scale(malloc_memory->malloc_size()) > 0) { |
|
161 |
// We don't know how many arena chunks are in used, so don't report the count |
|
162 |
size_t count = (flag == mtChunk) ? 0 : malloc_memory->malloc_count(); |
|
163 |
print_malloc_line(malloc_memory->malloc_size(), count); |
|
164 |
} |
|
13195 | 165 |
|
25946 | 166 |
if (amount_in_current_scale(virtual_memory->reserved()) > 0) { |
167 |
print_virtual_memory_line(virtual_memory->reserved(), virtual_memory->committed()); |
|
168 |
} |
|
13195 | 169 |
|
25946 | 170 |
if (amount_in_current_scale(malloc_memory->arena_size()) > 0) { |
171 |
print_arena_line(malloc_memory->arena_size(), malloc_memory->arena_count()); |
|
172 |
} |
|
173 |
||
174 |
if (flag == mtNMT && |
|
175 |
amount_in_current_scale(_malloc_snapshot->malloc_overhead()->size()) > 0) { |
|
176 |
out->print_cr("%27s (tracking overhead=" SIZE_FORMAT "%s)", " ", |
|
177 |
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
|
178 |
} else if (flag == mtClass) { |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
179 |
// Metadata information |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
180 |
report_metadata(Metaspace::NonClassType); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
181 |
if (Metaspace::using_class_space()) { |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
182 |
report_metadata(Metaspace::ClassType); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
183 |
} |
25946 | 184 |
} |
185 |
out->print_cr(" "); |
|
13195 | 186 |
} |
187 |
} |
|
188 |
||
47553
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
189 |
void MemSummaryReporter::report_metadata(Metaspace::MetadataType type) const { |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
190 |
assert(type == Metaspace::NonClassType || type == Metaspace::ClassType, |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
191 |
"Invalid metadata type"); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
192 |
const char* name = (type == Metaspace::NonClassType) ? |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
193 |
"Metadata: " : "Class space:"; |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
194 |
|
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
195 |
outputStream* out = output(); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
196 |
const char* scale = current_scale(); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
197 |
size_t committed = MetaspaceAux::committed_bytes(type); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
198 |
size_t used = MetaspaceAux::used_bytes(type); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
199 |
size_t free = (MetaspaceAux::capacity_bytes(type) - used) |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
200 |
+ MetaspaceAux::free_chunks_total_bytes(type) |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
201 |
+ MetaspaceAux::free_bytes(type); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
202 |
|
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
203 |
assert(committed >= used + free, "Sanity"); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
204 |
size_t waste = committed - (used + free); |
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 |
out->print_cr("%27s ( %s)", " ", name); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
207 |
out->print("%27s ( ", " "); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
208 |
print_total(MetaspaceAux::reserved_bytes(type), committed); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
209 |
out->print_cr(")"); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
210 |
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
|
211 |
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
|
212 |
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
|
213 |
scale, ((float)waste * 100)/committed); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
214 |
} |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
215 |
|
25946 | 216 |
void MemDetailReporter::report_detail() { |
217 |
// Start detail report |
|
218 |
outputStream* out = output(); |
|
219 |
out->print_cr("Details:\n"); |
|
220 |
||
221 |
report_malloc_sites(); |
|
222 |
report_virtual_memory_allocation_sites(); |
|
223 |
} |
|
224 |
||
225 |
void MemDetailReporter::report_malloc_sites() { |
|
226 |
MallocSiteIterator malloc_itr = _baseline.malloc_sites(MemBaseline::by_size); |
|
227 |
if (malloc_itr.is_empty()) return; |
|
228 |
||
229 |
outputStream* out = output(); |
|
13195 | 230 |
|
25946 | 231 |
const MallocSite* malloc_site; |
232 |
while ((malloc_site = malloc_itr.next()) != NULL) { |
|
233 |
// Don't report if size is too small |
|
234 |
if (amount_in_current_scale(malloc_site->size()) == 0) |
|
235 |
continue; |
|
13195 | 236 |
|
25946 | 237 |
const NativeCallStack* stack = malloc_site->call_stack(); |
238 |
stack->print_on(out); |
|
239 |
out->print("%29s", " "); |
|
46489
40abcea5a9d5
8139673: NMT stack traces in output should show mtcomponent
zgu
parents:
25946
diff
changeset
|
240 |
MEMFLAGS flag = malloc_site->flags(); |
40abcea5a9d5
8139673: NMT stack traces in output should show mtcomponent
zgu
parents:
25946
diff
changeset
|
241 |
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
|
242 |
"Must have a valid memory type"); |
40abcea5a9d5
8139673: NMT stack traces in output should show mtcomponent
zgu
parents:
25946
diff
changeset
|
243 |
print_malloc(malloc_site->size(), malloc_site->count(),flag); |
25946 | 244 |
out->print_cr("\n"); |
245 |
} |
|
246 |
} |
|
247 |
||
248 |
void MemDetailReporter::report_virtual_memory_allocation_sites() { |
|
249 |
VirtualMemorySiteIterator virtual_memory_itr = |
|
250 |
_baseline.virtual_memory_sites(MemBaseline::by_size); |
|
251 |
||
252 |
if (virtual_memory_itr.is_empty()) return; |
|
253 |
||
254 |
outputStream* out = output(); |
|
255 |
const VirtualMemoryAllocationSite* virtual_memory_site; |
|
13195 | 256 |
|
25946 | 257 |
while ((virtual_memory_site = virtual_memory_itr.next()) != NULL) { |
258 |
// Don't report if size is too small |
|
259 |
if (amount_in_current_scale(virtual_memory_site->reserved()) == 0) |
|
260 |
continue; |
|
261 |
||
262 |
const NativeCallStack* stack = virtual_memory_site->call_stack(); |
|
263 |
stack->print_on(out); |
|
264 |
out->print("%28s (", " "); |
|
265 |
print_total(virtual_memory_site->reserved(), virtual_memory_site->committed()); |
|
266 |
out->print_cr(")\n"); |
|
267 |
} |
|
268 |
} |
|
269 |
||
270 |
||
271 |
void MemDetailReporter::report_virtual_memory_map() { |
|
272 |
// Virtual memory map always in base address order |
|
273 |
VirtualMemoryAllocationIterator itr = _baseline.virtual_memory_allocations(); |
|
274 |
const ReservedMemoryRegion* rgn; |
|
275 |
||
276 |
output()->print_cr("Virtual memory map:"); |
|
277 |
while ((rgn = itr.next()) != NULL) { |
|
278 |
report_virtual_memory_region(rgn); |
|
279 |
} |
|
280 |
} |
|
281 |
||
282 |
void MemDetailReporter::report_virtual_memory_region(const ReservedMemoryRegion* reserved_rgn) { |
|
283 |
assert(reserved_rgn != NULL, "NULL pointer"); |
|
284 |
||
285 |
// Don't report if size is too small |
|
286 |
if (amount_in_current_scale(reserved_rgn->size()) == 0) return; |
|
287 |
||
288 |
outputStream* out = output(); |
|
289 |
const char* scale = current_scale(); |
|
290 |
const NativeCallStack* stack = reserved_rgn->call_stack(); |
|
291 |
bool all_committed = reserved_rgn->all_committed(); |
|
292 |
const char* region_type = (all_committed ? "reserved and committed" : "reserved"); |
|
293 |
out->print_cr(" "); |
|
294 |
print_virtual_memory_region(region_type, reserved_rgn->base(), reserved_rgn->size()); |
|
295 |
out->print(" for %s", NMTUtil::flag_to_name(reserved_rgn->flag())); |
|
296 |
if (stack->is_empty()) { |
|
297 |
out->print_cr(" "); |
|
298 |
} else { |
|
299 |
out->print_cr(" from"); |
|
300 |
stack->print_on(out, 4); |
|
13195 | 301 |
} |
302 |
||
25946 | 303 |
if (all_committed) return; |
13195 | 304 |
|
25946 | 305 |
CommittedRegionIterator itr = reserved_rgn->iterate_committed_regions(); |
306 |
const CommittedMemoryRegion* committed_rgn; |
|
307 |
while ((committed_rgn = itr.next()) != NULL) { |
|
308 |
// Don't report if size is too small |
|
309 |
if (amount_in_current_scale(committed_rgn->size()) == 0) continue; |
|
310 |
stack = committed_rgn->call_stack(); |
|
311 |
out->print("\n\t"); |
|
312 |
print_virtual_memory_region("committed", committed_rgn->base(), committed_rgn->size()); |
|
313 |
if (stack->is_empty()) { |
|
314 |
out->print_cr(" "); |
|
315 |
} else { |
|
316 |
out->print_cr(" from"); |
|
317 |
stack->print_on(out, 12); |
|
13195 | 318 |
} |
319 |
} |
|
320 |
} |
|
321 |
||
25946 | 322 |
void MemSummaryDiffReporter::report_diff() { |
323 |
const char* scale = current_scale(); |
|
324 |
outputStream* out = output(); |
|
325 |
out->print_cr("\nNative Memory Tracking:\n"); |
|
13195 | 326 |
|
25946 | 327 |
// Overall diff |
328 |
out->print("Total: "); |
|
329 |
print_virtual_memory_diff(_current_baseline.total_reserved_memory(), |
|
330 |
_current_baseline.total_committed_memory(), _early_baseline.total_reserved_memory(), |
|
331 |
_early_baseline.total_committed_memory()); |
|
14120
7d298141c258
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
13195
diff
changeset
|
332 |
|
25946 | 333 |
out->print_cr("\n"); |
14120
7d298141c258
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
13195
diff
changeset
|
334 |
|
25946 | 335 |
// Summary diff by memory type |
336 |
for (int index = 0; index < mt_number_of_types; index ++) { |
|
337 |
MEMFLAGS flag = NMTUtil::index_to_flag(index); |
|
338 |
// thread stack is reported as part of thread category |
|
339 |
if (flag == mtThreadStack) continue; |
|
47553
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
340 |
diff_summary_of_type(flag, |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
341 |
_early_baseline.malloc_memory(flag), |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
342 |
_early_baseline.virtual_memory(flag), |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
343 |
_early_baseline.metaspace_snapshot(), |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
344 |
_current_baseline.malloc_memory(flag), |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
345 |
_current_baseline.virtual_memory(flag), |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
346 |
_current_baseline.metaspace_snapshot()); |
14120
7d298141c258
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
13195
diff
changeset
|
347 |
} |
7d298141c258
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
13195
diff
changeset
|
348 |
} |
7d298141c258
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
13195
diff
changeset
|
349 |
|
25946 | 350 |
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
|
351 |
size_t early_amount, size_t early_count, MEMFLAGS flags) const { |
25946 | 352 |
const char* scale = current_scale(); |
353 |
outputStream* out = output(); |
|
13195 | 354 |
|
25946 | 355 |
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
|
356 |
// Report type only if it is valid |
0ccef2260315
8184991: NMT detail diff should take memory type into account
zgu
parents:
46489
diff
changeset
|
357 |
if (flags != mtNone) { |
0ccef2260315
8184991: NMT detail diff should take memory type into account
zgu
parents:
46489
diff
changeset
|
358 |
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
|
359 |
} |
0ccef2260315
8184991: NMT detail diff should take memory type into account
zgu
parents:
46489
diff
changeset
|
360 |
|
25946 | 361 |
long amount_diff = diff_in_current_scale(current_amount, early_amount); |
362 |
if (amount_diff != 0) { |
|
363 |
out->print(" %+ld%s", amount_diff, scale); |
|
364 |
} |
|
365 |
if (current_count > 0) { |
|
366 |
out->print(" #" SIZE_FORMAT "", current_count); |
|
367 |
if (current_count != early_count) { |
|
368 |
out->print(" %+d", (int)(current_count - early_count)); |
|
13195 | 369 |
} |
370 |
} |
|
371 |
} |
|
372 |
||
25946 | 373 |
void MemSummaryDiffReporter::print_arena_diff(size_t current_amount, size_t current_count, |
374 |
size_t early_amount, size_t early_count) const { |
|
375 |
const char* scale = current_scale(); |
|
376 |
outputStream* out = output(); |
|
377 |
out->print("arena=" SIZE_FORMAT "%s", amount_in_current_scale(current_amount), scale); |
|
378 |
if (diff_in_current_scale(current_amount, early_amount) != 0) { |
|
379 |
out->print(" %+ld", diff_in_current_scale(current_amount, early_amount)); |
|
380 |
} |
|
381 |
||
382 |
out->print(" #" SIZE_FORMAT "", current_count); |
|
383 |
if (current_count != early_count) { |
|
384 |
out->print(" %+d", (int)(current_count - early_count)); |
|
385 |
} |
|
386 |
} |
|
13195 | 387 |
|
25946 | 388 |
void MemSummaryDiffReporter::print_virtual_memory_diff(size_t current_reserved, size_t current_committed, |
389 |
size_t early_reserved, size_t early_committed) const { |
|
390 |
const char* scale = current_scale(); |
|
391 |
outputStream* out = output(); |
|
392 |
out->print("reserved=" SIZE_FORMAT "%s", amount_in_current_scale(current_reserved), scale); |
|
393 |
long reserved_diff = diff_in_current_scale(current_reserved, early_reserved); |
|
394 |
if (reserved_diff != 0) { |
|
395 |
out->print(" %+ld%s", reserved_diff, scale); |
|
396 |
} |
|
397 |
||
398 |
out->print(", committed=" SIZE_FORMAT "%s", amount_in_current_scale(current_committed), scale); |
|
399 |
long committed_diff = diff_in_current_scale(current_committed, early_committed); |
|
400 |
if (committed_diff != 0) { |
|
401 |
out->print(" %+ld%s", committed_diff, scale); |
|
13195 | 402 |
} |
403 |
} |
|
404 |
||
25946 | 405 |
|
47553
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
406 |
void MemSummaryDiffReporter::diff_summary_of_type(MEMFLAGS flag, |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
407 |
const MallocMemory* early_malloc, const VirtualMemory* early_vm, |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
408 |
const MetaspaceSnapshot* early_ms, |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
409 |
const MallocMemory* current_malloc, const VirtualMemory* current_vm, |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
410 |
const MetaspaceSnapshot* current_ms) const { |
25946 | 411 |
|
412 |
outputStream* out = output(); |
|
413 |
const char* scale = current_scale(); |
|
414 |
||
415 |
// Total reserved and committed memory in current baseline |
|
416 |
size_t current_reserved_amount = reserved_total (current_malloc, current_vm); |
|
417 |
size_t current_committed_amount = committed_total(current_malloc, current_vm); |
|
418 |
||
419 |
// Total reserved and committed memory in early baseline |
|
420 |
size_t early_reserved_amount = reserved_total(early_malloc, early_vm); |
|
421 |
size_t early_committed_amount = committed_total(early_malloc, early_vm); |
|
13195 | 422 |
|
25946 | 423 |
// Adjust virtual memory total |
424 |
if (flag == mtThread) { |
|
425 |
const VirtualMemory* early_thread_stack_usage = |
|
426 |
_early_baseline.virtual_memory(mtThreadStack); |
|
427 |
const VirtualMemory* current_thread_stack_usage = |
|
428 |
_current_baseline.virtual_memory(mtThreadStack); |
|
429 |
||
430 |
early_reserved_amount += early_thread_stack_usage->reserved(); |
|
431 |
early_committed_amount += early_thread_stack_usage->committed(); |
|
432 |
||
433 |
current_reserved_amount += current_thread_stack_usage->reserved(); |
|
434 |
current_committed_amount += current_thread_stack_usage->committed(); |
|
435 |
} else if (flag == mtNMT) { |
|
436 |
early_reserved_amount += _early_baseline.malloc_tracking_overhead(); |
|
437 |
early_committed_amount += _early_baseline.malloc_tracking_overhead(); |
|
438 |
||
439 |
current_reserved_amount += _current_baseline.malloc_tracking_overhead(); |
|
440 |
current_committed_amount += _current_baseline.malloc_tracking_overhead(); |
|
441 |
} |
|
13195 | 442 |
|
25946 | 443 |
if (amount_in_current_scale(current_reserved_amount) > 0 || |
444 |
diff_in_current_scale(current_reserved_amount, early_reserved_amount) != 0) { |
|
445 |
||
446 |
// print summary line |
|
447 |
out->print("-%26s (", NMTUtil::flag_to_name(flag)); |
|
448 |
print_virtual_memory_diff(current_reserved_amount, current_committed_amount, |
|
449 |
early_reserved_amount, early_committed_amount); |
|
450 |
out->print_cr(")"); |
|
13195 | 451 |
|
25946 | 452 |
// detail lines |
453 |
if (flag == mtClass) { |
|
454 |
// report class count |
|
455 |
out->print("%27s (classes #" SIZE_FORMAT "", " ", _current_baseline.class_count()); |
|
456 |
int class_count_diff = (int)(_current_baseline.class_count() - |
|
457 |
_early_baseline.class_count()); |
|
458 |
if (_current_baseline.class_count() != _early_baseline.class_count()) { |
|
459 |
out->print(" %+d", (int)(_current_baseline.class_count() - _early_baseline.class_count())); |
|
460 |
} |
|
461 |
out->print_cr(")"); |
|
462 |
} else if (flag == mtThread) { |
|
463 |
// report thread count |
|
464 |
out->print("%27s (thread #" SIZE_FORMAT "", " ", _current_baseline.thread_count()); |
|
465 |
int thread_count_diff = (int)(_current_baseline.thread_count() - |
|
466 |
_early_baseline.thread_count()); |
|
467 |
if (thread_count_diff != 0) { |
|
468 |
out->print(" %+d", thread_count_diff); |
|
469 |
} |
|
470 |
out->print_cr(")"); |
|
13195 | 471 |
|
25946 | 472 |
// report thread stack |
473 |
const VirtualMemory* current_thread_stack = |
|
474 |
_current_baseline.virtual_memory(mtThreadStack); |
|
475 |
const VirtualMemory* early_thread_stack = |
|
476 |
_early_baseline.virtual_memory(mtThreadStack); |
|
13195 | 477 |
|
25946 | 478 |
out->print("%27s (stack: ", " "); |
479 |
print_virtual_memory_diff(current_thread_stack->reserved(), current_thread_stack->committed(), |
|
480 |
early_thread_stack->reserved(), early_thread_stack->committed()); |
|
481 |
out->print_cr(")"); |
|
13195 | 482 |
} |
483 |
||
25946 | 484 |
// Report malloc'd memory |
485 |
size_t current_malloc_amount = current_malloc->malloc_size(); |
|
486 |
size_t early_malloc_amount = early_malloc->malloc_size(); |
|
487 |
if (amount_in_current_scale(current_malloc_amount) > 0 || |
|
488 |
diff_in_current_scale(current_malloc_amount, early_malloc_amount) != 0) { |
|
489 |
out->print("%28s(", " "); |
|
490 |
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
|
491 |
early_malloc_amount, early_malloc->malloc_count(), mtNone); |
25946 | 492 |
out->print_cr(")"); |
493 |
} |
|
13195 | 494 |
|
25946 | 495 |
// Report virtual memory |
496 |
if (amount_in_current_scale(current_vm->reserved()) > 0 || |
|
497 |
diff_in_current_scale(current_vm->reserved(), early_vm->reserved()) != 0) { |
|
498 |
out->print("%27s (mmap: ", " "); |
|
499 |
print_virtual_memory_diff(current_vm->reserved(), current_vm->committed(), |
|
500 |
early_vm->reserved(), early_vm->committed()); |
|
501 |
out->print_cr(")"); |
|
13195 | 502 |
} |
503 |
||
25946 | 504 |
// Report arena memory |
505 |
if (amount_in_current_scale(current_malloc->arena_size()) > 0 || |
|
506 |
diff_in_current_scale(current_malloc->arena_size(), early_malloc->arena_size()) != 0) { |
|
507 |
out->print("%28s(", " "); |
|
508 |
print_arena_diff(current_malloc->arena_size(), current_malloc->arena_count(), |
|
509 |
early_malloc->arena_size(), early_malloc->arena_count()); |
|
510 |
out->print_cr(")"); |
|
13195 | 511 |
} |
512 |
||
25946 | 513 |
// Report native memory tracking overhead |
514 |
if (flag == mtNMT) { |
|
515 |
size_t current_tracking_overhead = amount_in_current_scale(_current_baseline.malloc_tracking_overhead()); |
|
516 |
size_t early_tracking_overhead = amount_in_current_scale(_early_baseline.malloc_tracking_overhead()); |
|
13195 | 517 |
|
25946 | 518 |
out->print("%27s (tracking overhead=" SIZE_FORMAT "%s", " ", |
519 |
amount_in_current_scale(_current_baseline.malloc_tracking_overhead()), scale); |
|
13195 | 520 |
|
25946 | 521 |
long overhead_diff = diff_in_current_scale(_current_baseline.malloc_tracking_overhead(), |
522 |
_early_baseline.malloc_tracking_overhead()); |
|
523 |
if (overhead_diff != 0) { |
|
524 |
out->print(" %+ld%s", overhead_diff, scale); |
|
13195 | 525 |
} |
25946 | 526 |
out->print_cr(")"); |
47553
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
527 |
} else if (flag == mtClass) { |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
528 |
assert(current_ms != NULL && early_ms != NULL, "Sanity"); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
529 |
print_metaspace_diff(current_ms, early_ms); |
13195 | 530 |
} |
25946 | 531 |
out->print_cr(" "); |
13195 | 532 |
} |
533 |
} |
|
534 |
||
47553
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
535 |
void MemSummaryDiffReporter::print_metaspace_diff(const MetaspaceSnapshot* current_ms, |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
536 |
const MetaspaceSnapshot* early_ms) const { |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
537 |
print_metaspace_diff(Metaspace::NonClassType, current_ms, early_ms); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
538 |
if (Metaspace::using_class_space()) { |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
539 |
print_metaspace_diff(Metaspace::ClassType, current_ms, early_ms); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
540 |
} |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
541 |
} |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
542 |
|
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
543 |
void MemSummaryDiffReporter::print_metaspace_diff(Metaspace::MetadataType type, |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
544 |
const MetaspaceSnapshot* current_ms, |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
545 |
const MetaspaceSnapshot* early_ms) const { |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
546 |
const char* name = (type == Metaspace::NonClassType) ? |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
547 |
"Metadata: " : "Class space:"; |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
548 |
|
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
549 |
outputStream* out = output(); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
550 |
const char* scale = current_scale(); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
551 |
|
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
552 |
out->print_cr("%27s ( %s)", " ", name); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
553 |
out->print("%27s ( ", " "); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
554 |
print_virtual_memory_diff(current_ms->reserved_in_bytes(type), |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
555 |
current_ms->committed_in_bytes(type), |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
556 |
early_ms->reserved_in_bytes(type), |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
557 |
early_ms->committed_in_bytes(type)); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
558 |
out->print_cr(")"); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
559 |
|
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
560 |
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
|
561 |
early_ms->used_in_bytes(type)); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
562 |
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
|
563 |
early_ms->free_in_bytes(type)); |
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 |
size_t current_waste = current_ms->committed_in_bytes(type) |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
566 |
- (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
|
567 |
size_t early_waste = early_ms->committed_in_bytes(type) |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
568 |
- (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
|
569 |
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
|
570 |
|
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
571 |
// Diff used |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
572 |
out->print("%27s ( used=" SIZE_FORMAT "%s", " ", |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
573 |
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
|
574 |
if (diff_used != 0) { |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
575 |
out->print(" %+ld%s", diff_used, scale); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
576 |
} |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
577 |
out->print_cr(")"); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
578 |
|
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
579 |
// Diff free |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
580 |
out->print("%27s ( free=" SIZE_FORMAT "%s", " ", |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
581 |
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
|
582 |
if (diff_free != 0) { |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
583 |
out->print(" %+ld%s", diff_free, scale); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
584 |
} |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
585 |
out->print_cr(")"); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
586 |
|
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
587 |
|
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
588 |
// Diff waste |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
589 |
out->print("%27s ( waste=" SIZE_FORMAT "%s =%2.2f%%", " ", |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
590 |
amount_in_current_scale(current_waste), scale, |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
591 |
((float)current_waste * 100) / current_ms->committed_in_bytes(type)); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
592 |
if (diff_waste != 0) { |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
593 |
out->print(" %+ld%s", diff_waste, scale); |
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 |
out->print_cr(")"); |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
596 |
} |
5d20359dd938
8186770: NMT: Report metadata information in NMT summary
zgu
parents:
47216
diff
changeset
|
597 |
|
25946 | 598 |
void MemDetailDiffReporter::report_diff() { |
599 |
MemSummaryDiffReporter::report_diff(); |
|
600 |
diff_malloc_sites(); |
|
601 |
diff_virtual_memory_sites(); |
|
602 |
} |
|
603 |
||
604 |
void MemDetailDiffReporter::diff_malloc_sites() const { |
|
46711
0ccef2260315
8184991: NMT detail diff should take memory type into account
zgu
parents:
46489
diff
changeset
|
605 |
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
|
606 |
MallocSiteIterator current_itr = _current_baseline.malloc_sites(MemBaseline::by_site_and_type); |
25946 | 607 |
|
608 |
const MallocSite* early_site = early_itr.next(); |
|
609 |
const MallocSite* current_site = current_itr.next(); |
|
610 |
||
611 |
while (early_site != NULL || current_site != NULL) { |
|
612 |
if (early_site == NULL) { |
|
613 |
new_malloc_site(current_site); |
|
614 |
current_site = current_itr.next(); |
|
615 |
} else if (current_site == NULL) { |
|
616 |
old_malloc_site(early_site); |
|
617 |
early_site = early_itr.next(); |
|
13195 | 618 |
} else { |
25946 | 619 |
int compVal = current_site->call_stack()->compare(*early_site->call_stack()); |
620 |
if (compVal < 0) { |
|
621 |
new_malloc_site(current_site); |
|
622 |
current_site = current_itr.next(); |
|
623 |
} else if (compVal > 0) { |
|
624 |
old_malloc_site(early_site); |
|
625 |
early_site = early_itr.next(); |
|
13195 | 626 |
} else { |
25946 | 627 |
diff_malloc_site(early_site, current_site); |
628 |
early_site = early_itr.next(); |
|
629 |
current_site = current_itr.next(); |
|
13195 | 630 |
} |
631 |
} |
|
25946 | 632 |
} |
633 |
} |
|
13195 | 634 |
|
25946 | 635 |
void MemDetailDiffReporter::diff_virtual_memory_sites() const { |
636 |
VirtualMemorySiteIterator early_itr = _early_baseline.virtual_memory_sites(MemBaseline::by_site); |
|
637 |
VirtualMemorySiteIterator current_itr = _current_baseline.virtual_memory_sites(MemBaseline::by_site); |
|
638 |
||
639 |
const VirtualMemoryAllocationSite* early_site = early_itr.next(); |
|
640 |
const VirtualMemoryAllocationSite* current_site = current_itr.next(); |
|
641 |
||
642 |
while (early_site != NULL || current_site != NULL) { |
|
643 |
if (early_site == NULL) { |
|
644 |
new_virtual_memory_site(current_site); |
|
645 |
current_site = current_itr.next(); |
|
646 |
} else if (current_site == NULL) { |
|
647 |
old_virtual_memory_site(early_site); |
|
648 |
early_site = early_itr.next(); |
|
649 |
} else { |
|
650 |
int compVal = current_site->call_stack()->compare(*early_site->call_stack()); |
|
651 |
if (compVal < 0) { |
|
652 |
new_virtual_memory_site(current_site); |
|
653 |
current_site = current_itr.next(); |
|
654 |
} else if (compVal > 0) { |
|
655 |
old_virtual_memory_site(early_site); |
|
656 |
early_site = early_itr.next(); |
|
657 |
} else { |
|
658 |
diff_virtual_memory_site(early_site, current_site); |
|
659 |
early_site = early_itr.next(); |
|
660 |
current_site = current_itr.next(); |
|
661 |
} |
|
13195 | 662 |
} |
663 |
} |
|
664 |
} |
|
665 |
||
25946 | 666 |
|
667 |
void MemDetailDiffReporter::new_malloc_site(const MallocSite* malloc_site) const { |
|
668 |
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
|
669 |
0, 0, malloc_site->flags()); |
25946 | 670 |
} |
671 |
||
672 |
void MemDetailDiffReporter::old_malloc_site(const MallocSite* malloc_site) const { |
|
673 |
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
|
674 |
malloc_site->count(), malloc_site->flags()); |
25946 | 675 |
} |
676 |
||
677 |
void MemDetailDiffReporter::diff_malloc_site(const MallocSite* early, |
|
678 |
const MallocSite* current) const { |
|
46711
0ccef2260315
8184991: NMT detail diff should take memory type into account
zgu
parents:
46489
diff
changeset
|
679 |
assert(early->flags() == current->flags(), "Must be the same memory type"); |
25946 | 680 |
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
|
681 |
early->size(), early->count(), early->flags()); |
25946 | 682 |
} |
683 |
||
684 |
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
|
685 |
size_t current_count, size_t early_size, size_t early_count, MEMFLAGS flags) const { |
25946 | 686 |
outputStream* out = output(); |
687 |
||
688 |
assert(stack != NULL, "NULL stack"); |
|
689 |
||
690 |
if (diff_in_current_scale(current_size, early_size) == 0) { |
|
691 |
return; |
|
692 |
} |
|
693 |
||
694 |
stack->print_on(out); |
|
695 |
out->print("%28s (", " "); |
|
696 |
print_malloc_diff(current_size, current_count, |
|
46711
0ccef2260315
8184991: NMT detail diff should take memory type into account
zgu
parents:
46489
diff
changeset
|
697 |
early_size, early_count, flags); |
13195 | 698 |
|
25946 | 699 |
out->print_cr(")\n"); |
700 |
} |
|
701 |
||
702 |
||
703 |
void MemDetailDiffReporter::new_virtual_memory_site(const VirtualMemoryAllocationSite* site) const { |
|
704 |
diff_virtual_memory_site(site->call_stack(), site->reserved(), site->committed(), 0, 0); |
|
705 |
} |
|
706 |
||
707 |
void MemDetailDiffReporter::old_virtual_memory_site(const VirtualMemoryAllocationSite* site) const { |
|
708 |
diff_virtual_memory_site(site->call_stack(), 0, 0, site->reserved(), site->committed()); |
|
709 |
} |
|
710 |
||
711 |
void MemDetailDiffReporter::diff_virtual_memory_site(const VirtualMemoryAllocationSite* early, |
|
712 |
const VirtualMemoryAllocationSite* current) const { |
|
713 |
diff_virtual_memory_site(current->call_stack(), current->reserved(), current->committed(), |
|
714 |
early->reserved(), early->committed()); |
|
715 |
} |
|
716 |
||
717 |
void MemDetailDiffReporter::diff_virtual_memory_site(const NativeCallStack* stack, size_t current_reserved, |
|
718 |
size_t current_committed, size_t early_reserved, size_t early_committed) const { |
|
719 |
outputStream* out = output(); |
|
720 |
||
721 |
// no change |
|
722 |
if (diff_in_current_scale(current_reserved, early_reserved) == 0 && |
|
723 |
diff_in_current_scale(current_committed, early_committed) == 0) { |
|
724 |
return; |
|
13195 | 725 |
} |
25946 | 726 |
|
727 |
stack->print_on(out); |
|
728 |
out->print("%28s (mmap: ", " "); |
|
729 |
print_virtual_memory_diff(current_reserved, current_committed, |
|
730 |
early_reserved, early_committed); |
|
731 |
||
732 |
out->print_cr(")\n"); |
|
733 |
} |
|
734 |