Skip to content

perf(tools): drop the column padding from read line numbers - #424

Merged
mrnasil merged 1 commit into
mainfrom
perf/read-grep-format
Nov 7, 2026
Merged

mrnasil merged 1 commit into
mainfrom
perf/read-grep-format

Conversation

@mrnasil

@mrnasil mrnasil commented Nov 7, 2026

Copy link
Copy Markdown
Member

Part of the token-efficiency series (#418–#423).

Problem

Every read line was {n:6} {tag}|text, with the line number padded to six columns. With o200k the padding costs about two tokens per line, which is 14% of a read. A model gains nothing from aligned numbers.

400-line read Padded Unpadded
crates/session/src/title.rs (337 lines) 4,822 tok 4,148 tok
crates/agent/src/subagent.rs 5,732 tok 4,932 tok

Change

  • Tool. format_read_line now emits 42 a3|text. The tag stays because tag-addressed edits need it. This covers read output, outlines and the edit-error snippets that reuse the helper.
  • TUI. The read painter never recognised tagged lines: the tag made the left side non-numeric, so these lines were shown raw and without highlighting. split_read_line now accepts 42 a3| and the older padded form, hides the tag and right-aligns the number. As a result, read results get the same code highlighting that plain numbered lines already had.

Considered and left out

  • Grouping grep hits under one path header would save about 18% of a grep. It also changes the TUI's grep painter and match summary, so it is better as its own PR.
  • Excluding context lines from max_results would let context: 5 return around 550 lines (~8k tokens) per call. The saving is speculative, so the current behavior stays.

Checks

  • whycodes-tools --lib 538 passed; whycodes-tui --lib 1494 passed. split_read_line test cases are added for tagged, legacy and non-matching lines.
  • fmt and clippy (tools, tui) are ok. Local llvm-cov on tools: every changed line is covered.

🤖 Generated with Claude Code

Every `read` line was `{n:6} {tag}|text`: the number padded to six
columns. o200k spends about two tokens a line on that padding, 14% of a
400-line read of this repo's Rust files (subagent.rs 5,732 -> 4,932
tokens), and a model gains nothing from aligned numbers. Lines are now
`42 a3|text`; the tag stays, since tag-addressed edits need it.

The TUI's read painter did not recognise tagged lines at all (the tag made
the left side non-numeric), so it showed them raw and unhighlighted.
`split_read_line` now accepts `42 a3|` and the older padded form, hides
the tag and right-aligns the number, so read results get the code
highlighting plain numbered lines already had.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@mrnasil
mrnasil force-pushed the perf/read-grep-format branch from 9ba0cd5 to 227a733 Compare November 7, 2026 13:55
@mrnasil
mrnasil merged commit cb05ff5 into main Nov 7, 2026
7 checks passed
@mrnasil
mrnasil deleted the perf/read-grep-format branch November 7, 2026 14:07
mrnasil added a commit that referenced this pull request Nov 9, 2026
#437)

Release PRs only bump [workspace.package] version, which made
affected_tests.py select `cargo test --workspace`. At CARGO_BUILD_JOBS=1
that took 26-32 minutes (v0.6.34, v0.6.36) while Coverage ran the same
tests in ~6. The selector now compares the root manifest against the base
and skips it when only the workspace version changed; any other root edit
still runs the workspace.

watchdog_keeps_checking_until_aborted used real 5ms/30ms sleeps. On a
loaded runner both expired in one tick, the task was aborted before its
first check, and whycodes-server's 100% floor failed at 1518/1519
(#424 push). A paused clock makes the order deterministic.

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant