Repository navigation
cli: add stax stalls — automatic work-gap detector - #8
Merged
Merged
Conversation
"it stalled a whole second, just show me that." No manual markers. `stax stalls` calls the existing timeline RPC (which already buckets wall-time across all threads), computes the median per-bin on-CPU ns, flags bins below a threshold of median (default 20%), merges consecutive flagged bins into stall windows, filters by minimum duration (default 100ms), and ranks by duration. Each result prints a ready-to-paste `stax flame --window <start>..<end>` command so you immediately see what the process was doing during the freeze. Why a work-gap detector, not "longest off-CPU interval": a render freeze produces the opposite signature from a parked thread. The main thread keeps running (on-CPU samples accumulate, often on a hot spin) while target-span throughput collapses to zero. Sorting off-CPU intervals by duration surfaces chronic background starvation (always present, not the stall) and is blind to an on-CPU busy-spin. The timeline-bucket approach catches both: any bin where total process throughput drops below a fraction of normal counts, regardless of which threads are on or off CPU at the time. The detection algorithm (`detect_stalls`) is a pure function of `&[TimelineBucket]`, extracted from the RPC glue so it is unit-testable without a server. Five tests cover: single-gap detection, adjacent-bin merging, short-gap filtering, duration-descending ranking, and the zero-throughput guard. Verified live against a binnacle render recording: correctly detects startup gaps (t=0–0.39s, on-CPU 8% of median — process in GPU teardown and thread spawning) and the end-of-recording tail, with flame commands that drill into the exact window.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
"it stalled a whole second, just show me that." No manual markers needed.
What it does
stax stallscalls the existing timeline RPC (which already buckets wall-time across all threads), computes the median per-bin on-CPU ns, flags bins below a threshold of median (default 20%), merges consecutive flagged bins into stall windows, filters by minimum duration (default 100ms), and ranks by duration. Each result prints a ready-to-paste flame command:Copy the flame command, paste it, see what the process was doing during the freeze. Done.
Why not "sort off-CPU intervals by duration"
A render freeze produces the opposite signature from a parked thread. The main thread keeps running (on-CPU samples accumulate, often on a hot spin) while target-span throughput collapses to zero. Sorting off-CPU intervals by duration surfaces chronic background starvation (always present, not the stall) and is blind to an on-CPU busy-spin or a throughput collapse.
The timeline-bucket approach catches all three:
…because all three manifest as "total process on-CPU + target work per bin dropped below a fraction of normal."
Design
The detection algorithm (
detect_stalls) is a pure function of&[TimelineBucket], extracted from the RPC glue so it is unit-testable without a server. Five tests cover:--min-duration-nsVerification
cargo test -p staxgreen (35 tests, including 5 new stall tests)Usage