|
1 | 1 | # Profiling TruffleRuby
|
2 | 2 |
|
3 |
| -There is no shortage of tools for profiling TruffleRuby. When running in JVM mode, we can |
4 |
| -use standard JVM tooling, such as VisualVM and Java Flight Recorder. When run as a native |
5 |
| -image we can use callgrind from the valgrind tool suite and other system tools, such as |
6 |
| -strace. As an instrumented Truffle language, we can also use Truffle's profiling |
7 |
| -capabilities. For a broad enough definition of profiling, we can also use the Ideal Graph |
8 |
| -Visualizer (IGV) and C1 Visualizer to inspect Graal's output. |
| 3 | +There is no shortage of tools for profiling TruffleRuby. When running in JVM |
| 4 | +mode, we can use standard JVM tooling, such as VisualVM and Java Flight |
| 5 | +Recorder. When run as a native image we can use callgrind from the Valgrind |
| 6 | +tool suite and other system tools, such as strace. As an instrumented Truffle |
| 7 | +language, we can also use Truffle's profiling capabilities and other [user |
| 8 | +tools](../user/tools.md). For a broad enough definition of profiling, we can |
| 9 | +also use the Ideal Graph Visualizer (IGV) and C1 Visualizer to inspect Graal's |
| 10 | +output. |
9 | 11 |
|
10 | 12 | This document is less about how to use each tool and more about suggestions for extracting
|
11 | 13 | the most useful information from the tools, assuming basic knowledge of their usage.
|
12 | 14 |
|
13 |
| -## Truffle Profiling |
14 |
| - |
15 |
| -Truffle provides both a CPU sampler and a CPU tracer. To see the full list of options, run |
16 |
| -`jt ruby --help:tools`. By default, the output is a histogram format that looks quite |
17 |
| -similar to gprof's flat profile and it is printed directly to STDOUT. |
18 |
| - |
19 |
| -### CPU Tracer |
20 |
| - |
21 |
| -The CPU tracer can be invoked via `jt ruby --cputracer`. It provides method invocation |
22 |
| -counts, but not elapsed time. It can be a good way to see which methods should be optimized |
23 |
| -or for discovering calls that are being called more frequently than expected. |
24 |
| - |
25 |
| -### CPU Sampler |
26 |
| - |
27 |
| -The CPU sampler can be invoked via `jt ruby --cpusampler`. It provides sampled execution |
28 |
| -times for both the total time of the method call (i.e., the method & its subcalls) |
29 |
| -and just the method's execution time (i.e., ignoring calls made from the method). It does |
30 |
| -not provide invocation counts. |
31 |
| - |
32 | 15 | ### Creating a Flame Graph
|
33 | 16 |
|
34 | 17 | #### The Easy Way
|
|
0 commit comments