Skip to content

Commit 49b9e68

Browse files
committedApr 19, 2021
8262165: NMT report should state how many callsites had been skipped
Reviewed-by: zgu, shade
1 parent e390e55 commit 49b9e68

File tree

2 files changed

+51
-19
lines changed

2 files changed

+51
-19
lines changed
 

‎src/hotspot/share/services/memReporter.cpp

+44-15
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ void MemReporterBase::print_virtual_memory_region(const char* type, address base
9797

9898

9999
void MemSummaryReporter::report() {
100-
const char* scale = current_scale();
101100
outputStream* out = output();
102101
size_t total_reserved_amount = _malloc_snapshot->total() +
103102
_vm_snapshot->total_reserved();
@@ -106,6 +105,12 @@ void MemSummaryReporter::report() {
106105

107106
// Overall total
108107
out->print_cr("\nNative Memory Tracking:\n");
108+
109+
if (scale() > 1) {
110+
out->print_cr("(Omitting categories weighting less than 1%s)", current_scale());
111+
out->cr();
112+
}
113+
109114
out->print("Total: ");
110115
print_total(total_reserved_amount, total_committed_amount);
111116
out->print("\n");
@@ -243,22 +248,35 @@ void MemDetailReporter::report_detail() {
243248
outputStream* out = output();
244249
out->print_cr("Details:\n");
245250

246-
report_malloc_sites();
247-
report_virtual_memory_allocation_sites();
251+
int num_omitted =
252+
report_malloc_sites() +
253+
report_virtual_memory_allocation_sites();
254+
if (num_omitted > 0) {
255+
assert(scale() > 1, "sanity");
256+
out->print_cr("(%d call sites weighting less than 1%s each omitted.)",
257+
num_omitted, current_scale());
258+
out->cr();
259+
}
248260
}
249261

250-
void MemDetailReporter::report_malloc_sites() {
262+
int MemDetailReporter::report_malloc_sites() {
251263
MallocSiteIterator malloc_itr = _baseline.malloc_sites(MemBaseline::by_size);
252-
if (malloc_itr.is_empty()) return;
264+
if (malloc_itr.is_empty()) return 0;
253265

254266
outputStream* out = output();
255267

256268
const MallocSite* malloc_site;
269+
int num_omitted = 0;
257270
while ((malloc_site = malloc_itr.next()) != NULL) {
258-
// Don't report if size is too small
259-
if (amount_in_current_scale(malloc_site->size()) == 0)
271+
// Don't report free sites; does not count toward omitted count.
272+
if (malloc_site->size() == 0) {
260273
continue;
261-
274+
}
275+
// Don't report if site has allocated less than one unit of whatever our scale is
276+
if (scale() > 1 && amount_in_current_scale(malloc_site->size()) == 0) {
277+
num_omitted ++;
278+
continue;
279+
}
262280
const NativeCallStack* stack = malloc_site->call_stack();
263281
stack->print_on(out);
264282
out->print("%29s", " ");
@@ -268,22 +286,28 @@ void MemDetailReporter::report_malloc_sites() {
268286
print_malloc(malloc_site->size(), malloc_site->count(),flag);
269287
out->print_cr("\n");
270288
}
289+
return num_omitted;
271290
}
272291

273-
void MemDetailReporter::report_virtual_memory_allocation_sites() {
292+
int MemDetailReporter::report_virtual_memory_allocation_sites() {
274293
VirtualMemorySiteIterator virtual_memory_itr =
275294
_baseline.virtual_memory_sites(MemBaseline::by_size);
276295

277-
if (virtual_memory_itr.is_empty()) return;
296+
if (virtual_memory_itr.is_empty()) return 0;
278297

279298
outputStream* out = output();
280299
const VirtualMemoryAllocationSite* virtual_memory_site;
281-
300+
int num_omitted = 0;
282301
while ((virtual_memory_site = virtual_memory_itr.next()) != NULL) {
283-
// Don't report if size is too small
284-
if (amount_in_current_scale(virtual_memory_site->reserved()) == 0)
302+
// Don't report free sites; does not count toward omitted count.
303+
if (virtual_memory_site->reserved() == 0) {
285304
continue;
286-
305+
}
306+
// Don't report if site has reserved less than one unit of whatever our scale is
307+
if (scale() > 1 && amount_in_current_scale(virtual_memory_site->reserved()) == 0) {
308+
num_omitted++;
309+
continue;
310+
}
287311
const NativeCallStack* stack = virtual_memory_site->call_stack();
288312
stack->print_on(out);
289313
out->print("%28s (", " ");
@@ -294,6 +318,7 @@ void MemDetailReporter::report_virtual_memory_allocation_sites() {
294318
}
295319
out->print_cr(")\n");
296320
}
321+
return num_omitted;
297322
}
298323

299324

@@ -359,10 +384,14 @@ void MemDetailReporter::report_virtual_memory_region(const ReservedMemoryRegion*
359384
}
360385

361386
void MemSummaryDiffReporter::report_diff() {
362-
const char* scale = current_scale();
363387
outputStream* out = output();
364388
out->print_cr("\nNative Memory Tracking:\n");
365389

390+
if (scale() > 1) {
391+
out->print_cr("(Omitting categories weighting less than 1%s)", current_scale());
392+
out->cr();
393+
}
394+
366395
// Overall diff
367396
out->print("Total: ");
368397
print_virtual_memory_diff(_current_baseline.total_reserved_memory(),

‎src/hotspot/share/services/memReporter.hpp

+7-4
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ class MemReporterBase : public StackObj {
5656
return _output;
5757
}
5858
// Current reporting scale
59+
size_t scale() const {
60+
return _scale;
61+
}
5962
inline const char* current_scale() const {
6063
return NMTUtil::scale_name(_scale);
6164
}
@@ -144,10 +147,10 @@ class MemDetailReporter : public MemSummaryReporter {
144147
void report_detail();
145148
// Report virtual memory map
146149
void report_virtual_memory_map();
147-
// Report malloc allocation sites
148-
void report_malloc_sites();
149-
// Report virtual memory reservation sites
150-
void report_virtual_memory_allocation_sites();
150+
// Report malloc allocation sites; returns number of omitted sites
151+
int report_malloc_sites();
152+
// Report virtual memory reservation sites; returns number of omitted sites
153+
int report_virtual_memory_allocation_sites();
151154

152155
// Report a virtual memory region
153156
void report_virtual_memory_region(const ReservedMemoryRegion* rgn);

0 commit comments

Comments
 (0)
Please sign in to comment.