Skip to content

Sampling architectural events

Tudor Brindus edited this page Oct 28, 2023 · 1 revision

There are many architectural events that perf can sample and output and magic-trace supports some of these. They will show up on separate tracks under the trace as arrows.

If you pass the -events flag, you can give a comma separated list of the following options: branch-misses, cache-misses. These are the same as the corresponding perf events (see perf list). However since these are sampled, magic-trace will not show you every single occurrence of these events, but rather every time a certain number of them occur (period of the event) or sample every unit of time (frequency of the event).

You can also pass a s-expression of the form ((when_to_sample x) (name y) (precision z)) if you wish the change when magic-trace samples or the precision of the event used. when_to_sample is of the form (Period 50) or (Frequency 50) and precision is one of Maximum_possible, Arbitrary_skid, Constant_skid, Requested_zero_skid or Zero_skid. If you set this low, you may risk getting throttled by the CPU and dropping data or getting trace errors. From our testing, it may not even be apparent through perf that any samples were dropped.

When running with -events, magic-trace will no longer use the --per-thread flag on perf. This however means if a process switches CPUs, you may end up with split traces with outdated data from the previous CPU. These traces are still usable, but they will have a large gap.