monado/doc/tracing-perfetto.md

97 lines
2.9 KiB
Markdown
Raw Normal View History

# Tracing with Perfetto {#tracing-perfetto}
<!--
2021-05-14 20:26:06 +00:00
Copyright 2021-2023, Collabora, Ltd. and the Monado contributors
SPDX-License-Identifier: BSL-1.0
-->
## Requirements
2021-05-14 20:26:06 +00:00
Monado uses the [Perfetto][]/[Percetto][] framework for tracing support. You
need to first build and install [Percetto][] in a place where CMake can find it.
2021-05-14 20:26:06 +00:00
Build [Perfetto][] (you will have gotten the source at least as part of build
[Percetto][]). It is a good idea to familiarise yourself with Perfetto before
2021-05-14 20:26:06 +00:00
proceeding. You then need to build Monado with CMake and make sure
`XRT_FEATURE_TRACING` is enabled.
2021-05-14 20:26:06 +00:00
* Build and install [Percetto][] - **note** Depending on the version of Percetto
you are using you might need to have a release version of Perfetto available
or use the one that is included in percetto. A release version of Perfetto is
needed due to the `sdk/` directory and amalgamated files is only made there.
* Build and get [Perfetto][] running.
* Build Monado with CMake and with `XRT_FEATURE_TRACING` being `ON`.
## Running
Save the following file to `data_events.cfg`, next to your perfetto folder.
Please refer to [Perfetto][] documentation about the format and options of this
config file, but the most important bits is the `tracker_event` section.
2021-05-14 20:26:06 +00:00
```none
flush_period_ms: 30000
incremental_state_config {
clear_period_ms: 500
}
buffers: {
size_kb: 63488
fill_policy: DISCARD
}
# This is the important bit, this enables all data events from Monado.
data_sources: {
config: {
name: "track_event"
target_buffer: 0
}
}
```
Then run the following commands before launching Monado.
```bash
# Start the daemon.
# Only needs to be run once and keeps running.
./perfetto/out/linux_clang_release/traced &
# Start the daemon ftrace probes daemon.
# Only needs to be run once and keeps running.
2022-05-17 20:30:05 +00:00
# Not needed with the preceding config.
./perfetto/out/linux_clang_release/traced_probes &
# When you want to run a capture do and then run Monado.
./perfetto/out/linux_clang_release/perfetto --txt -c data_events.cfg -o /tmp/trace.protobuf
```
2022-04-15 12:08:24 +00:00
Finally run the App and Monado with `XRT_TRACING=true` exported.
```bash
XRT_TRACING=true monado-serivce
```
## Gotchas
2022-04-15 12:08:24 +00:00
Here's where we write down bugs or other sharp corners that we found while
running Monado with [Perfetto][]/[Percetto][] and tracing enabled.
### OpenXR CTS
Running multiple CTS tests in one run causes Perfetto to crash, this is because
the CTS loads and unloads the OpenXR runtime multiple times, and there seems to
be a race on destruction.
### "Value doesn't exist" in web viewer
2022-04-15 12:08:24 +00:00
This is probably because you don't have read permissions on your tracefile,
probably because you ran traced/tracebox as root. Don't do that, instead do
`sudo chown -R $USER /sys/kernel/tracing` and run traced/tracebox as your normal
user.
(If you really have to run it as root, then before you open the tracefile do
`sudo chown $USER <tracefile>`).
2022-04-15 12:08:24 +00:00
[Perfetto]: https://perfetto.dev
[Percetto]: https://github.com/olvaffe/percetto