Skip to content

Commit c620754

Browse files
committed
Improve image statistics.
1 parent d3c496f commit c620754

File tree

2 files changed

+41
-36
lines changed

2 files changed

+41
-36
lines changed

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

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,49 +9,52 @@ permalink: /reference-manual/native-image/BuildOutput/
99
This page provides documentation for the build output of GraalVM Native Image.
1010

1111
## HelloWorld Example Output
12-
```
12+
```text
1313
================================================================================
1414
GraalVM Native Image: Generating 'helloworld'...
1515
================================================================================
16-
[1/7] Initializing... (2.1s @ 0.19GB)
16+
[1/7] Initializing... (2.5s @ 0.21GB)
1717
Version info: 'GraalVM dev Java 11 CE'
18-
[2/7] Performing analysis... [*******] (5.7s @ 0.47GB)
18+
[2/7] Performing analysis... [*******] (5.6s @ 0.46GB)
1919
2,565 (82.61%) of 3,105 classes reachable
2020
3,216 (60.42%) of 5,323 fields reachable
21-
11,653 (72.44%) of 16,087 methods reachable
21+
11,652 (72.44%) of 16,086 methods reachable
2222
27 classes, 0 fields, and 135 methods registered for reflection
2323
57 classes, 59 fields, and 51 methods registered for JNI access
24-
[3/7] Building universe... (0.4s @ 0.63GB)
25-
[4/7] Parsing methods... [*] (0.4s @ 0.83GB)
26-
[5/7] Inlining methods... [****] (0.4s @ 0.67GB)
27-
[6/7] Compiling methods... [**] (3.4s @ 1.38GB)
28-
[7/7] Creating image... (0.8s @ 1.65GB)
29-
10.52MB in total (35.1% code area, 55.7% image heap, and 9.3% other data)
30-
3.69MB for code area: 6,955 compilation units
31-
5.86MB for image heap: 1,545 classes and 81,111 objects
32-
997.09KB for other data
24+
[3/7] Building universe... (0.5s @ 0.61GB)
25+
[4/7] Parsing methods... [*] (0.5s @ 0.86GB)
26+
[5/7] Inlining methods... [****] (0.5s @ 0.73GB)
27+
[6/7] Compiling methods... [**] (3.7s @ 2.38GB)
28+
[7/7] Creating image... (2.1s @ 1.04GB)
29+
3.69MB (27.19%) for code area: 6,955 compilation units
30+
5.86MB (43.18%) for image heap: 1,545 classes and 80,528 objects
31+
3.05MB (22.46%) for debug info generated in 1.0s
32+
997.25KB ( 7.18%) for other data
33+
13.57MB in total
3334
--------------------------------------------------------------------------------
3435
Top 10 packages in code area: Top 10 object types in image heap:
35-
606.11KB java.util 1.64MB byte[] for general heap data
36-
282.34KB java.lang 718.09KB java.lang.String
36+
606.23KB java.util 1.64MB byte[] for general heap data
37+
282.34KB java.lang 715.56KB java.lang.String
3738
222.47KB java.util.regex 549.46KB java.lang.Class
38-
219.55KB java.text 454.06KB byte[] for java.lang.String
39+
219.55KB java.text 451.79KB byte[] for java.lang.String
3940
193.17KB com.oracle.svm.jni 363.23KB java.util.HashMap$Node
40-
149.80KB java.util.concurrent 192.11KB java.util.HashMap$Node[]
41-
118.09KB java.math 139.04KB char[]
42-
103.60KB com.oracle.svm.core.reflect 136.48KB java.lang.String[]
41+
149.80KB java.util.concurrent 192.00KB java.util.HashMap$Node[]
42+
118.07KB java.math 139.83KB java.lang.String[]
43+
103.60KB com.oracle.svm.core.reflect 139.04KB char[]
4344
97.83KB sun.text.normalizer 130.59KB j.u.c.ConcurrentHashMap$Node
4445
88.78KB c.oracle.svm.core.genscavenge 103.92KB s.u.l.LocaleObjec~e$CacheEntry
4546
... 111 additional packages ... 723 additional object types
4647
(use GraalVM Dashboard to see all)
4748
--------------------------------------------------------------------------------
48-
0.8s (5.4% of total time) in 17 GCs | Peak RSS: 2.60GB | CPU load: 11.83
49+
0.9s (5.6% of total time) in 17 GCs | Peak RSS: 3.22GB | CPU load: 10.87
4950
--------------------------------------------------------------------------------
5051
Produced artifacts:
5152
/home/janedoe/helloworld/helloworld (executable)
53+
/home/janedoe/helloworld/sources (debug_info)
54+
/home/janedoe/helloworld/helloworld (debug_info)
5255
/home/janedoe/helloworld/helloworld.build_artifacts.txt
5356
================================================================================
54-
Finished generating 'helloworld' in 14.0s.
57+
Finished generating 'helloworld' in 16.2s.
5558
```
5659

5760
## Build Stages

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

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -349,22 +349,24 @@ public void setDebugInfoTimer(Timer timer) {
349349
public void printCreationEnd(Timer creationTimer, Timer writeTimer, int imageSize, AnalysisUniverse universe, int numHeapObjects, long imageHeapSize, int codeCacheSize,
350350
int numCompilations, int debugInfoSize) {
351351
printStageEnd(creationTimer.getTotalTime() + writeTimer.getTotalTime());
352-
String total = bytesToHuman("%4.2f", imageSize);
353-
long otherBytes = imageSize - codeCacheSize - imageHeapSize;
354-
l().a("%9s in total (%.1f%% ", total, codeCacheSize / (double) imageSize * 100).doclink("code area", "#glossary-code-area")
355-
.a(", %.1f%% ", imageHeapSize / (double) imageSize * 100).doclink("image heap", "#glossary-image-heap")
356-
.a(", and %.1f%% ", otherBytes / (double) imageSize * 100).doclink("other data", "#glossary-other-data").a(")").flushln();
357-
l().a("%9s for code area:%,9d compilation units", bytesToHuman("%4.2f", codeCacheSize), numCompilations).flushln();
352+
String format = "%9s (%5.2f%%) for ";
353+
l().a(format, bytesToHuman(codeCacheSize), codeCacheSize / (double) imageSize * 100)
354+
.doclink("code area", "#glossary-code-area").a(":%,9d compilation units", numCompilations).flushln();
358355
long numInstantiatedClasses = universe.getTypes().stream().filter(t -> t.isInstantiated()).count();
359-
l().a("%9s for image heap:%,8d classes and %,d objects", bytesToHuman("%4.2f", imageHeapSize), numInstantiatedClasses, numHeapObjects).flushln();
356+
l().a(format, bytesToHuman(imageHeapSize), imageHeapSize / (double) imageSize * 100)
357+
.doclink("image heap", "#glossary-image-heap").a(":%,8d classes and %,d objects", numInstantiatedClasses, numHeapObjects).flushln();
360358
if (debugInfoSize > 0) {
361-
l().a("%9s in debugInfo size", bytesToHuman("%4.2f", debugInfoSize)).flushln();
362-
}
363-
l().a("%9s for other data", bytesToHuman("%4.2f", otherBytes)).flushln();
364-
if (debugInfoTimer != null) {
365-
String debugInfoTime = String.format("%.1fs", millisToSeconds(debugInfoTimer.getTotalTime()));
366-
l().dim().a("%9s for generating debug info", debugInfoTime).reset().flushln();
359+
LinePrinter l = l().a(format, bytesToHuman(debugInfoSize), debugInfoSize / (double) imageSize * 100)
360+
.doclink("debug info", "#glossary-debug-info");
361+
if (debugInfoTimer != null) {
362+
l.a(" generated in %.1fs", millisToSeconds(debugInfoTimer.getTotalTime()));
363+
}
364+
l.flushln();
367365
}
366+
long otherBytes = imageSize - codeCacheSize - imageHeapSize - debugInfoSize;
367+
l().a(format, bytesToHuman(otherBytes), otherBytes / (double) imageSize * 100)
368+
.doclink("other data", "#glossary-other-data").flushln();
369+
l().a("%9s in total", bytesToHuman(imageSize)).flushln();
368370
}
369371

370372
public void printBreakdowns(Collection<CompileTask> compilationTasks, Collection<ObjectInfo> heapObjects) {
@@ -387,7 +389,7 @@ public void printBreakdowns(Collection<CompileTask> compilationTasks, Collection
387389
if (packagesBySize.hasNext()) {
388390
Entry<String, Long> e = packagesBySize.next();
389391
String className = truncateClassOrPackageName(e.getKey());
390-
codeSizePart = String.format("%9s %s", bytesToHuman("%4.2f", e.getValue()), className);
392+
codeSizePart = String.format("%9s %s", bytesToHuman(e.getValue()), className);
391393
printedCodeSizeEntries.add(e);
392394
}
393395

@@ -675,7 +677,7 @@ private static double getUsedMemory() {
675677
}
676678

677679
private static String bytesToHuman(long bytes) {
678-
return bytesToHuman("%.2f", bytes);
680+
return bytesToHuman("%4.2f", bytes);
679681
}
680682

681683
private static String bytesToHuman(String format, long bytes) {

0 commit comments

Comments
 (0)