Skip to content

Commit 9b202ab

Browse files
committed
Improve and fix ProgressReporter.
- Add documentation - List packages (not classes) in code breakdown - List size of "other data" - Print runtime compiled methods after analysis - Add and fix some links - Minor other improvements
1 parent f0a778e commit 9b202ab

File tree

4 files changed

+220
-66
lines changed

4 files changed

+220
-66
lines changed

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

Lines changed: 144 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,164 @@ permalink: /reference-manual/native-image/BuildOutput/
66
---
77
# Native Image Build Output
88

9-
## Glossary
9+
This page provides documentation for the build output of GraalVM Native Image.
10+
11+
## HelloWorld Example Output
12+
```
13+
================================================================================
14+
GraalVM Native Image: Generating 'helloworld'...
15+
================================================================================
16+
[1/7] Initializing... (5.1s @ 0.22GB)
17+
Version info: 'GraalVM dev Java 11 CE'
18+
1 user-provided feature(s)
19+
- HelloWorld$MyFeature
20+
18 classes registered for reflection
21+
[2/7] Performing analysis... [*******] (9.7s @ 1.07GB)
22+
11,598 (72.45%) of 16,008 methods reachable
23+
2,553 (83.24%) of 3,067 classes reachable
24+
[3/7] Building universe... (0.9s @ 0.38GB)
25+
[4/7] Parsing methods... [*] (0.8s @ 0.58GB)
26+
[5/7] Inlining methods... [****] (1.1s @ 1.21GB)
27+
[6/7] Compiling methods... [*********] (8.2s @ 1.94GB)
28+
[7/7] Creating image... (1.7s @ 2.28GB)
29+
10.30MB in total (35.7% code area, 56.8% image heap, and 7.5% other data)
30+
3.67MB for code area: 6,918 compilation units
31+
5.86MB for image heap: 1,537 classes and 80,370 objects
32+
790.25KB for other data
33+
--------------------------------------------------------------------------------
34+
Top 10 packages in code area: Top 10 object types in image heap:
35+
609.50KB java.util 1.64MB byte[] for general data
36+
283.62KB java.lang 713.72KB java.lang.String
37+
223.08KB java.util.regex 546.84KB java.lang.Class
38+
219.70KB java.text 449.59KB byte[] for java.lang.String
39+
193.77KB com.oracle.svm.jni 363.66KB java.util.HashMap$Node
40+
150.15KB java.util.concurrent 192.28KB java.util.HashMap$Node[]
41+
114.75KB java.math 139.25KB java.lang.String[]
42+
103.51KB com.oracle.svm.core.reflect 139.04KB char[]
43+
101.82KB sun.text.normalizer 130.59KB j.u.c.ConcurrentHashMap$Node
44+
88.48KB sun.util.locale.provider 103.92KB s.u.l.LocaleObjec~e$CacheEntry
45+
... 109 additional packages ... 718 additional object types
46+
(use GraalVM Dashboard to see all)
47+
--------------------------------------------------------------------------------
48+
1.0s spent in 15 GCs | Peak RSS: 2.58GB | CPU load: ~616.47%
49+
--------------------------------------------------------------------------------
50+
Produced artifacts:
51+
/Users/fniephaus/Downloads/helloworld/helloworld (executable)
52+
/Users/fniephaus/Downloads/helloworld/helloworld.build_artifacts.txt
53+
================================================================================
54+
Finished generating 'helloworld' in 28.8s.
55+
```
1056

11-
### <a name="glossary-user-provided-features">User-provided features
57+
## Build Stages
1258

13-
### <a name="glossary-reflection-classes">Classes registered for reflection
59+
### <a name="stage-initializing"></a>Initializing
1460

15-
### <a name="glossary-reachability"/>Reachable classes and methods
61+
In this stage, the Native Image build process is being set up.
62+
This includes loading all classes, detecting [`Features`][jdoc_feature], and [registering classes for reflection](#glossary-reflection-classes).
1663

17-
### <a name="glossary-runtime-methods"/>Runtime compiled methods
64+
#### <a name="glossary-version-info"></a>Version Info
65+
The version info of the Native Image process.
66+
This string is also used for the `java.vm.version` property within the generated image.
67+
Please report this version info when you [file issues][new_issue].
1868

19-
### <a name="glossary-code-area"/>Code Area
69+
#### <a name="glossary-user-provided-features"></a>User-provided Features
70+
All [`Features`][jdoc_feature] that are provided by the user or implicitly registered for the user, for example, by a framework.
71+
GraalVM Native Image deploys a number of internal features, which are excluded from this list.
2072

21-
### <a name="glossary-image-heap"/>Image Heap
73+
#### <a name="glossary-reflection-classes"></a>Classes Registered for Reflection
74+
The number of classes that are registered for reflection.
75+
A large number can cause significant reflection overheads, slow down the build process, and increase the size of the native image (see [method metadata](#glossary-method-metadata)).
2276

23-
### <a name="glossary-peak-rss"/>Peak RSS
77+
### <a name="stage-analysis"></a>Performing Analysis
78+
In this stage, a [points-to analysis][oopsla19_initialize_once_start_fast] is performed.
79+
The progress indicator visualizes the number of analysis iterations.
80+
A large number of iterations can indicate problems in the analysis likely caused by misconfiguration.
2481

25-
### <a name="glossary-cpu-load"/>CPU load
82+
#### <a name="glossary-reachability"></a>Reachable Classes and Methods
83+
The number of classes and methods that are reachable versus the total number of classes and methods loaded as part of the build process.
84+
A significantly larger number of loaded classes that are not reachable can indicate a configuration problem.
85+
To reduce overhead, please ensure that the classpath only contains entries that are needed for building the application.
2686

87+
#### <a name="glossary-runtime-methods"></a>Runtime Compiled Methods
88+
The number of methods marked for runtime compilation.
89+
This number is only shown if runtime compilation is available, for example, when building a[Truffle][truffle] language.
90+
Runtime compiled methods account for [graph encodings](#glossary-graph-encodings) in the image heap.
2791

28-
## Build Stages
92+
### <a name="stage-universe"></a>Building Universe
93+
In this stage, a universe with all classes, methods, and fields is built, which is then used to create the native image.
94+
95+
### <a name="stage-parsing"></a>Parsing Methods
96+
In this stage, the Graal compiler parses all reachable methods.
97+
The progress indicator is printed periodically after a certain interval.
98+
99+
### <a name="stage-inlining"></a>Inlining Methods
100+
In this stage, trivial method inlining is performed.
101+
The progress indicator visualizes the number of inlining iterations.
102+
103+
### <a name="stage-compiling"></a>Compiling Methods
104+
In this stage, the Graal compiler compiles all reachable methods to machine code.
105+
The progress indicator is printed periodically after a certain interval.
106+
107+
### <a name="stage-creating"></a>Creating Image
108+
In this stage, the native image is created and written to disk.
109+
110+
#### <a name="glossary-code-area"></a>Code Area
111+
The code area contains machine code produced by the Graal compiler for all reachable methods.
112+
Therefore, reducing the number of reachable methods also reduces the size of the code area.
113+
114+
#### <a name="glossary-image-heap"></a>Image Heap
115+
The image heap contains reachable objects such as static data, classes initialized at run-time, and `byte[]` for different purposes.
116+
117+
##### <a name="glossary-general-heap-data"></a>General Heap Data Stored in `byte[]`
118+
The total size of all `byte[]` objects that are neither used for `java.lang.String`, nor [graph encodings](#glossary-graph-encodings), nor [method metadata](#glossary-method-metadata).
119+
This typically dominates
120+
121+
##### <a name="glossary-graph-encodings"></a>Graph Encodings Stored in `byte[]`
122+
The total size of all `byte[]` objects used for graph encodings.
123+
These encodings are a result of [runtime compiled methods](#glossary-runtime-methods).
124+
Therefore, reducing the number of such methods also reduces the size of corresponding graph encodings.
125+
126+
##### <a name="glossary-method-metadata"></a>Method Metadata Stored in `byte[]`
127+
The total size of all `byte[]` objects used for method metadata, a type of reflection metadata.
128+
To reduce the amount of method metadata, reduce the number of [classes registered for reflection](#glossary-reflection-classes).
129+
130+
#### <a name="glossary-other-data"></a>Other Data
131+
The amount of data in the image that is neither in the [code area](#glossary-code-area) nor in the [image heap](#glossary-image-heap).
132+
This data typically contains internal information for Native Image but it can also contain other information such as debug info.
133+
134+
### Resource Usage Statistics
29135

30-
### <a name="step-initializing"/>Initializing
136+
#### <a name="glossary-garbage-collection"></a>Garbage Collections
137+
The total number of garbage collections and total time spent in all garbage collectors.
138+
A large number of collections or time spent in collectors usually indicates that the system is under memory pressure.
139+
Increase the amount of available memory to reduce the time to build the image.
31140

32-
### <a name="step-analysis"/>Performing analysis
141+
#### <a name="glossary-peak-rss"></a>Peak RSS
142+
Peak [resident set size][rss_wiki] as reported by the operating system.
143+
This value indicates the maximum amount of memory consumed by the build process.
144+
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.
33145

34-
### <a name="step-universe"/>Building universe
146+
#### <a name="glossary-cpu-load"></a>CPU load
147+
The CPU time used by the process divided by the total time to build the image in percent.
148+
Increase the number of CPU threads to reduce the time to build the image.
35149

36-
### <a name="step-parsing"/>Parsing methods
150+
## Build Output Options
37151

38-
### <a name="step-inlining"/>Inlining methods
152+
Run `native-image --expert-options-all | grep "BuildOutput"` to see all build output options:
39153

40-
### <a name="step-compiling"/>Compiling methods
154+
```
155+
-H:±BuildOutputBreakdowns Show code and heap breakdowns as part of the build output. Default: + (enabled).
156+
-H:±BuildOutputColorful Colorize build output. Default: + (enabled).
157+
-H:±BuildOutputGCWarnings Print GC warnings as part of build output. Default: + (enabled).
158+
-H:±BuildOutputLinks Show links in build output. Default: + (enabled).
159+
-H:±BuildOutputPrefix Prefix build output with '<pid>:<image name>'. Default: - (disabled).
160+
-H:±BuildOutputProgress Report progress in build output. Default: + (enabled).
161+
-H:±BuildOutputUseNewStyle Use new build output style. Default: + (enabled).
162+
```
41163

42-
### <a name="step-creation"/>Creating image
164+
165+
[jdoc_feature]: https://www.graalvm.org/sdk/javadoc/org/graalvm/nativeimage/hosted/Feature.html
166+
[new_issue]: https://github.com/oracle/graal/issues/new
167+
[oopsla19_initialize_once_start_fast]: https://dl.acm.org/doi/10.1145/3360610
168+
[rss_wiki]: https://en.wikipedia.org/wiki/Resident_set_size
169+
[truffle]: https://github.com/oracle/graal/tree/master/truffle

substratevm/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ This changelog summarizes major changes to GraalVM Native Image.
1111
* (GR-32403) Use more compressed encoding for stack frame metadata.
1212
* (GR-35152) Add -H:DisableURLProtocols to allow specifying URL protocols that must never be included in the image.
1313
* (GR-35085) Custom prologue/epilogue/handleException customizations of @CEntryPoint must be annotated with @Uninterruptible. The entry points synthetic methods are now implicilty annotated with @Uninterruptible too.
14-
* (GR-33602) Enable new user-friendly build output mode. The old output can be restored with `-H:-BuildOutputUseNewStyle`. Run `native-image --expert-options-all | grep "BuildOutput` to see all options for the new output.
14+
* (GR-33602) Enable [new user-friendly build output mode](https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/BuildOutput.md). The old output can be restored with `-H:-BuildOutputUseNewStyle`.

substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/hosted/GraalFeature.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,11 @@ public static String buildSourceReference(FrameState startState) {
640640
return sourceReferenceBuilder.toString();
641641
}
642642

643+
@Override
644+
public void afterAnalysis(AfterAnalysisAccess access) {
645+
ProgressReporter.singleton().setNumRuntimeCompiledMethods(methods.size());
646+
}
647+
643648
@Override
644649
@SuppressWarnings("try")
645650
public void beforeCompilation(BeforeCompilationAccess c) {
@@ -649,8 +654,6 @@ public void beforeCompilation(BeforeCompilationAccess c) {
649654
printCallTree();
650655
}
651656

652-
ProgressReporter.singleton().printRuntimeCompileMethods(methods.size(), config.getMethods().size());
653-
654657
if (Options.PrintStaticTruffleBoundaries.getValue()) {
655658
printStaticTruffleBoundaries();
656659
}

0 commit comments

Comments
 (0)