jimblandy / perf-event

perf-event: a Rust interface to Linux performance monitoring
Apache License 2.0
111 stars 19 forks source link

Even more minimal support for perf-event sampling #30

Closed Phantomical closed 7 months ago

Phantomical commented 1 year ago

@janaknat's comment on #22 lead to me rethinking some of the design on how to expose sampling. Instead of attempting to parse every possible type of emitted perf record, the solution instead is to not attempt to do any parsing and just expose the raw record bytes. That way people can start off by doing whatever parsing they want themselves and later on support for new message types can be added here on top of the existing sampler.

This PR shares most of its code with #22 with the following changes:

When viewing the diff I recommend disabling whitespace-only changes (via the github ui or git diff -b) since it hides about 100 lines of indenting that does not have any effect on the behaviour of the code in question.

Commit Message

This commit introduces a minimal but mostly complete form of support for reading sampled perf_event events emitted by the kernel.

New public types being introduced

One thing to note is that this commit does not include any support for actually deserializing the records emitted by the kernel into something rust code can easily use. This can be added on top of the Sampler and Record types in a straightforward, albeit not necessarily easy, fashion. I consider it to be out of scope for this specific commit.

New Dependencies

This commit introduces one new dependency and one dev-dependency:

Unsupported Features

This section can also be taken as notes for which features would make for a good starting point for future work.

cc @jimblandy Supercedes #22