Worshipping at the altar of Brendan Gregg
The creator of a deterministic VM adds a performance analysis command inspired by Brendan Gregg to calculate critical paths, off-CPU time, and trace execution steps down to source lines.
read it Provides a detailed look at how recording context switches in a deterministic VM enables precise off-CPU and critical-path performance analysis post-run.
summary
The author builds a command into their deterministic VM called Rewind, applying Brendan Gregg's performance methodologies to recorded execution traces. By tracking context switches, wakeups, and process forks, the tool calculates a program's critical path and identifies whether execution time is spent computing or sleeping. Developers can drill down through process trees, view flame graphs, and jump directly to specific source lines using GDB to investigate bottlenecks. Although the featured libuv test case turned out to be an intentional sleep, the approach eliminates the overhead of live-machine tracing.
key points
- Rewind's analysis command extracts critical paths and thread states from recorded execution logs without live-tracing overhead.
- The tool surfaces off-CPU time—such as sleeping in epoll_pwait or clock_nanosleep—which standard CPU profilers miss entirely.
- Engineers can drill down from process trees and flame graphs directly into individual instructions using GDB and deterministic replay.
who should read it
Systems programmers, performance engineers, and developers interested in debugging tools and deterministic execution.
discussion positive
consensus
Commenters find the integration of deterministic record-and-replay with off-CPU critical path analysis compelling, though some question how single-threaded deterministic VMs scale to multithreaded workloads.
pushback
A few readers note disappointment that the article's walkthrough ended on an intentional sleep rather than a fix, and criticize phrasing reminiscent of AI generation.
I really like the idea of a deterministic VM (I like Antithesis for a similar reason!), though I saw on another post that your VM is single threaded which I feel like must compromise a lot of performance analyses? E.g. when you have very high throughput multithreaded pipelines.
Personally I've really cooled on flamegraphs for the purpose of doing multithreaded performance analysis - it's so hard to infer cross-thread dependencies. I'd encourage people interested in performance analysis to read https://thume.ca/2023/12/02/tracing-methods/ (and I'd love to hear if there's something more recent …
Highlights the limitations of single-threaded deterministic VMs for multithreaded performance analysis and points to alternative tracing approaches.
Generated by an LLM from the article and thread. Check the sources before relying on it.