You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `-g` option instructs Native Image to produce debug information for the generated binary.
76
76
`perf` can use this debug information, for example, to provide proper names for types and methods in traces.
77
+
The `-H:+PreserveFramePointer` option instructs Native Image to save frame pointers on the stack.
78
+
This allows `perf` to reliably unwind stack frames and reconstruct the call hierarchy.
79
+
80
+
### Profiling of Runtime-Compiled Methods
81
+
82
+
Native Image can generate detailed runtime compilation metadata for perf in the [jitdump](https://github.com/torvalds/linux/blob/46a51f4f5edade43ba66b3c151f0e25ec8b69cb6/tools/perf/Documentation/jitdump-specification.txt) format.
83
+
This enables perf profiling of runtime compiled methods, for example for Truffle compilations.
84
+
85
+
#### jitdump
86
+
87
+
The jitdump format stores detailed metadata for runtime compiled code.
88
+
This requires post-processing of the perf data to inject the runtime compilation metadata.
At image-runtime, the jitdump file _<jitdump_dir>/jit-<pid>.dump_ is created, and runtime compilation metadata is written to it.
97
+
The output directory can be configured with `-R:RuntimeJitdumpDir=<jitdump_dir>` (defaults to _./jitdump_).
98
+
99
+
2. Record with perf:
100
+
101
+
When recording profiling data, use the `-k 1` option to ensure time-based events are ordered correctly for injection:
102
+
103
+
```bash
104
+
perf record -k 1 -o perf.data <your-application>
105
+
```
106
+
107
+
If the perf data was not recorded with `-k 1`, injecting runtime compilation metadata from a jitdump file will fail.
108
+
109
+
3. Inject jitdump into perf data:
110
+
111
+
```bash
112
+
perf inject -j -i perf.data -o perf.jit.data
113
+
```
114
+
115
+
This step:
116
+
- Locates the jitdump file.
117
+
- Generates a _.so_ file for each runtime compilation entry in the jitdump file.
118
+
- Injects runtime compilation metadata into the profiling data and stores it in _perf.jit.data_.
119
+
120
+
4. Inspect profiling data:
121
+
122
+
```bash
123
+
perf report -i perf.jit.data
124
+
```
125
+
126
+
Symbols from the jitdump file appear as coming from _jitted-<pid>-<code_id>.so_, where `code_id` is the index of a compilation entry in the jitdump file.
77
127
78
128
## Basic Operations
79
129
@@ -141,6 +191,79 @@ The `-g` option instructs Native Image to produce debug information for the gene
141
191
142
192
This command generates a script that can be used for analyzing the recorded trace data.
143
193
194
+
## Generating Flame Graphs from Profiling Data
195
+
196
+
[FlameGraph](https://github.com/brendangregg/FlameGraph) is a tool written in Perl that can be used to produce flame graphs from perf profiling data.
197
+
Flame graphs generated by this tool visualize stack samples as interactive SVGs, making it easy to identify hot code paths in an application.
198
+
199
+
1. Download the tool and record profiling data as described in [Basic Operations](#basic-operations).
200
+
201
+
Make sure the profiling data was recorded with `-g` to capture call graphs, otherwise the flame graph will be flat.
Use an application to view the generated SVG file (for example, `firefox`, `chromium`).
216
+
```bash
217
+
firefox perf.data.svg
218
+
```
219
+
220
+
### Highlighting Runtime-Compiled Methods
221
+
222
+
If the native image supports [profiling of runtime-compiled methods](#profiling-of-runtime-compiled-methods), it is possible to highlight runtime-compiled symbols in the flame graph.
223
+
224
+
1. Build the native image with jitdump support, record profiling data and inject the jitdump information as described in [jitdump](#jitdump).
225
+
226
+
2. Fold stacks:
227
+
228
+
This involves folding the stacks for the non-jitdump-injected _perf.data_ and the jitdump-injected _perf.jit.data_.
Copy file name to clipboardExpand all lines: substratevm/CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,7 @@ This changelog summarizes major changes to GraalVM Native Image.
6
6
* (GR-44384) Add size warnings for bundles when individual or cumulative file sizes exceed limits. Configure with options `size-warning-file-limit` and `size-warning-total-limit` to `bundle-create`, sizes in MiB.
7
7
* (GR-43070) Add a new API flag `-Werror` to treat warnings as errors.
8
8
* (GR-69280) Allow use of the `graal.` prefix for options without issuing a warning.
9
+
* (GR-2092) Add jitdump support for recording run-time compilation metadata for perf (see PerfProfiling.md). Can be enabled with `-g -H:+RuntimeDebugInfo -H:RuntimeDebugInfoFormat=jitdump`.
9
10
10
11
## GraalVM 25
11
12
* (GR-52276) (GR-61959) Add support for Arena.ofShared().
Copy file name to clipboardExpand all lines: substratevm/debug/include/gdb_jit_compilation_interface.h
+5-1Lines changed: 5 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -27,7 +27,9 @@
27
27
#defineSVM_NATIVE_GDBJITCOMPILATIONINTERFACE_H
28
28
29
29
// This header specifies the types used by the GDB JIT compilation interface (see https://sourceware.org/gdb/current/onlinedocs/gdb.html/Declarations.html#Declarations)
30
-
// The implementation of the JIT compilation interface is located in com.oracle.svm.core.debug.GdbJitInterface.
30
+
// The implementation of the JIT compilation interface is located in com.oracle.svm.core.debug.gdb.GdbJitInterface.
* Copyright (c) 2025, 2025, Oracle and/or its affiliates. All rights reserved.
3
+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
+
*
5
+
* This code is free software; you can redistribute it and/or modify it
6
+
* under the terms of the GNU General Public License version 2 only, as
7
+
* published by the Free Software Foundation. Oracle designates this
8
+
* particular file as subject to the "Classpath" exception as provided
9
+
* by Oracle in the LICENSE file that accompanied this code.
10
+
*
11
+
* This code is distributed in the hope that it will be useful, but WITHOUT
12
+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
+
* version 2 for more details (a copy is included in the LICENSE file that
15
+
* accompanied this code).
16
+
*
17
+
* You should have received a copy of the GNU General Public License version
18
+
* 2 along with this work; if not, write to the Free Software Foundation,
19
+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20
+
*
21
+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
+
* or visit www.oracle.com if you need additional information or have any
23
+
* questions.
24
+
*/
25
+
26
+
#ifndefSVM_NATIVE_JITDUMPRECORDS_H
27
+
#defineSVM_NATIVE_JITDUMPRECORDS_H
28
+
29
+
#ifdef__linux__
30
+
31
+
// This header specifies the jitdump entries described in the Jitdump specification (see https://github.com/torvalds/linux/blob/46a51f4f5edade43ba66b3c151f0e25ec8b69cb6/tools/perf/Documentation/jitdump-specification.txt)
32
+
// The implementation of the Jitdump provider generating these entries is located in com.oracle.svm.core.posix.debug.jitdump.JitdumpProvider.
0 commit comments