Follow up to #279 (comment)
PR #279 added PerfSession::perf_fds() so consumers can drive parsing from kernel fd readiness (for example epoll(2) or tokio::io::unix::AsyncFd).
For sources that do not own per-CPU perf fds (MockData and InProcessRingBuf), perf_fds() returns an empty list. A consumer wired purely to fd readiness will therefore never wake up on such sources.
The current contract is that the consumer picks the source and knows whether the fd-driven async pattern applies. Sources without fds are expected to be driven by PerfSession::parse_all, parse_for_duration, or parse_until, as they are today.
Possible future directions if a real use case appears:
- Give
InProcessRingBuf a std::task::Waker slot (for example Arc<Mutex<Option<Waker>>> shared with the writer). The reader stashes its waker on Poll::Pending, and InProcessRingBufWriter::write calls wake() after publishing. This is std-only, works on any async runtime, and avoids a kernel-side wakeup object.
- Alternatively, add an eventfd (or similar) so
perf_fds() can return a real fd for in-process sources.
- Add a timeout boundary to the async drain paths so they fall back to a periodic drain when no fds are present.
MockData is a test fixture, so the sync drain methods (parse_all, etc.) are likely the right answer there regardless.
Follow up to #279 (comment)
PR #279 added
PerfSession::perf_fds()so consumers can drive parsing from kernel fd readiness (for exampleepoll(2)ortokio::io::unix::AsyncFd).For sources that do not own per-CPU perf fds (
MockDataandInProcessRingBuf),perf_fds()returns an empty list. A consumer wired purely to fd readiness will therefore never wake up on such sources.The current contract is that the consumer picks the source and knows whether the fd-driven async pattern applies. Sources without fds are expected to be driven by
PerfSession::parse_all,parse_for_duration, orparse_until, as they are today.Possible future directions if a real use case appears:
InProcessRingBufastd::task::Wakerslot (for exampleArc<Mutex<Option<Waker>>>shared with the writer). The reader stashes its waker onPoll::Pending, andInProcessRingBufWriter::writecallswake()after publishing. This is std-only, works on any async runtime, and avoids a kernel-side wakeup object.perf_fds()can return a real fd for in-process sources.MockDatais a test fixture, so the sync drain methods (parse_all, etc.) are likely the right answer there regardless.