8289182: NMT: MemTracker::baseline should return void

Reviewed-by: dholmes, zgu
This commit is contained in:
Thomas Stuefe 2022-06-29 04:12:46 +00:00
parent 779b4e1d19
commit b96ba19807
8 changed files with 36 additions and 47 deletions

View File

@ -145,11 +145,10 @@ class VirtualMemoryAllocationWalker : public VirtualMemoryWalker {
};
bool MemBaseline::baseline_summary() {
void MemBaseline::baseline_summary() {
MallocMemorySummary::snapshot(&_malloc_memory_snapshot);
VirtualMemorySummary::snapshot(&_virtual_memory_snapshot);
_metaspace_stats = MetaspaceUtils::get_combined_statistics();
return true;
}
bool MemBaseline::baseline_allocation_sites() {
@ -186,15 +185,12 @@ bool MemBaseline::baseline_allocation_sites() {
return true;
}
bool MemBaseline::baseline(bool summaryOnly) {
void MemBaseline::baseline(bool summaryOnly) {
reset();
_instance_class_count = ClassLoaderDataGraph::num_instance_classes();
_array_class_count = ClassLoaderDataGraph::num_array_classes();
if (!baseline_summary()) {
return false;
}
baseline_summary();
_baseline_type = Summary_baselined;
@ -205,7 +201,6 @@ bool MemBaseline::baseline(bool summaryOnly) {
_baseline_type = Detail_baselined;
}
return true;
}
int compare_allocation_site(const VirtualMemoryAllocationSite& s1,

View File

@ -88,7 +88,7 @@ class MemBaseline {
_baseline_type(Not_baselined) {
}
bool baseline(bool summaryOnly = true);
void baseline(bool summaryOnly = true);
BaselineType baseline_type() const { return _baseline_type; }
@ -188,7 +188,7 @@ class MemBaseline {
private:
// Baseline summary information
bool baseline_summary();
void baseline_summary();
// Baseline allocation sites (detail tracking only)
bool baseline_allocation_sites();

View File

@ -129,18 +129,17 @@ void MemTracker::final_report(outputStream* output) {
void MemTracker::report(bool summary_only, outputStream* output, size_t scale) {
assert(output != NULL, "No output stream");
MemBaseline baseline;
if (baseline.baseline(summary_only)) {
if (summary_only) {
MemSummaryReporter rpt(baseline, output, scale);
rpt.report();
} else {
MemDetailReporter rpt(baseline, output, scale);
rpt.report();
output->print("Metaspace:");
// The basic metaspace report avoids any locking and should be safe to
// be called at any time.
MetaspaceUtils::print_basic_report(output, scale);
}
baseline.baseline(summary_only);
if (summary_only) {
MemSummaryReporter rpt(baseline, output, scale);
rpt.report();
} else {
MemDetailReporter rpt(baseline, output, scale);
rpt.report();
output->print("Metaspace:");
// The basic metaspace report avoids any locking and should be safe to
// be called at any time.
MetaspaceUtils::print_basic_report(output, scale);
}
}

View File

@ -117,11 +117,8 @@ void NMTDCmd::execute(DCmdSource source, TRAPS) {
report(false, scale_unit);
} else if (_baseline.value()) {
MemBaseline& baseline = MemTracker::get_baseline();
if (!baseline.baseline(MemTracker::tracking_level() != NMT_detail)) {
output()->print_cr("Baseline failed");
} else {
output()->print_cr("Baseline succeeded");
}
baseline.baseline(MemTracker::tracking_level() != NMT_detail);
output()->print_cr("Baseline taken");
} else if (_summary_diff.value()) {
MemBaseline& baseline = MemTracker::get_baseline();
if (baseline.baseline_type() >= MemBaseline::Summary_baselined) {
@ -151,14 +148,13 @@ void NMTDCmd::execute(DCmdSource source, TRAPS) {
void NMTDCmd::report(bool summaryOnly, size_t scale_unit) {
MemBaseline baseline;
if (baseline.baseline(summaryOnly)) {
if (summaryOnly) {
MemSummaryReporter rpt(baseline, output(), scale_unit);
rpt.report();
} else {
MemDetailReporter rpt(baseline, output(), scale_unit);
rpt.report();
}
baseline.baseline(summaryOnly);
if (summaryOnly) {
MemSummaryReporter rpt(baseline, output(), scale_unit);
rpt.report();
} else {
MemDetailReporter rpt(baseline, output(), scale_unit);
rpt.report();
}
}
@ -170,14 +166,13 @@ void NMTDCmd::report_diff(bool summaryOnly, size_t scale_unit) {
"Not a detail baseline");
MemBaseline baseline;
if (baseline.baseline(summaryOnly)) {
if (summaryOnly) {
MemSummaryDiffReporter rpt(early_baseline, baseline, output(), scale_unit);
rpt.report_diff();
} else {
MemDetailDiffReporter rpt(early_baseline, baseline, output(), scale_unit);
rpt.report_diff();
}
baseline.baseline(summaryOnly);
if (summaryOnly) {
MemSummaryDiffReporter rpt(early_baseline, baseline, output(), scale_unit);
rpt.report_diff();
} else {
MemDetailDiffReporter rpt(early_baseline, baseline, output(), scale_unit);
rpt.report_diff();
}
}

View File

@ -47,6 +47,6 @@ public class JcmdBaselineDetail {
pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "baseline=true"});
output = new OutputAnalyzer(pb.start());
output.shouldContain("Baseline succeeded");
output.shouldContain("Baseline taken");
}
}

View File

@ -57,7 +57,7 @@ public class JcmdDetailDiff {
pb.start().waitFor();
output = new OutputAnalyzer(pb.start());
output.shouldContain("Baseline succeeded");
output.shouldContain("Baseline taken");
addr = wb.NMTReserveMemory(reserveSize);
pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "detail.diff", "scale=KB"});

View File

@ -57,7 +57,7 @@ public class JcmdSummaryDiff {
pb.start().waitFor();
output = new OutputAnalyzer(pb.start());
output.shouldContain("Baseline succeeded");
output.shouldContain("Baseline taken");
addr = wb.NMTReserveMemory(reserveSize);
pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary.diff", "scale=KB"});

View File

@ -56,7 +56,7 @@ public class MallocSiteTypeChange {
pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "baseline"});
output = new OutputAnalyzer(pb.start());
output.shouldContain("Baseline succeeded");
output.shouldContain("Baseline taken");
wb.NMTFree(addr);
addr = wb.NMTMallocWithPseudoStackAndType(2 * 1024, pc, 9 /* mtInternal */ );