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

View File

@ -88,7 +88,7 @@ class MemBaseline {
_baseline_type(Not_baselined) { _baseline_type(Not_baselined) {
} }
bool baseline(bool summaryOnly = true); void baseline(bool summaryOnly = true);
BaselineType baseline_type() const { return _baseline_type; } BaselineType baseline_type() const { return _baseline_type; }
@ -188,7 +188,7 @@ class MemBaseline {
private: private:
// Baseline summary information // Baseline summary information
bool baseline_summary(); void baseline_summary();
// Baseline allocation sites (detail tracking only) // Baseline allocation sites (detail tracking only)
bool baseline_allocation_sites(); 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) { void MemTracker::report(bool summary_only, outputStream* output, size_t scale) {
assert(output != NULL, "No output stream"); assert(output != NULL, "No output stream");
MemBaseline baseline; MemBaseline baseline;
if (baseline.baseline(summary_only)) { baseline.baseline(summary_only);
if (summary_only) { if (summary_only) {
MemSummaryReporter rpt(baseline, output, scale); MemSummaryReporter rpt(baseline, output, scale);
rpt.report(); rpt.report();
} else { } else {
MemDetailReporter rpt(baseline, output, scale); MemDetailReporter rpt(baseline, output, scale);
rpt.report(); rpt.report();
output->print("Metaspace:"); output->print("Metaspace:");
// The basic metaspace report avoids any locking and should be safe to // The basic metaspace report avoids any locking and should be safe to
// be called at any time. // be called at any time.
MetaspaceUtils::print_basic_report(output, scale); MetaspaceUtils::print_basic_report(output, scale);
}
} }
} }

View File

@ -117,11 +117,8 @@ void NMTDCmd::execute(DCmdSource source, TRAPS) {
report(false, scale_unit); report(false, scale_unit);
} else if (_baseline.value()) { } else if (_baseline.value()) {
MemBaseline& baseline = MemTracker::get_baseline(); MemBaseline& baseline = MemTracker::get_baseline();
if (!baseline.baseline(MemTracker::tracking_level() != NMT_detail)) { baseline.baseline(MemTracker::tracking_level() != NMT_detail);
output()->print_cr("Baseline failed"); output()->print_cr("Baseline taken");
} else {
output()->print_cr("Baseline succeeded");
}
} else if (_summary_diff.value()) { } else if (_summary_diff.value()) {
MemBaseline& baseline = MemTracker::get_baseline(); MemBaseline& baseline = MemTracker::get_baseline();
if (baseline.baseline_type() >= MemBaseline::Summary_baselined) { 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) { void NMTDCmd::report(bool summaryOnly, size_t scale_unit) {
MemBaseline baseline; MemBaseline baseline;
if (baseline.baseline(summaryOnly)) { baseline.baseline(summaryOnly);
if (summaryOnly) { if (summaryOnly) {
MemSummaryReporter rpt(baseline, output(), scale_unit); MemSummaryReporter rpt(baseline, output(), scale_unit);
rpt.report(); rpt.report();
} else { } else {
MemDetailReporter rpt(baseline, output(), scale_unit); MemDetailReporter rpt(baseline, output(), scale_unit);
rpt.report(); rpt.report();
}
} }
} }
@ -170,14 +166,13 @@ void NMTDCmd::report_diff(bool summaryOnly, size_t scale_unit) {
"Not a detail baseline"); "Not a detail baseline");
MemBaseline baseline; MemBaseline baseline;
if (baseline.baseline(summaryOnly)) { baseline.baseline(summaryOnly);
if (summaryOnly) { if (summaryOnly) {
MemSummaryDiffReporter rpt(early_baseline, baseline, output(), scale_unit); MemSummaryDiffReporter rpt(early_baseline, baseline, output(), scale_unit);
rpt.report_diff(); rpt.report_diff();
} else { } else {
MemDetailDiffReporter rpt(early_baseline, baseline, output(), scale_unit); MemDetailDiffReporter rpt(early_baseline, baseline, output(), scale_unit);
rpt.report_diff(); 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"}); pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "baseline=true"});
output = new OutputAnalyzer(pb.start()); 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(); pb.start().waitFor();
output = new OutputAnalyzer(pb.start()); output = new OutputAnalyzer(pb.start());
output.shouldContain("Baseline succeeded"); output.shouldContain("Baseline taken");
addr = wb.NMTReserveMemory(reserveSize); addr = wb.NMTReserveMemory(reserveSize);
pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "detail.diff", "scale=KB"}); 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(); pb.start().waitFor();
output = new OutputAnalyzer(pb.start()); output = new OutputAnalyzer(pb.start());
output.shouldContain("Baseline succeeded"); output.shouldContain("Baseline taken");
addr = wb.NMTReserveMemory(reserveSize); addr = wb.NMTReserveMemory(reserveSize);
pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary.diff", "scale=KB"}); 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"}); pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "baseline"});
output = new OutputAnalyzer(pb.start()); output = new OutputAnalyzer(pb.start());
output.shouldContain("Baseline succeeded"); output.shouldContain("Baseline taken");
wb.NMTFree(addr); wb.NMTFree(addr);
addr = wb.NMTMallocWithPseudoStackAndType(2 * 1024, pc, 9 /* mtInternal */ ); addr = wb.NMTMallocWithPseudoStackAndType(2 * 1024, pc, 9 /* mtInternal */ );