Skip to content

Commit d3c496f

Browse files
committed
Improve resource statistics.
1 parent 2d2297e commit d3c496f

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

docs/reference-manual/native-image/BuildOutput.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Top 10 packages in code area: Top 10 object types in image heap:
4545
... 111 additional packages ... 723 additional object types
4646
(use GraalVM Dashboard to see all)
4747
--------------------------------------------------------------------------------
48-
0.8s (5.4% of total time) in 17 GCs | Peak RSS: 2.60GB | CPU load: ~1183.69%
48+
0.8s (5.4% of total time) in 17 GCs | Peak RSS: 2.60GB | CPU load: 11.83
4949
--------------------------------------------------------------------------------
5050
Produced artifacts:
5151
/home/janedoe/helloworld/helloworld (executable)
@@ -136,7 +136,7 @@ This data typically contains internal information for Native Image but it can al
136136
### Resource Usage Statistics
137137

138138
#### <a name="glossary-garbage-collection"></a>Garbage Collections
139-
The total time spent in all garbage collectors, total GC time divided by the total time to build the image in percent, and the total number of garbage collections.
139+
The total time spent in all garbage collectors, total GC time divided by the total process time in percent, and the total number of garbage collections.
140140
A large number of collections or time spent in collectors usually indicates that the system is under memory pressure.
141141
Increase the amount of available memory to reduce the time to build the image.
142142

@@ -146,7 +146,7 @@ This value indicates the maximum amount of memory consumed by the build process.
146146
If the [GC statistics](#glossary-garbage-collection) do not show any problems, the amount of available memory of the system can be reduced to a value closer to the peak RSS.
147147

148148
#### <a name="glossary-cpu-load"></a>CPU load
149-
The CPU time used by the process divided by the total time to build the image in percent.
149+
The CPU time used by the process divided by the total process time.
150150
Increase the number of CPU threads to reduce the time to build the image.
151151

152152
## Build Output Options

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reporting/ProgressReporter.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ private Map<String, Long> calculateHeapBreakdown(Collection<ObjectInfo> heapObje
461461

462462
public void printEpilog(String imageName, NativeImageGenerator generator, boolean wasSuccessfulBuild, Timer totalTimer, OptionValues parsedHostedOptions) {
463463
l().printLineSeparator();
464-
printResourceStats(millisToSeconds(totalTimer.getTotalTime()));
464+
printResourceStats();
465465
l().printLineSeparator();
466466

467467
l().yellowBold().a("Produced artifacts:").reset().flushln();
@@ -518,10 +518,11 @@ private Path reportBuildArtifacts(String imageName, Map<ArtifactType, List<Path>
518518
return ReportUtils.report("build artifacts", buildDir.resolve(imageName + ".build_artifacts.txt"), writerConsumer, !isEnabled);
519519
}
520520

521-
private void printResourceStats(double totalSeconds) {
521+
private void printResourceStats() {
522+
double totalProcessTimeSeconds = millisToSeconds(System.currentTimeMillis() - ManagementFactory.getRuntimeMXBean().getStartTime());
522523
GCStats gcStats = getCurrentGCStats();
523524
double gcSeconds = millisToSeconds(gcStats.totalTimeMillis);
524-
LinePrinter l = l().a("%.1fs (%.1f%% of total time) in %d ", gcSeconds, gcSeconds / totalSeconds * 100, gcStats.totalCount)
525+
LinePrinter l = l().a("%.1fs (%.1f%% of total time) in %d ", gcSeconds, gcSeconds / totalProcessTimeSeconds * 100, gcStats.totalCount)
525526
.doclink("GCs", "#glossary-garbage-collections");
526527
long peakRSS = ProgressReporterCHelper.getPeakRSS();
527528
if (peakRSS >= 0) {
@@ -530,7 +531,7 @@ private void printResourceStats(double totalSeconds) {
530531
OperatingSystemMXBean osMXBean = ManagementFactory.getOperatingSystemMXBean();
531532
long processCPUTime = ((com.sun.management.OperatingSystemMXBean) osMXBean).getProcessCpuTime();
532533
if (processCPUTime > 0) {
533-
l.a(" | ").doclink("CPU load", "#glossary-cpu-load").a(": ").a("~%.2f%%", nanosToSeconds(processCPUTime) / totalSeconds * 100);
534+
l.a(" | ").doclink("CPU load", "#glossary-cpu-load").a(": ").a("%.2f", nanosToSeconds(processCPUTime) / totalProcessTimeSeconds);
534535
}
535536
l.flushCenteredln();
536537
}

0 commit comments

Comments
 (0)