8b2b6b2440
This reverts commit74c5aa3a7a. Reason for revert: Fix golem breakage by not changing the script dart_precompiled_runtime2 TEST=ci Original change's description: > Revert ""[SDK/VM] - Rename dart_precompiled_runtime to dartaotruntime, ensures we have a uniform name for the executable between the build directories and the SDK directory"" > > This reverts commitf81a402aa1. > > Reason for revert: golem benchmarks are failing to run > > TEST=ci > > Original change's description: > > "[SDK/VM] - Rename dart_precompiled_runtime to dartaotruntime, ensures we have a uniform name for the executable between the build directories and the SDK directory" > > > > Fixed golem breakage by temporarily copying dartaotruntime to dart_precompiled_runtime > > > > This reverts commit75e6a748f7. > > > > TEST=ci > > Change-Id: I9efe40643c59bc617f6fb484b89b038deaffbb93 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393941 Reviewed-by: Alexander Aprelev <aam@google.com> Commit-Queue: Siva Annamalai <asiva@google.com>
65 lines
2.3 KiB
Markdown
65 lines
2.3 KiB
Markdown
Various tools for low level profing of code running on the Dart VM.
|
|
|
|
# Uprobe based profiling
|
|
|
|
[uprobes](https://www.kernel.org/doc/html/latest/trace/uprobetracer.html) is
|
|
a user-space dynamic tracing mechanism. Using this mechanism the kernel can
|
|
be instructed to place a tracepoint at a particular file offset within a
|
|
specific binary. Whenever this tracepoint is hit the kernel will fetch values
|
|
from the execution context based on the uprobe's description and emit an event.
|
|
A developer can subscribe to uprobe events in a few different ways including
|
|
[perf_event_open](https://man7.org/linux/man-pages/man2/perf_event_open.2.html)
|
|
syscall. uprobes have been enabled by default on all newish Linux kernels
|
|
(4.14+), however they are only truly usable on Android/ARM64 starting from
|
|
5.10+. `bin/set_uprobe.dart` is a helper script for placing uprobes inside
|
|
binaries and using this for profiling.
|
|
|
|
The core workflow looks like this:
|
|
|
|
```console
|
|
$ sudo $(which dart) runtime/tools/profiling/bin/set_uprobe.dart probeName symbol binary
|
|
```
|
|
|
|
This will create an uprobe with name `probeName` which triggers whenever
|
|
the given `symbol` inside the given `binary` is called. You can then record
|
|
an event (and collect the call stack) using:
|
|
|
|
```console
|
|
$ sudo perf record -g -e uprobes:probeName ...
|
|
```
|
|
|
|
## Allocation profiling with uprobes
|
|
|
|
AOT compiler can emit a special probe point (`stub AllocationProbePoint`) which
|
|
triggers for each new space allocation from generated code. `set_uprobe` script
|
|
has special support for this probe point: it will configure probe point to
|
|
record additional information (address of allocated object, allocation top and
|
|
cid of the allocated object) allowing to post process collected data into
|
|
an actual allocation profile.
|
|
|
|
Start by compiling your application with `--generate-probe-points`:
|
|
|
|
```console
|
|
$ pkg/vm/tool/precompiler2 --generate-probe-points test.dart test.aot
|
|
```
|
|
|
|
Then install uprobe on `AllocationProbePoint`:
|
|
|
|
```console
|
|
$ sudo $(which dart) runtime/tools/profiling/bin/set_uprobe.dart alloc AllocationProbePoint test.aot
|
|
```
|
|
|
|
Record the profile:
|
|
|
|
```
|
|
$ sudo perf record -g -e uprobes:alloc out/ReleaseX64/dartaotruntime test.aot
|
|
$ sudo chmod 0755 perf.data
|
|
```
|
|
|
|
Produce a coalesced allocation profile from the recording:
|
|
|
|
```
|
|
$ dart runtime/tools/profiling/bin/convert_allocation_profile.dart perf.data
|
|
$ pprof -flame pprof.profile
|
|
```
|