Skip to content

Commit ba7d3f3

Browse files
committed
[GR-51905] Post-process new Native Image PGO content.
PullRequest: graal/16962
2 parents 087f280 + bc283c2 commit ba7d3f3

File tree

8 files changed

+336
-539
lines changed

8 files changed

+336
-539
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ This reduces the set of instructions used by the compiler to a minimum and thus
3737

3838
Native Image provides additional features to further optimize a generated binary:
3939

40-
- Profile-Guided Optimizations (PGO) can provide additional performance gain and higher throughput for most native images. See [Optimize a Native Executable with PGO](guides/optimize-native-executable-with-pgo.md).
40+
- Profile-Guided Optimization (PGO) can provide additional performance gain and higher throughput for most native images. See [Profile-Guided Optimization](PGO.md).
4141
- Choosing an appropriate Garbage Collector and tailoring the garbage collection policy can reduce GC times. See [Memory Management](MemoryManagement.md).
4242
- Loading application configuration during the image build can speed up application startup. See [Class Initialization at Image Build Time](ClassInitialization.md).

docs/reference-manual/native-image/PGO-Basic-Usage.md

Lines changed: 68 additions & 141 deletions
Large diffs are not rendered by default.
Lines changed: 44 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,70 @@
11
---
22
layout: docs
33
toc_group: pgo
4-
link_title: Inspecting Profiles in Build Report
5-
permalink: /reference-manual/native-image/pgo/build-report
4+
link_title: Inspecting a Profile in a Build Report
5+
permalink: /reference-manual/native-image/optimizations-and-performance/PGO/build-reports/
66
---
77

8-
> *Note - Profile inspection assumes familiarity with fundamental PGO concepts and relies on example
9-
application covered in basic usage. If not already familiar with these yet, we recommend first
10-
reading [Profile Guided Optimization for Native Image](PGO.md) and [Basic Usage of Profile-Guided
11-
Optimizations](PGO-Basic-Usage.md).*
8+
# Inspecting a Profile in a Build Report
129

13-
# Inspecting Profiles in Build Report
14-
15-
* [Profile Visualization Generation](#profile-visualization-generation)
16-
* [Profile Inspection using Build Report](#profile-inspection-using-build-report)
17-
18-
Profiles play an essential part in efficient AOT compilation by Native Image. They contain the information
19-
about a particular execution of the application, and are used to guide the additional optimizations that
10+
A profile plays an essential part in efficient AOT compilation by Native Image.
11+
It contains the information about a particular execution of the application, and is used to guide additional optimizations that
2012
further improve application performance.
21-
It is often useful to visualize the information in the profile.
22-
This section explains how to inspect parts of the profile using the Build Report tool.
23-
24-
## Profile Visualization Generation
25-
26-
To generate a profile information about a particular application, one must first create an
27-
instrumented image. After a successful compilation and execution, the binary will store the collected
28-
information in an iprof file. This file represents the *profile* of that concrete execution and is
29-
used for profile-guided optimization in a subsequent build.
13+
It is often useful to visualize the information in a profile.
14+
This section explains how to inspect parts of a profile using the Native Image **Build Report** tool.
3015

31-
Build Report is a tool for displaying various data about the image build. Among other things, Build
32-
Report can be used for visualizing profiling information recorded by the sampler. The samples are
33-
aggregated into a single flame graph. This is particularly useful for exploring how different methods
34-
contribute to overall execution time.
35-
Also, the graph is color-coded to show how the inliner made the inlining decisions during the compilation
36-
(more on that in [the following section](#profile-inspection-using-build-report)).
16+
## Generating a Profile Visualization
3717

38-
To generate a report with the visualization for the Game-Of-Life example, we only have to pass the
39-
additional `-H:+BuildReport` and `-H:+BuildReportSamplerFlamegraph` options to the optimized image
40-
build:
18+
The Build Report tool displays various data about the generated image and the build process itself.
19+
Among other things, the tool can visualize profiling information recorded by the sampler, which is useful for exploring how different methods contribute to overall execution time.
20+
The samples are aggregated into a single _flame graph_.
21+
The flame graph is color-coded to show how the inliner made the inlining decisions during the compilation (more on that below).
4122

23+
To generate a comprehensive report with the visualization, pass the `-H:+BuildReport` and `-H:+BuildReportSamplerFlamegraph` options at the step when you build a PGO-optimized native executable.
24+
For example:
4225
``` bash
43-
# Note - GRAALVM_HOME environment variable should point to a GraalVM installation.
44-
$ $GRAALVM_HOME/bin/javac GameOfLife.java
45-
$ $GRAALVM_HOME/bin/native-image -cp . GameOfLife -o gameoflife-instrumented --pgo-instrument
46-
$ ./gameoflife-instrumented -XX:ProfilesDumpFile=gameoflife.iprof input.txt output.txt 10
47-
$ $GRAALVM_HOME/bin/native-image -cp . GameOfLife -o gameoflife-pgo --pgo=gameoflife.iprof -H:+BuildReport -H:+BuildReportSamplerFlamegraph
26+
native-image -cp . GameOfLife -o gameoflife-pgo --pgo=gameoflife.iprof -H:+BuildReport -H:+BuildReportSamplerFlamegraph
4827
```
28+
> Refer to [Basic Usage of Profile-Guided Optimization](PGO-Basic-Usage.md) for the step-by-step guide.
4929
50-
> *Note - Refer to [Basic Usage of Profile-Guided Optimizations](PGO-Basic-Usage.md) for the full
51-
step-by-step guide.*
30+
## Inspecting a Profile Using a Build Report
5231

53-
## Profile Inspection using Build Report
32+
Profiling information recorded by the Native Image sampler is visualized in form of a flame graph - a hierarchical chart that aggregates multiple stack traces.
33+
This flame graph is specialized in differentiating "hot" vs. "cold" compilation units.
34+
There are three distinct colors:
35+
- **red**: used for marking root methods of hot compilation units;
36+
- **blue**: used for all the methods inlined into a hot compilation root;
37+
- **gray**: represents the "cold" code.
5438

55-
The sampling profile information used in an optimized compilation in visualized in form of a flame
56-
graph - a hierarchical chart that aggregates multiple stack traces. This flame graph is specialized
57-
for differentiating hot vs. cold compilation units. There are three distinct colors (can also be seen
58-
by showing legend with "?"):
59-
60-
- **Red** - used for marking root methods of hot compilation units,
61-
- **Blue** - used for all the methods inlined into hot compilation root, and
62-
- **Gray** - represents the "cold" code.
63-
64-
> *Note - The color descriptions and other useful information are part of chart legend (can be toggled
65-
by clicking "?").*
39+
> Note: The color descriptions and other useful information are part of a chart legend, and can be toggled by clicking "?".
6640
6741
![Flame Graph Preview](images/pgo-flame-graph-preview.png)
6842

69-
The graph itself provides a couple of functionalities. First, a user can hover over the specific
70-
method bar to see more information about that method such as number of samples and the percentage
71-
related to total number of samples. Besides that, there is the ability to "zoom" into a particular
72-
method (by clicking on it) to see all the subsequent calls in that call chain more clearly. One can
73-
reset the view using *Reset Zoom* button in top-left corner.
43+
The graph itself provides a couple of functionalities.
44+
A user can hover over a specific method bar to see more information about that method, for example, a number of samples and the percentage related to the total number of samples.
45+
Besides that, there is the ability to "zoom" into a particular method (by clicking on it) and see all the subsequent calls in that call chain more clearly.
46+
One can reset the view using the **Reset Zoom** button in top-left corner.
7447

7548
![Flame Graph Zoom](images/pgo-flame-graph-zoom.png)
7649

77-
Additionally, there is a search button (*Search*) located in top-right corner of the graph. It can be
78-
used to highlight a specific method or group of methods that match the search criteria (the method(s)
79-
will be colored yellow). Also, there is a *Matched* field that represents that group's share in the
80-
total number of samples (showed underneath the chart in the right half). Note that this is also a
81-
relative share - it will be readjusted when expanding/collapsing the view. There is also a *Reset
82-
Search* button that can cancel the search at any time.
50+
Additionally, there is a search button (**Search**) located in top-right corner of the graph.
51+
It can be used to highlight a specific method or a group of methods that match the search criteria (the method(s)
52+
will be colored yellow).
53+
Also, there is a **Matched** field that represents the group share in the total number of samples (showed underneath the chart in the right half).
54+
Note that this is also a relative share - it will be readjusted when expanding/collapsing the view.
55+
One can also use a **Reset Search** button to cancel the search at any time.
8356

8457
![Flame Graph Search](images/pgo-flame-graph-search.png)
8558

86-
The flame graph also comes with the additional histogram (below it). It shows the individual methods'
87-
contributions in the total execution time (descending by the number of samples). These bars are also
88-
clickable, and the click has the same effect as searching - it highlights that particular method in
89-
the flame graph above. Additional click on that same bar will reset the highlighting.
59+
The flame graph comes with the additional histogram (below it).
60+
It shows the individual methods' contributions to the total execution time (descending by the number of samples).
61+
These bars are also clickable, and the click has the same effect as searching - it highlights that particular method in
62+
the flame graph above.
63+
Additional click on that same bar resets the highlighting.
9064

9165
![Histogram Highlight](images/pgo-histogram-highlight.png)
66+
67+
### Further Reading
68+
69+
* [Tracking Profile Quality](PGO-Profile-Quality.md)
70+
* [Merging Profiles from Multiple Sources](PGO-Merging-Profiles.md)

0 commit comments

Comments
 (0)