|
1 | 1 | --- |
2 | 2 | layout: docs |
3 | 3 | 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/ |
6 | 6 | --- |
7 | 7 |
|
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 |
12 | 9 |
|
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 |
20 | 12 | 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. |
30 | 15 |
|
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 |
37 | 17 |
|
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). |
41 | 22 |
|
| 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: |
42 | 25 | ``` 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 |
48 | 27 | ``` |
| 28 | +> Refer to [Basic Usage of Profile-Guided Optimization](PGO-Basic-Usage.md) for the step-by-step guide. |
49 | 29 |
|
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 |
52 | 31 |
|
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. |
54 | 38 |
|
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 "?". |
66 | 40 |
|
67 | 41 |  |
68 | 42 |
|
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. |
74 | 47 |
|
75 | 48 |  |
76 | 49 |
|
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. |
83 | 56 |
|
84 | 57 |  |
85 | 58 |
|
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. |
90 | 64 |
|
91 | 65 |  |
| 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