Skip to content

Commit

Permalink
8308633: Increase precision of timestamps in g1 log
Browse files Browse the repository at this point in the history
Reviewed-by: ayang, kbarrett
  • Loading branch information
Thomas Schatzl committed Jun 26, 2023
1 parent 9397094 commit c23794f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/g1/g1GCPhaseTimes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ void G1GCPhaseTimes::trace_phase(WorkerDataArray<double>* phase, bool print_sum,
}
}

#define TIME_FORMAT "%.1lfms"
#define TIME_FORMAT "%.2lfms"

void G1GCPhaseTimes::info_time(const char* name, double value) const {
log_info(gc, phases)(" %s: " TIME_FORMAT, name, value);
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/shared/weakProcessorTimes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ static const char* indent_str(size_t i) {
return indents[MIN2(i, max_indents_index)];
}

#define TIME_FORMAT "%.1lfms"
#define TIME_FORMAT "%.2lfms"

void WeakProcessorTimes::log_summary(OopStorageSet::WeakId id, uint indent) const {
LogTarget(Debug, gc, phases) lt;
Expand Down
9 changes: 6 additions & 3 deletions src/hotspot/share/gc/shared/workerDataArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,14 @@ double WorkerDataArray<double>::uninitialized() {
return -1.0;
}

#define WDA_TIME_FORMAT "%4.2lf"

template <>
void WorkerDataArray<double>::WDAPrinter::summary(outputStream* out, double min, double avg, double max, double diff, double sum, bool print_sum) {
out->print(" Min: %4.1lf, Avg: %4.1lf, Max: %4.1lf, Diff: %4.1lf", min * MILLIUNITS, avg * MILLIUNITS, max * MILLIUNITS, diff* MILLIUNITS);
out->print(" Min: " WDA_TIME_FORMAT ", Avg: " WDA_TIME_FORMAT ", Max: " WDA_TIME_FORMAT ", Diff: " WDA_TIME_FORMAT,
min * MILLIUNITS, avg * MILLIUNITS, max * MILLIUNITS, diff* MILLIUNITS);
if (print_sum) {
out->print(", Sum: %4.1lf", sum * MILLIUNITS);
out->print(", Sum: " WDA_TIME_FORMAT, sum * MILLIUNITS);
}
}

Expand All @@ -58,7 +61,7 @@ void WorkerDataArray<double>::WDAPrinter::details(const WorkerDataArray<double>*
for (uint i = 0; i < phase->_length; ++i) {
double value = phase->get(i);
if (value != phase->uninitialized()) {
out->print(" %4.1lf", phase->get(i) * 1000.0);
out->print(" " WDA_TIME_FORMAT, phase->get(i) * 1000.0);
} else {
out->print(" -");
}
Expand Down
10 changes: 5 additions & 5 deletions test/hotspot/gtest/gc/shared/test_workerDataArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ const char* WorkerDataArrayTest<double>::format_summary(
double min, double avg, double max, double diff, double sum, size_t workers) {

stringStream out;
out.print(" Min: %4.1lf"
", Avg: %4.1lf, Max: %4.1lf"
", Diff: %4.1lf, Sum: %4.1lf"
out.print(" Min: %4.2lf"
", Avg: %4.2lf, Max: %4.2lf"
", Diff: %4.2lf, Sum: %4.2lf"
", Workers: " SIZE_FORMAT "\n",
min, avg, max, diff, sum, workers);
return out.as_string();
Expand Down Expand Up @@ -278,12 +278,12 @@ class UninitializedDoubleElementWorkerDataArrayTest : public WorkerDataArrayTest

private:
virtual const char* expected_summary() {
return format_summary(5.1, 6.1, 7.2, 2.1, 12.3, 2);
return format_summary(5.10, 6.15, 7.20, 2.10, 12.30, 2);
}

virtual const char* expected_details() {
stringStream out;
out.print(" %4.1lf - %4.1lf\n", 5.1, 7.2);
out.print(" %4.2lf - %4.2lf\n", 5.1, 7.2);
return out.as_string();
}
};
Expand Down

1 comment on commit c23794f

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.