Repository navigation
perf(sandbox): collapse long runs of same-shaped output blocks - #477
Merged
Merged
Conversation
A build with many warnings prints the same multi-line diagnostic layout around a different name each time; the per-line collapse cannot see it. Command output is now also split into blank-line separated blocks, each reduced to its layout (words and numbers erased, whitespace and repeated marks folded). A run of 8 or more same-shaped blocks keeps the first block whole and the first two lines of the others: a diagnostic's message and `--> file:line`, a failed test's name and where it panicked. A block that breaks the shape ends the run. Dev token workload: the 120-warning build log goes from 7,035 to 2,914 o200k tokens with the final error intact. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Merged
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.
What
clean_terminal_outputgains a block pass after the per-line collapse (#461). Output is split into blank-line separated blocks; each block's shape is its layout with words and numbers erased (letter/digit/_runs →x, whitespace → one space, a repeated mark → one mark, so^^^^under a name of any length matches). A run of 8 or more same-shaped blocks keeps:[N more blocks shaped like the one above; first 2 lines of each],--> file:line, a failed test's name and where it panicked.A block that breaks the shape (the
error[E0308]after the warnings) ends the run and is kept whole. Blocks of ≤ 2 lines never collapse (nothing to drop). No word lists: shape only.Why
The dev token workload's failed build prints 120
unused variablewarnings, 5 lines each. The line-level collapse cannot see that repetition, so the whole 28.5 KB log (7,035 tokens) rode in every one of the next 6 requests.Measured (
scripts/bench_tokens.py --workload dev, o200k, release builds)The "before" run predates #476 (glob grouping), so the totals include its ~3k as well; the build log row is this PR alone.
Trade-off
In a run of 8+ same-shaped blocks, lines after the second of each later block are dropped (for many failing tests with identical assertion layouts, the left/right values of all but the first). Every block's identity and location stays; the model can rerun one test for detail.
Tests
long_runs_of_same_shaped_blocks_keep_the_first_and_each_head: varying name lengths and line numbers still match; heads kept, bodies dropped; the breakingerrorblock and the end of the output intact.short_runs_and_short_blocks_are_not_collapsed: 7 blocks, and 2-line blocks, pass through unchanged.clean.rsat 100% line coverage locally; fmt, clippy, budgets.🤖 Generated with Claude Code