Skip to content

Commit

Permalink
Renamed dump fraction to percentage
Browse files Browse the repository at this point in the history
  • Loading branch information
schmelter-sap committed Jan 26, 2024
1 parent 3a5a6ed commit 0010896
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
16 changes: 8 additions & 8 deletions src/hotspot/os/posix/malloctrace/mallocTrace2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2078,7 +2078,7 @@ bool MallocStatisticImpl::dump(outputStream* msg_stream, outputStream* dump_stre
uint64_t total_size = 0;
int total_entries = 0;
int total_non_empty_entries = 0;
int max_entries = MAX2(1, spec._dump_fraction > 0 ? INT_MAX : spec._max_entries);
int max_entries = MAX2(1, spec._dump_percentage > 0 ? INT_MAX : spec._max_entries);
int max_printed_entries = max_entries;

if (uses_filter) {
Expand Down Expand Up @@ -2180,11 +2180,11 @@ bool MallocStatisticImpl::dump(outputStream* msg_stream, outputStream* dump_stre
uint64_t size_limit = total_size;
uint64_t count_limit = total_count;

if (spec._dump_fraction > 0) {
if (spec._dump_percentage > 0) {
if (spec._sort_by_count) {
count_limit = (uint64_t) (0.01 * total_count * spec._dump_fraction);
count_limit = (uint64_t) (0.01 * total_count * spec._dump_percentage);
} else {
size_limit = (uint64_t) (0.01 * total_size * spec._dump_fraction);
size_limit = (uint64_t) (0.01 * total_size * spec._dump_percentage);
}
}

Expand Down Expand Up @@ -2353,7 +2353,7 @@ static void dump_from_flags(bool on_error) {
spec._filter = MallocTraceDumpFilter;
spec._sort_by_count = MallocTraceDumpSortByCount;
spec._max_entries = MallocTraceDumpMaxEntries;
spec._dump_fraction = MallocTraceDumpFraction;
spec._dump_percentage = MallocTraceDumpPercentage;
spec._hide_dump_allocs = MallocTraceDumpHideDumpAlllocs;
spec._internal_stats = MallocTraceDumpInternalStats;

Expand Down Expand Up @@ -2634,7 +2634,7 @@ MallocTraceDumpDCmd::MallocTraceDumpDCmd(outputStream* output, bool heap) :
_filter("-filter", "If given we only print a stack if it contains a function matching " \
"the given string.", "STRING", false),
_max_entries("-max-entries", "The maximum number of entries to dump.", "INT", false, "10"),
_dump_fraction("-fraction", "If > 0 we dump the given fraction of allocated bytes " \
_dump_percentage("-percentage", "If > 0 we dump the given percentage of allocated bytes " \
"(or allocated objects if sorted by count). In that case the -max-entries " \
"option is ignored", "INT", false, "0"),
_sort_by_count("-sort-by-count", "If given the stacks are sorted according to the number " \
Expand All @@ -2645,7 +2645,7 @@ MallocTraceDumpDCmd::MallocTraceDumpDCmd(outputStream* output, bool heap) :
_dcmdparser.add_dcmd_option(&_dump_file);
_dcmdparser.add_dcmd_option(&_filter);
_dcmdparser.add_dcmd_option(&_max_entries);
_dcmdparser.add_dcmd_option(&_dump_fraction);
_dcmdparser.add_dcmd_option(&_dump_percentage);
_dcmdparser.add_dcmd_option(&_sort_by_count);
_dcmdparser.add_dcmd_option(&_internal_stats);
}
Expand All @@ -2658,7 +2658,7 @@ void MallocTraceDumpDCmd::execute(DCmdSource source, TRAPS) {
spec._dump_file = _dump_file.value();
spec._filter = _filter.value();
spec._max_entries = _max_entries.value();
spec._dump_fraction = _dump_fraction.value();
spec._dump_percentage = _dump_percentage.value();
spec._on_error = false;
spec._sort_by_count = _sort_by_count.value();
spec._internal_stats = _internal_stats.value();
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/os/posix/malloctrace/mallocTrace2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ struct DumpSpec {
bool _hide_dump_allocs;
bool _on_error;
bool _sort_by_count;
int _dump_fraction;
int _dump_percentage;
bool _internal_stats;

DumpSpec() :
Expand All @@ -73,7 +73,7 @@ struct DumpSpec {
_hide_dump_allocs(true),
_on_error(false),
_sort_by_count(false),
_dump_fraction(100),
_dump_percentage(100),
_internal_stats(false) {
}
};
Expand Down Expand Up @@ -174,7 +174,7 @@ class MallocTraceDumpDCmd : public DCmdWithParser {
DCmdArgument<char*> _dump_file;
DCmdArgument<char*> _filter;
DCmdArgument<jlong> _max_entries;
DCmdArgument<jlong> _dump_fraction;
DCmdArgument<jlong> _dump_percentage;
DCmdArgument<bool> _sort_by_count;
DCmdArgument<bool> _internal_stats;

Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/runtime/globals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -634,8 +634,8 @@ const int ObjectAlignmentInBytes = 8;
"is specified via -XX:MallocTraceDumpSort, we sort by " \
"size.") \
\
product(uintx, MallocTraceDumpFraction, 0, \
"If > 0 we dump the given fraction of allocated bytes " \
product(uintx, MallocTraceDumpPercentage, 0, \
"If > 0 we dump the given percentage of allocated bytes " \
"(or allocated objects if sorted by count). In that case the " \
"-XX:MallocTraceDumpMaxEntries option is ignored.") \
\
Expand Down
10 changes: 5 additions & 5 deletions test/hotspot/jtreg/runtime/malloctrace/MallocHooksTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ public static void main(String args[]) throws Exception {
testEnvSanitizing();
testTracking(false);
testTracking(true);
testDumpFraction(true);
testDumpFraction(false);
testDumpPercentage(true);
testDumpPercentage(false);
testPartialTrackint(false, 2, 0.2);
testPartialTrackint(true, 2, 0.2);
testPartialTrackint(false, 10, 0.3);
Expand Down Expand Up @@ -456,14 +456,14 @@ private static ProcessBuilder runManyStacks(int nrOfOps, int size, int maxStack,
return ProcessTools.createLimitedTestJavaProcessBuilder(args);
}

private static void testDumpFraction(boolean bySize) throws Exception {
private static void testDumpPercentage(boolean bySize) throws Exception {
ProcessBuilder pb = runManyStacks(1024 * 1024 * 10, 1024 * 16, 5, 172369973,
"-Djava.library.path=" + System.getProperty("java.library.path"),
"-XX:MallocTraceStackDepth=12");
Process p = ProcessTools.startProcess("runManyStack", pb, x -> System.out.println("> " + x), null, -1, null);
p.getInputStream().read();
OutputAnalyzer oa = bySize ? callJcmd(p, "MallocTrace.dump", "-fraction=90") :
callJcmd(p, "MallocTrace.dump", "-sort-by-count", "-fraction=90");
OutputAnalyzer oa = bySize ? callJcmd(p, "MallocTrace.dump", "-percentage=90") :
callJcmd(p, "MallocTrace.dump", "-sort-by-count", "-percentage=90");
oa.shouldHaveExitValue(0);
p.destroy();
oa.stdoutShouldMatch("Total printed " + (bySize ? "bytes" : "count") + ": .*[(].*90[.][0-9]+ %[)]");
Expand Down

0 comments on commit 0010896

Please sign in to comment.