Concurrent tracing sessions

Perfetto supports multiple concurrent tracing sessions. Sessions are isolated from each other each and each session can choose a different mix of producers and data sources in its config and, in general, it will only receive events specified by that config. This is a powerful mechanism which allows great flexibility when collecting traces from the lab or field. However there are a few caveats to bear in mind with concurrent tracing sessions:

  1. Some data sources do not support concurrent sessions
  2. Some settings are per session while others are per producer
  3. Due to the way atrace works works if a session requests any atrace category or app it receives all atrace events enabled on the device
  4. Various limits apply

Some data sources do not support concurrent sessions

Whilst most data sources implemented with the Perfetto SDK as well as most data sources provided by the Perfetto team, do support concurrent tracing sessions some do not. This can be due to:

Known to work

Known to work with caveats

Known not to work

Some settings are per session while others are per producer

Most buffer sizes and timings specified in the config are per session. For example the buffer sizes.

However some parameters configure per-producer settings: for example the size and layout of the shmem buffer between the producer and traced. While that is general data source setting the same can apply to data source specific settings. For example the ftrace kernel buffer size and drain period are settings that have to be shared between all users of traced_probes.

Bear in mind that

Atrace

Atrace is an Android specific mechanism for doing userland instrumentation and the only available tracing method prior to the introduction of the Perfetto SDK into Android. It still powers os.Trace (as used by platform and application Java code) and ATRACE_* (as used by platform C++).

Atrace (both prior to Perfetto and via Perfetto) works as follows:

As mentioned, each category may enable a number of kernel ftrace events. For example the 'sched' atrace category enables the sched/sched_switch ftrace event. Kernel ftrace events do not suffer from the current session issues so will not be described further.

For the userland instrumentation:

Various limits