Even more minimal support for perf-event sampling #30
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
@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:
Sampler::next
now returns aRecord
type which is a reference into the kernel ring buffer. When dropped,Record
advances the tail pointer of the ring buffer.Sampler
is now constructed by callingcounter.sampled(bufsize)
since it no longer needs access toperf_event_attr
.SampleType
has been moved to the crate root.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