perf(tui): batch-drain build events to kill post-completion hang#75
Open
raphaelvigee wants to merge 1 commit into
Open
perf(tui): batch-drain build events to kill post-completion hang#75raphaelvigee wants to merge 1 commit into
raphaelvigee wants to merge 1 commit into
Conversation
A warm `heph run test //...` emits typed events for the whole transitive closure (ResultStart/End + cache-hit per dep) — tens of thousands, flooded into the unbounded channel near-instantly. Both backends folded at most one event per `select!` iteration, so the burst drained one-at-a-time over seconds after the headline `44/44 done` had already painted. Add `fold_buffered`: on each build-event wake, greedily `try_recv` the rest of the buffered backlog in one pass. N select iterations collapse to one; the 80ms ticker still repaints. Engine event emission is unchanged — events stay typed, collapsed only at render. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Problem
A warm
heph run test //...shows44/44 done, then the inline TUI hangs a few seconds "just processing events" — switching to the all view, the counter keeps climbing right up to exit.Root cause (consumer-bound)
The engine emits typed events for every target in the transitive closure (
ResultStart/ResultEnd+LocalCacheHitper dep) — tens of thousands on a warm run, flooded near-instantly into the unbounded channel. Both backends folded at most one event pertokio::select!iteration, so the burst drained one-at-a-time across thousands of iterations (interleaved with the 80ms ticker) after the headline had already painted.apply()itself is cheap; volume × per-iteration dispatch was the cost.Fix
fold_buffered(src/tui/backend/mod.rs): on each build-event wake, greedilytry_recvthe rest of the buffered backlog in one pass. N select iterations collapse to one; the ticker still repaints per tick. Used by both the live arm and the final drain in interactive + ci backends. Engine emission unchanged — events stay typed, collapsed only at render.Tests
fold_bufferedunit tests: one wake folds the whole K-event backlog and leaves the channel empty; empty channel folds nothing.-D warnings+ fmt clean.🤖 Generated with Claude Code