janestreet / janestreet/magic-trace

Add an interface for using perf events to pause/resume aux tracing

Open
#330 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
OCaml
Stars
6.3k
Forks
209
PR merge metrics
No merged PRs in 30d

Description

[Recently](https://patchew.org/linux/20241216070244.14450-1-adrian.hunter@intel.com/), perf added support for [starting and pausing](https://www.man7.org/linux/man-pages/man1/perf-intel-pt.1.html#PAUSE_OR_RESUME_TRACING) aux-area tracing upon other perf events.

Some possible uses within magic-trace:
- Starting/stopping the trace on breakpoint hit or on particular symbols using uprobe events (similar to (#81), (#222)). Currently, this requires manually tuning the buffer size, creates excess PT data to post-process, and interacts poorly with multi-snapshot because of the extra PT data. Using this mechanism, "full execution" traces of long or repeated spans becomes viable out-of-the-box. AUX suspension/resumption occurs inside the uprobe call chain, so this is more precise than any alternative that would round-trip through magic-trace.
- Capturing snapshots / ending traces upon kernel events, such as page faults. This isn't possible out-of-the-box today because we can't set breakpoints on kernel functions. This is more limited than using `bpftrace` with (#230), less so if `--filter` does the magical thing we want. Also, this removes trace skid where skid is desirable in the absence of a perfect "return-to-userspace" kernel event.
- Tracee-directed asynchronous trace start. Traces can be started upon timer expiration, IO completion, signal delivery, and so on, without PT overhead prior to the region of interest.

Ideally we would have nice, separate interfaces for these uses rather than just passing through flags (and maybe also a just-pass-through-my-flags interface).

Contributor guide

Open the contributing guide

Research direction

Start by reading the linked perf documentation and related issues #81, #222, and #230. Work out separate interfaces for starting or pausing AUX tracing from perf events, and consider whether a pass-through flags interface is needed; done means the proposed use cases have clear supported entry points.

Written by the indexing model from the issue text.

Assessment

Tech stack
linux, ocaml
Domain
devtools, observability, performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.