Performance
Baseline numbers for Vix’s per-keystroke and per-frame hot paths, so a
regression is a number that moved, not a feeling. See
spec/test/index.md for how the
benchmarks themselves are organized and how to read a run’s console output.
Running the benchmarks
cargo bench # everything
cargo bench --bench editor_ops # one file
cargo bench -- editor/open # one group; Criterion compares to the
# last run under target/criterion/
cargo bench --bench startup -- open/ # the large-checkout open-time exercise
cargo bench uses [profile.bench] (speed-optimized, no LTO) rather than the
default [profile.release] (size-optimized, lto = "thin") that a plain
bench run would otherwise inherit — the release profile is tuned for a small
shipped binary, not for representative hot-path timing, and workspace-wide
LTO makes the final link slower to rerun casually.
Baseline (measured 2026-09-15, editor/open re-measured after T121, startup/* added for T122)
Apple M4 Max, macOS (Darwin 25.6.0), rustc 1.98.0, cargo bench (release,
no LTO). These are one machine’s numbers, not a promise — the point is
the shape (which sizes are cheap, which are not) and a reference to diff a
later run against, not an absolute SLA.
Each cell is Criterion’s middle (best) estimate from a 10–100 sample run; see
target/criterion/ locally for the full confidence interval.
editor/open measures only Editor::new returning — since T121 (below),
that’s no longer the same thing as “fully parsed and highlighted” for a
buffer at or above the 50 KB async-parse threshold, which is why these rows
moved so much from the original 2026-09-02 baseline: they’re measuring the
same operation as before, but that operation itself got faster, not a
different one. editor/open_until_highlighted (new) measures the older,
“fully parsed too” quantity for the two sizes where that now differs — use
it, not editor/open, when the question is “how much total background CPU
does opening this file cost”, not “how long does it block the user”.
| Benchmark | Input | Time |
|---|---|---|
editor/open | 200 lines (~8 KB, below the async-parse threshold) | 399 µs |
editor/open | 5,000 lines (~200 KB) | 49.0 µs |
editor/open | 20,000 lines (~800 KB) | 136 µs |
editor/open | 125,000 lines (~5 MB, plan T006’s “syntax-highlight a 5 MB Rust file”) | 707 µs |
editor/open | 2,500,000 lines (~100 MB, plan T006’s “open/parse a 100 MB file”) | 14.1 ms |
editor/open_until_highlighted | 125,000 lines (~5 MB) — editor/open’s own number before T121 | 236 ms |
editor/open_until_highlighted | 2,500,000 lines (~100 MB) — editor/open’s own number before T121 | 4.69 s |
editor/typing | 200 lines, one keystroke | 14.3 µs |
editor/typing | 5,000 lines, one keystroke | 2.27 µs |
editor/typing | 250,000 lines (~10 MB, plan T121’s “keypress-to-frame < 16 ms at 10 MB”), one keystroke | 3.35 µs |
editor/random_edits | 10k inserts/deletes burst, plan T006’s scenario | 1.60 s |
editor/paste_undo | paste 50 lines | 12.4 µs |
editor/paste_undo | undo | 272 µs |
editor/line_transforms | sort_lines, 2,000 lines | 4.35 ms |
editor/line_transforms | remove_duplicate_lines, 2,000 lines | 3.29 ms |
editor/line_transforms | trim_trailing_whitespace, 2,000 lines | 4.21 ms |
find/matches | plain, 1,000 lines | 190 µs |
find/matches | plain, 20,000 lines | 4.50 ms |
find/matches | regex, 1,000 lines | 341 µs |
find/matches | regex, 20,000 lines | 3.83 ms |
workspace_search/rescan | 1,000 files, plan T006’s “10k-file tree” scenario | 33.4 ms |
workspace_search/rescan | 10,000 files | 214 ms |
palette/fuzzy | filter, 1,000 candidates | 59.6 µs |
palette/fuzzy | filter, 20,000 candidates | 1.20 ms |
palette/fuzzy | rank, 1,000 candidates | 149 µs |
palette/fuzzy | rank, 20,000 candidates | 1.37 ms |
textops/cursor_rewrites | transpose_words / transpose_sentences / delete_word / delete_paragraph / smart_toggle, 100 lines | 4.1–18.7 µs |
textops/cursor_rewrites | same, 2,000 lines | 66.3–336 µs |
textops/whole_text | wrap_80, to_crlf, squeeze_blank_lines, sentence_starts | 34.3–873 µs |
startup/app_new | App::new — theme scan, editor/menu/LSP-client setup, no git involved | 134 µs |
startup/refresh_git | refresh_git (3 git subprocesses: repo?/branch/status) against an empty fixture repo | 12.2 ms |
T121’s three explicit budgets — open 100 MB < 1 s, keypress-to-frame < 16 ms at 10 MB, workspace search 10k files < 500 ms — are now all met, two of them by a wide margin:
- Open 100 MB < 1 s: was the one furthest from budget in the original
2026-09-02 run (5.05 s), and the clearest incremental/lazy-highlighting
candidate that run named. It wasn’t highlighting that was slow, though —
highlight-query execution was already lazy and viewport-scoped (only the
visible rows’ byte range is ever queried, at any buffer size); the whole
5.05 s was one synchronous, unconditional, whole-buffer Tree-sitter parse
in
Code::new, which never went through the background-worker machinery a post-edit reparse already used for large buffers. Routing the initial parse through that same worker (the change T121 actually made — seecrates/vix-editor-core/spec/syntax-highlighting/index.md) took it to 14.1 ms, a 350× improvement, without touching the highlight layer at all. - Keypress-to-frame < 16 ms at 10 MB: 3.35 µs for the mutation + incremental-reparse-trigger side of a keystroke in a 250,000-line (~10 MB) buffer — this budget was already met before T121 (typing already used the async-reparse worker for any buffer over 50 KB), this run just adds a benchmark point at the actual target size to prove it with a number instead of an inference from the 200/5,000-line points.
- Workspace search 10k files < 500 ms: already clears this comfortably at 214 ms (unchanged by T121 — a separate subsystem) and scales close to linearly with file count (33 ms → 214 ms for 1k → 10k, roughly 10× for 10×).
One thing this baseline still shows, not addressed by T121 and worth its
own investigation: editor/random_edits’ 1.60 s for 10k random-position
edits, against editor/typing’s 2–14 µs steady-state single keystroke, says
random-position churn (structural edits scattered across a buffer, not
typing at one spot) is disproportionately expensive — the incremental-parse
machinery amortizes a single edit well, but a burst of scattered ones
still adds up; a candidate for a future task, not something T121’s parse/
highlight work touches.
Cold start (T122)
main.rs timed step by step opening this repository itself (~/git/vixide/ vix, a real, large, ~115-crate workspace — not a synthetic fixture) with a
throwaway instrumented build: Settings::load 0.6–1.0 ms, App::new
10.1 ms, load_scripts/maybe_prompt_script_trust/resolve_key_overrides/
maybe_show_welcome/restore_session combined under 1 ms — and
refresh_git 75–82 ms, by far the largest single cost, all of it before
ratatui::init() had even taken over the terminal. refresh_git shells out
to git three times (repo?, branch, status); on a small/empty repo that’s
cheap (startup/refresh_git’s own 12.2 ms, above, against a fixture repo
with no files or history) but real subprocess spawn overhead, git status
included, scales with repository size — this one just happens to be a large
one, which is exactly the realistic case worth fixing for.
The fix: main no longer calls refresh_git before the first frame draws.
App’s git-related fields (git_repo, git_branch, git_status) already
default to “not a repo” — the same state opening Vix outside a repo renders
correctly today — so drawing before that first refresh_git call is safe;
the terminal now shows the real editor almost immediately (Settings::load
App::new, ~11 ms in the instrumented run above, before terminal setup’s own small cost), with the branch/status indicator catching up one frame later rather than blocking everything that comes after it. Nothing else measured mattered enough to move: every other pre-first-frame step was already sub-millisecond, so — per this task’s own “defer if measurement says it matters” — none of them needed to move.
A smaller, unconditional fix landed alongside it: App::new scanned the
custom-themes directory (real filesystem I/O) twice — once inside
apply_saved_theme, once again immediately after for the View → Theme
submenu’s name list — now scanned once and reused for both.
The startup git refresh, in the background (T830)
T122 moved refresh_git (three git runs: repo?, branch, status) after
the first frame; a later change (e3063798) dropped the startup call
altogether, which saved its cost but left the status-bar branch, the
changed-file state and the change gutter empty until the first save or git
action. Since T830, App::start (both front ends) starts the same refresh on
a worker thread (tui/src/app/git_refresh.rs) and App::tick installs its
answer; the event loop ticks every 50 ms while it runs, so the branch and
gutter appear within a frame or two of the answer landing. A synchronous
refresh_git (opening the Git panel, a save, any git action) supersedes a
refresh still in flight.
Measured with cargo bench --bench startup -- startup/ on 2026-11-27
(on 6875a21c, a busy machine: load average around 45, so the absolute times
are high; the ratios are the point). VIX_BENCH_GIT_DIR points the git
benchmarks at a real repository, here this checkout (147 crates):
| Benchmark | What it times | Empty fixture repo | This checkout |
|---|---|---|---|
startup/app_new | App::new, no git (before: 235 µs) | 302 µs | 678 µs |
startup/refresh_git | the synchronous refresh, as before T830 (before: 27.4 ms) | 30.7 ms | 87.1 ms |
startup/start_git_refresh | what the UI thread pays now: spawning the worker | 60 µs | 17 µs |
startup/git_refresh_landed | spawn through tick installing the answer (wall time, off the UI thread) | 31.3 ms | 86.3 ms |
So startup’s git cost on the UI thread fell from a blocking 27–87 ms (before
e3063798) to tens of microseconds, and the branch shows again: it lands
once git answers, without holding up the first frame or the first keystroke.
The open-time exercise below (open/) runs App::start and so now
includes that spawn; its first editable frame (6.7 ms warm median for 20,000
files on the same busy machine) is dominated by everything else.
Rarely used features at startup (T830)
What App::new and the first frame spend on the rarely used features,
measured 2026-11-27 with a throwaway timing test built with
[profile.bench] (median of 300 runs; default features plus cowork and
jupyter, which are opt-in; load average around 12 on 16 cores):
| Feature | What App::new builds | Time | Size in App | Startup I/O |
|---|---|---|---|---|
| DB workbench | db: None, built when the workbench first opens | 0 | an Option | none |
| OC containers | oc: None, built when the OC panel first opens | 0 | an Option | none |
| Jupyter | an empty kernel list (nothing is discovered until a kernel is asked for) | 0 ns | 344 B | none |
| Cowork | an empty session state and one mpsc channel | 83 ns | 1.7 KB | none |
IM, history = "session" (default) | the inbox with Notes, the panel | 209 ns | 528 B | none |
IM, history = "disk" | the same, plus reading and decoding Notes’ JSONL (1,000 messages, 110 KB) | 297 µs | 528 B | a file read (and a rewrite if pruned) |
For scale, all of App::new took 187 µs in the same run and the first
frame (120 × 40, nothing open) 140 µs. Only the disk-history read was worth
deferring: it was larger than the rest of App::new together and was file
I/O for a feature most sessions never open. Notes’ history is now read on
the first IM use (an im.* action, a delivered message, or the panel drawn;
ImState::ensure_notes_history), so startup with disk history reads no file
and costs what the default does. The others are already lazy, or too small
to measure against the noise, and are unchanged.
cargo bench --bench startup -- startup/app_new afterwards read 230 µs
(load average around 25; 302 µs in the git-refresh run above at around
45). It uses default settings, session-only history, so this change does
not move it; with history = "disk" it saves the ~0.3 ms above.
Caches over a long session (T830, measured 2026-11-27)
Everything the App and the editor widget keep that could grow over a long
session, and what bounds it. The exercise is
app::memory::tests::opening_and_closing_a_thousand_files_keeps_per_file_state_bounded
(cargo test -p vix-tui --lib memory -- --nocapture prints the sizes): in a
committed repository of 1,000 small files, open each one (two in three as a
Position History jump, one in three as an explorer preview, which the next
preview replaces), let the language-server sync, the change gutter and the
once-a-second disk poll see it, then close it (Close Tab for one in three,
Close All every 30 files). The highlight cache has its own exercise in
vix-editor-core (highlight_cache_is_bounded_and_rebuilds_what_it_evicted):
draw a 2,000-line Rust file at each of its 2,000 scroll positions.
| Cache | Key | Grown by | Evicted before T830 | Size after the exercise, before | After |
|---|---|---|---|---|---|
App::disk_mtimes | file path | each disk poll, per open file | never | 1,000 entries (about 100 B each) | the open files (3) |
App::lsp_synced and, in vix-lsp, the document’s version and full text | file path | the first sync of a file a server handles | Close Tab only; not Close All, a replaced preview or a deleted file’s buffer (the server kept the document open too) | 667 entries, each holding the whole file text | the open files (3); the rest get didClose |
App::git_head_cache | file path | the change gutter, per file shown | a git refresh (a save, a git action) | 1,000 entries, each the file’s whole HEAD text | the open files |
App::git_gutter_base_cache (gutter base other than HEAD) | file path | the same | the same | as above, with another base | the open files |
App::nav_history (Position History) | — | every jump | never | 1,332 locations | 100 (NAV_HISTORY_CAP, as Vim’s jumplist) |
vix-editor-core highlight cache, per tab | visible byte range | each new scroll position (each visual row with soft wrap) | an edit or theme change | 2,000 entries for 2,000 positions (a viewport’s spans each, a few KB) | 256 (HIGHLIGHT_CACHE_ENTRIES), least recently used first |
| Reopen Closed Tab stack | — | each close | capped | 20 | 20 |
| Recent files | path | each open | capped | 15 (recent_files_max) | 15 |
| Command palette recents / query history | — | each command / query | capped | 12 / 50 | 12 / 50 |
| Clipboard history | — | each copy | capped | 30 | 30 |
| Output dock, terminal scrollback | — | output | capped | scrollback (1,000) / at most 50,000 lines | unchanged |
| IM messages | conversation | each message | capped | 5,000 per conversation | unchanged |
| Undo history, folds, marks, per-tab caches | — | edits in that tab | dropped with the tab | — | unchanged |
| LSP diagnostics | file path | the server’s publishes | the server’s empty publish | as many files as the server reports on | unchanged (the server decides) |
| Messages drawer | — | notices | the user dismisses each | 2 | unchanged (by design, vix-right-dock) |
| Symbols, picker preview, inline blame | — | — | one entry each | 1 | 1 |
| File index, Tree-sitter queries, git repository location | workspace / language / workspace folder | — | rebuilt, never per file | the workspace’s files / one per language / one per folder | unchanged |
Bounded since T830:
- Per-file state is dropped once no tab shows the file.
App::prune_closed_file_stateruns from the once-a-second disk poll and keepsdisk_mtimes,git_head_cacheandgit_gutter_base_cacheonly for open files, and sendsdidClosefor any synced file without a tab, which also dropsvix-lsp’s copy of its text. Every close path reaches it, so Close All, a replaced preview and a deleted file’s buffer no longer leak. A reopened file is re-read: its mtime is recorded afresh (no reload warning), the server gets a newdidOpenand the gutter fetches HEAD again (a_reopened_file_rebuilds_what_was_dropped). - Position History keeps the newest 100 jumps, as Vim’s jumplist does
(
position_history_keeps_the_newest_hundred_jumps). - The highlight cache keeps 256 ranges, evicting the least recently
used; an evicted range is recomputed to the same spans
(
highlight_cache_evicts_the_least_recently_used_range). Each eviction scans the 256 entries once, and only on a miss, which already runs a Tree-sitter query.
The exercise takes about 0.9 s in a debug build (the change gutter is built
for one file in ten there, since each build runs git show; the “before”
column comes from a run that built it for all 1,000, about 11 s).
Vi sentence motions (T830, measured 2026-11-27)
In the T843 profile about half of a Vi ( or ) was
vix_textops::sentence_starts decoding the whole buffer into a
Vec<char>; the rest was copying it out of the rope first. Now (/) read
the editor’s rope from the cursor outward through
vix_textops::sentence_start_from / sentence_start_before (a small state
carried over the chars, seeded from the whitespace and closing marks just
behind the cursor), and sentence_starts itself scans bytes from one
sentence end to the next. Both give the same starts as before: the
vix-textops tests compare them with the old scan at every offset of a
table of texts and of proptest-generated ones, and the vix-modal oracle
tests compare the motions.
editor/vi_sentences (tui/benches/editor_ops.rs): ) + ( through the
real App key path, in prose with a sentence end every few words around
the same line; --warm-up-time 1 --measurement-time 3, load average
around 10–15:
| Buffer | Before | After |
|---|---|---|
| 4 KiB | 19.2 µs | 4.4 µs |
| 512 KiB | 1.67 ms | 4.7 µs |
| 8 MiB | 34.7 ms | 4.8 µs |
sentence_starts on the textops/whole_text prose (144 KB), old and new
timed alternately in one process (median of 400): 140 µs → 84 µs; on 140 KB
of code with no sentence ends, 137 µs → 59 µs. A sentence motion in text
with no sentence end (code, say) still walks to a buffer end, but over the
rope without a copy.
Go → Sentence → Next / Previous (nav.sentence_next /
nav.sentence_prev) did the same whole-buffer copy and scan; they now
read the rope through the same two functions (vix-editor’s
next_sentence_start / prev_sentence_start, checked against the old
scan at every offset). editor/go_sentences (tui/benches/editor_ops.rs):
Next then Previous through App::run_action in the same prose buffer,
measured 2026-11-27 with --warm-up-time 1 --measurement-time 3, load
average around 15–23:
| Buffer | Before | After |
|---|---|---|
| 4 KiB | 8.5 µs | 1.7 µs |
| 512 KiB | 895 µs | 2.0 µs |
| 8 MiB | 14.2 ms | 2.0 µs |
Word and sentence navigation, Matching Tag, Highlight Word (T851, measured 2026-11-27)
T830 left four paths that copied the whole buffer out of the rope. Highlight
Word (App::refresh_word_highlight) is the one that runs without being
asked: when the setting is on, the event loop calls it every tick, and it
does its work whenever the cursor or the buffer changed since the last
call, so on every cursor move and every keystroke that edits. Measured
first, before changing anything (editor/word_highlight in
tui/benches/editor_ops.rs: two cursor moves, each followed by the
refresh, around the same line; rare is an identifier found once, so the
search reads to the end; common is a word of the filler, where the
500-mark cap is reached early): about 20 ms per cursor move at 8 MiB
(39.3 ms per two). It copied the buffer twice (once to find the word under
the cursor, once to search) and decoded each copy into a Vec<char>.
Now the word under the cursor is read from the rope out from the cursor,
and the occurrences are found by vix_textops::whole_word_matches, a byte
search over the rope’s chunks (no copy), with the marks’ char offsets from
Rope::byte_to_char. Go → Matching Tag reads the rope through
vix_tags::matching_tag_in from the cursor to the partner; Go → Word
(Start, End, Next, Previous) and Go → Sentence (Start, End) read from the
cursor to where they land; Go → Word / Sentence → Number count from the
top to the target. Each gives the old answer: unit tests compare them with
the old whole-text code at every offset of tables and generated texts, and
go_word_sentence_tag_and_highlight_word_make_no_whole_buffer_pass in
tui/tests/integration/big_buffer.rs checks that none of them makes a
whole-buffer pass in ~1.7 MB of text.
--warm-up-time 1 --measurement-time 3, load average around 15–20 before
and 6–10 after:
| Bench | 4 KiB before | 4 KiB after | 512 KiB before | 512 KiB after | 8 MiB before | 8 MiB after |
|---|---|---|---|---|---|---|
word_highlight/rare (2 moves) | 36.4 µs | 2.2 µs | 1.98 ms | 134 µs | 39.3 ms | 2.13 ms |
word_highlight/common (2 moves) | 17.5 µs | 15.6 µs | 1.10 ms | 55.7 µs | 27.4 ms | 58.6 µs |
go_words/word_next_prev | 11.2 µs | 0.99 µs | 1.08 ms | 1.23 µs | 25.9 ms | 1.39 µs |
go_words/word_start_end | 9.4 µs | 0.97 µs | 802 µs | 1.23 µs | 14.9 ms | 1.22 µs |
go_words/sentence_start_end | 9.7 µs | 1.55 µs | 902 µs | 1.85 µs | 16.3 ms | 1.80 µs |
go_words/goto_word_and_sentence_10 | 8.7 µs | 2.2 µs | 861 µs | 2.3 µs | 15.4 ms | 2.4 µs |
matching_tag/there_and_back | 37.0 µs | 3.7 µs | 4.58 ms | 2.97 µs | 83.0 ms | 2.95 µs |
Highlight Word with a rare identifier still searches the whole buffer (it marks the first 500 occurrences anywhere), now about 1 ms per cursor move at 8 MiB instead of 20; Go → Word / Sentence → Number to a far target, and a matching tag far away or missing, still read up to it, but over the rope without a copy.
Highlight Word marks the occurrences on screen (T852, measured 2026-11-27)
After T851 Highlight Word still marked the first 500 occurrences in the
buffer: in a large file with a common word, every mark could sit above the
viewport, and a word found once read to the end of the buffer (about 1 ms
per cursor move at 8 MiB). Now word_marks_near in tui/src/app.rs
searches the visible rows first, then the cursor’s neighborhood when it is
off screen, then outward from the view in 256-line steps, alternately above
and below, stopping at 500 marks or 3,000 lines past the view each way
(nothing shows a total count; the rule is in
crates/vix-find-panel/spec/highlight-word/index.md). The rebuild key gains
the view’s top line and height, so scrolling moves the marks and an idle
frame recomputes nothing.
Same bench (editor/word_highlight, two cursor moves; the view stays at the
top, so the cursor’s neighborhood is what gets searched), default criterion
settings:
| Bench | 4 KiB before | 4 KiB after | 512 KiB before | 512 KiB after | 8 MiB before | 8 MiB after |
|---|---|---|---|---|---|---|
word_highlight/rare (2 moves) | 2.90 µs | 3.66 µs | 142 µs | 70.4 µs | 2.26 ms | 67.5 µs |
word_highlight/common (2 moves) | 16.5 µs | 17.4 µs | 57.9 µs | 69.5 µs | 78.2 µs | 74.4 µs |
The rare word now costs the same at 512 KiB and 8 MiB (the window, not the buffer); the common word’s cost is the 500 marks either way. At 4 KiB the stepwise search adds under a microsecond.
Tree-sitter on very large files (T830, measured 2026-11-27)
Measured with cargo run --release --example large_syntax -p vix-tui -- <MiB> [plain]: an App with large_file_mb = 0 opens a generated, deterministic
Rust file (doc comments, structs, impl blocks with match, strings,
numbers, a test module per item; about 29 bytes a line) and draws into a
200×50 test terminal; plain opens the same bytes as .txt. Open is
App::open_initial; parse is the wall time until the background parse is
installed; keystroke is on_key in the middle of the file, then the
frame after it, then the wall time of the background reparse (median of
five). Resident memory is vix_system_information_panel::resident_memory
before and after the open. Each size is its own process; Apple silicon.
What the code already did before this slice, read from
crates/vix-editor-core/src/code.rs: the first parse of a buffer at or above 50 KB
runs on the vix-parse worker (T121), so opening never waits for it; each
edit calls Tree::edit and reparses with the old tree on the worker, so
typing never waits either; and highlighting runs a range-scoped
QueryCursor over the visible rows only (plus the LRU of 256 ranges). The
numbers confirm it: the keystroke reparse is incremental (19 ms at 64 MiB
against a 9.7 s full parse) and the highlighted frame costs the same at every
size.
Before (2026-11-27; every Rust file parsed):
| Size | Lines | Open | First frame (plain until parsed) | Parse (background) | First highlighted frame | Keystroke (on_key) | Reparse (background) | Memory the open added |
|---|---|---|---|---|---|---|---|---|
| 1 MiB | 36 k | 32 ms¹ | 1.2 ms | 125–160 ms | 0.85 ms | 19 µs | 0.5–6 ms | 47 MiB |
| 8 MiB | 286 k | 31–50 ms¹ | 4–7 ms | 1.0–1.7 s | 0.9 ms | 22–33 µs | 2.5–4 ms | 343 MiB |
| 16 MiB | 570 k | 36 ms | 8.7 ms | 2.2 s | 0.8 ms | 33 µs | 11 ms | 679 MiB |
| 32 MiB | 1.14 M | 46 ms | 29 ms | 4.1 s | 0.8 ms | 35 µs | 15 ms | 1,350 MiB |
| 64 MiB | 2.27 M | 261 ms | 97 ms | 9.7 s | 0.9 ms | 27 µs | 19 ms | 2,691 MiB |
64 MiB as .txt | 2.27 M | 28 ms | 28 ms | — | — | 15 µs | — | 73 MiB |
¹ Most of it is compiling the Rust highlight query, once per process.
The one problem is memory: the parse tree costs about 42 bytes of resident memory per byte of text, and the first parse about 140 ms per MiB of CPU on the worker. A 64 MiB source file held 2.7 GiB and kept a core busy for ten seconds before any color showed. Time on the UI thread was never the issue.
The fix is a size limit, nothing else: a buffer larger than
SYNTAX_MAX_BYTES (8 MiB) when it is created opens with Tree-sitter off
(no tree, so no highlighting, textobjects or structural selection), and the
status line says “Opened … ; syntax highlighting is off for files over 8 MiB”
(status.opened_syntax_off). At or under 8 MiB nothing changed. 8 MiB keeps
the tree near 340 MiB and the background parse near a second; VS Code’s
editor.largeFileOptimizations draws a similar line at 20 MB. After:
| Size | Highlighted | Open | First frame | Keystroke (on_key) | Memory the open added |
|---|---|---|---|---|---|
| 1 MiB | yes | 35 ms¹ | 1.4 ms | 23 µs | 47 MiB |
| 8 MiB | yes | 50 ms¹ | 7.1 ms | 33 µs | 343 MiB |
| 9 MiB | no | 4.4 ms | 4.5 ms | 16 µs | 11 MiB |
| 64 MiB | no | 28 ms | 28 ms | 18 µs | 73 MiB (was 2,691) |
Found and not changed here (they are the same with and without
Tree-sitter, so they belong to “incremental rendering”): the first frame
after a keystroke costs about 7 ms per MiB of text (66 ms at 8 MiB, 0.46 s at
64 MiB, .txt included), and five keystrokes at 64 MiB raised resident
memory by about 320 MiB in both cases.
Opening a large checkout (T823)
How long a user waits after opening a big project: for the file named on
the command line to be on screen and editable, and for Quick Open (the
palette’s file finder, Ctrl+P in the VS Code and Sublime keymaps) to list a
result. Measured by the open-time exercise in tui/benches/startup.rs,
2026-11-26 (branch for T823, on d570a67a).
cargo bench --bench startup -- open/ # the default run: no language server
VIX_BENCH_LSP=1 cargo bench --bench startup -- lsp/ # opt-in, needs rust-analyzer
The checkout is generated, never committed: a seeded, Cargo-workspace-shaped
tree of 100 crates under crates/cNNN/src/ (a lib.rs each, modules two
directories deep), written to $TMPDIR and deleted afterwards.
VIX_BENCH_OPEN_FILES sets its size (default 20,000) and
VIX_BENCH_OPEN_RUNS the number of opens per authority (default 10; 20
below). Each open builds a fresh App.
Environment of the run below. Apple M4 Max (16 cores), macOS (Darwin
27.2.0, aarch64), rustc 1.100.0 (0ef1bc386 2026-11-09), git version 2.56.1, vix 3.0.0 built with [profile.bench] and default features
(capabilities: sql, image, script, terminal, http, ai, git, jj, oc, im,
lsp, dap, tasks, hunspell), language servers switched off in the settings
(subsystems.lsp_enabled = false, so nothing can start one and no trust
prompt covers the first frame). Workspace: 20,000 files, 4,193 directories,
28.6 MiB. Load average 50.3 / 57.3 / 53.7 (1 / 5 / 15 min) from other
jobs on the machine, about three runnable threads per core: the numbers are
indicative, and the spread (p90, max) is mostly the scheduler.
| Measurement | Authority | Run | Median ms | p90 ms | Min ms | Max ms | Samples |
|---|---|---|---|---|---|---|---|
| First editable frame | local | cold | 18.9 | 18.9 | 18.9 | 18.9 | 1 |
| First editable frame | local | warm | 6.8 | 21.2 | 3.4 | 21.8 | 19 |
| Quick Open, files listed | local | cold | 67.3 | 67.3 | 67.3 | 67.3 | 1 |
| Quick Open, files listed | local | warm | 65.4 | 95.0 | 50.8 | 104.2 | 19 |
| Quick Open, query result | local | cold | 67.6 | 67.6 | 67.6 | 67.6 | 1 |
| Quick Open, query result | local | warm | 65.7 | 95.3 | 51.1 | 104.5 | 19 |
| First editable frame | fake remote | cold | 4.4 | 4.4 | 4.4 | 4.4 | 1 |
| First editable frame | fake remote | warm | 6.0 | 24.9 | 3.7 | 48.5 | 19 |
| Quick Open, files listed | fake remote | cold | 68.4 | 68.4 | 68.4 | 68.4 | 1 |
| Quick Open, files listed | fake remote | warm | 61.7 | 88.3 | 51.2 | 365.8 | 19 |
| Quick Open, query result | fake remote | cold | 68.7 | 68.7 | 68.7 | 68.7 | 1 |
| Quick Open, query result | fake remote | warm | 62.0 | 88.6 | 51.5 | 366.1 | 19 |
Through the fake authority, the first frame made 17 authority calls and Quick Open 2 (the file-index walk is one call).
Where each measurement starts and ends
- First editable frame starts just before
App::newand ends when the first frame has been drawn (ui::drawinto a 120 × 40 headless terminal) with the file given on the command line open and focused. In between:App::new,App::start(scripts, project settings, key overrides, the welcome screen, opening the file) and the draw — whatmainruns. Not included: starting the process, loadingconfig.toml, setting up the terminal and the terminal painting the bytes. The whole-process figure, measured fromforkin a pseudo-terminal, is the T744 table above: about 40 ms to the first screen on a 10,000-line file. - Quick Open, files listed starts when
tools.paletteis invoked on that app and ends when the frame showing the open picker (empty query, files listed) has been drawn. Opening the picker builds the file index, so this includes walking the checkout; that walk is almost all of it. - Quick Open, query result has the same start and ends when the frame
listing at least one result for
lib.rs, typed one key at a time after the picker opened, has been drawn. The six keystrokes add about 0.3 ms. - Cold is the first open in the benchmark process: it pays one-time
costs (grammar and query compilation, the theme, the translation
tables). The operating system’s file cache is warm, since the checkout
was just written; a cold-disk run needs
sudo purgeand is not measured. The fake-remote “cold” run comes after the local runs in the same process, so it is only cold for the authority. - Warm is every later open: a new
Appeach time, in a warm process.
Remote authority
The remote rows install the in-process FakeAuthority (T711) over the same
checkout and open /proj, a path that exists only inside it, so every file
operation goes through the authority slot as it would over SSH. No host is
contacted. The timing starts after the authority is installed: that
stands for a finished connection, which main makes before App::new
(vix::remote::connect_cli), so the SSH handshake and the remote agent’s
start are not in these numbers. It ends at the same drawn frame as the
local rows. The fake has no transport: each call is a local file operation,
so these rows measure Vix’s routed code path, and match the local ones.
Over a real link, add about one round trip per authority call: 17 for the
first frame and 2 for Quick Open, so at a 50 ms round trip, roughly 0.85 s
and 0.1 s more.
Language server (opt-in, not measured here)
First semantic definition and first actionable diagnostic need a real
server, so the default run never starts one. With VIX_BENCH_LSP=1 and a
rust-analyzer that runs (VIX_BENCH_RUST_ANALYZER names another
program), the exercise generates a small Cargo crate (one package, 202
modules, no dependencies, the server run with CARGO_NET_OFFLINE=true) and
opens its lib.rs VIX_BENCH_LSP_RUNS times (default 3) with a local
server. Each interval starts just before App::new, so it includes the
server’s start and indexing, and ends at the first tick after which:
- first semantic definition:
nav.goto_definitionon a call inlib.rshas moved the cursor toa.rs(asked again every second, since a server still indexing answers with nothing); - first actionable diagnostic: the server has published an error for
lib.rs(a deliberate type mismatch).
Cold is the first run (a fresh server, first cargo metadata), warm the
later ones. On the machine above this mode printed
skipping lsp/large_checkout: `rust-analyzer --version` did not run:
rust-analyzer on PATH is a rustup proxy with no component installed,
so there are no language-server numbers yet. A remote language server is
not covered: the fake authority has no server behind it.
What the numbers say
- On a 20,000-file checkout the file is on screen and editable in about 7 ms (median, in-process; 19 ms for the first open in a process). The size of the checkout does not enter into it: nothing on that path walks the tree.
- Quick Open lists files in about 65 ms, nearly all of it the file-index
walk. That walk stops at 5,000 files
(
App::build_file_index’s cap), so in this checkout Quick Open only ever offers a quarter of the files, and its cost stops growing at that size. - The micro-benchmarks run alongside, under the same load:
startup/app_new378 µs (134 µs in the idle 2026-09-15 baseline) andstartup/refresh_git31.4 ms (12.2 ms), which shows how much the load inflates everything.
Large File Viewer (T733)
The Large File Viewer opens files too big for a buffer without loading them
(see crates/vix-large-file/spec).
Measured 2026-10-30 with scripts/bench-large-file, which generates a 1 GiB
and a 4 GiB log-like file (~113-byte lines), opens each headlessly in the
viewer with a 50 × 200 screen, and deletes them afterward.
Machine: Apple M4 Max (16 cores), 128 GiB RAM, internal SSD (APFS), macOS
27.0.1, rustc 1.99.1, --release. Warm cache: each file is measured
right after it is written, so it is in the OS page cache; a cold read from
disk is bounded by the drive instead, and only the full-index and search
rows (which read the whole file) would change much.
| Measurement | 1 GiB (9.5 M lines) | 4 GiB (38.1 M lines) |
|---|---|---|
| Time to first screen (open + first 50 lines drawn) | 0.3–0.4 ms | 0.2 ms |
| Goto end (before the index has started) | 0.1 ms | 0.1 ms |
| Time to full line index (background) | 119–120 ms | 480–487 ms |
| Goto a line in the middle (index done) | 0.2 ms | 0.2 ms |
| Search the whole file for a string on its last line | 83–86 ms | 335–341 ms |
Peak RSS of the whole process (/usr/bin/time -l) | 4.3 MiB | 3.6–4.6 MiB |
| Line-index checkpoints kept | 9,298 (73 KiB) | 37,191 (291 KiB) |
Ranges are two runs. The quotable number: a 4 GiB file opens to its first
screen in under a millisecond and is fully indexed in about half a second,
in under 5 MiB of memory (this machine, warm cache). Memory does not grow
with the file beyond the checkpoints (8 bytes per 1,024 lines); the index
and search each read 1 MiB at a time. Process start-up and terminal setup
are not included: the benchmark times the viewer, not vix launching.
Reproduce: scripts/bench-large-file (or scripts/bench-large-file 1 for
one size). It needs about 4 GiB of free space in $TMPDIR at a time.
Startup and memory vs other editors (T744)
How long Vix takes to show a file, and how much memory it holds, next to the other terminal editors installed on the same machine, measured the same way. Every editor that was measured is listed, including the ones that beat Vix.
Measured 2026-10-30 with scripts/bench-editors, re-run the same day after
the large-buffer fixes of T749 (branch perf/big-file-memory-startup on
806dd040); the first run, on commit 282b529f, is kept below for
comparison. Machine: Apple M4 Max (16 cores), 128 GiB RAM, internal SSD
(APFS), macOS 27.0.1 (Darwin 27.0.0). Vix built with cargo build --release -p vix-tui (rustc 1.99.1, the shipped [profile.release], default
features).
| Editor | Version | Command (config disabled) |
|---|---|---|
| Vix | 2.0.0 pre-release (commits above) | vix FILE with a fresh HOME; large_file_mb = 1024 so the 100 MB file opens as text |
| Vim | 9.2 | vim -u NONE -i NONE -n -N FILE |
| Neovim | 0.12.6 | nvim --clean -n FILE |
| Helix | 25.07.1 | hx -c EMPTY.toml FILE |
| GNU Emacs | 30.2 | emacs -nw -Q --eval '(setq large-file-warning-threshold nil)' FILE |
| micro | 2.0.15 | micro -config-dir EMPTY_DIR FILE |
| GNU nano | 9.3 | nano -I FILE |
| mg | macOS /usr/bin/mg (no version flag) | mg -n FILE |
| Kakoune | 2026.05.21 | kak -n FILE |
Zed is installed but is a GUI editor, so it is out of scope for a terminal comparison. (Kakoune was not installed for the first run.)
Each cell is the median (min–max) of 10 runs on the 10,000-line file and 5 runs on the 100 MB file, after 2 discarded warm-up runs per editor and file.
10,000-line Rust file (~300 KB)
| Editor | Time to first screen, ms | Memory, MiB | Idle CPU, % |
|---|---|---|---|
| Kakoune | 7.8 (7.3–43.7) | 4.2 (4.2–4.3) | 0 |
| mg | 10.6 (10.4–56.7) | 2.5 (2.5–2.5) | 0 |
| nano | 10.7 (9.6–11.2) | 8.3 (8.3–8.4) | 0 |
| Vim | 16.5 (14.1–28.0) | 12.3 (12.3–12.4) | 0 |
| Neovim | 31.9 (30.8–34.1) | 25.0 (24.9–25.1) ¹ | 0 |
| Vix | 39.7 (38.5–53.9) | 33.0 (32.8–34.2) | 0 |
| micro | 45.8 (36.4–86.6) | 28.3 (27.7–28.7) | 0 |
| Emacs | 188.7 (171.0–201.0) | 53.6 (53.5–53.7) | 0 |
| Helix | 197.1 (193.3–794.6) | 58.0 (53.3–64.8) ² | 0 |
100 MB plain-text log file (~1.1 M lines)
| Editor | Time to first screen, ms | Memory, MiB | Idle CPU, % |
|---|---|---|---|
| Vim | 62.8 (61.4–64.2) | 116.7 (116.6–116.8) | 0 |
| Kakoune | 78.5 (76.5–86.7) | 129.8 (129.8–129.9) ³ | 0 |
| Vix | 87.0 (71.0–93.8) | 125.5 (125.3–125.5) | 0 |
| Neovim | 120.6 (104.0–157.8) | 129.7 (129.7–130.1) ¹ | 0 |
| micro | 269.6 (240.6–285.8) | 359.6 (347.4–374.8) | 67.1 (58.7–68.9) |
| nano | 275.3 (258.2–284.6) | 159.1 (159.1–159.2) | 0 |
| Emacs | 364.9 (307.3–445.8) | 148.7 (148.7–148.9) | 0 |
| Helix | 554.2 (551.5–568.4) | 524.7 (433.8–526.4) | 0 |
| mg | 1264.0 (1246.5–1704.0) | 136.6 (136.6–136.6) | 0 |
¹ Neovim runs as two processes (the terminal UI and an embedded editor
server); the figure is both together. The UI process alone peaks at 10.6
MiB. ² Helix sometimes had a second process alive while it was sampled;
the figure includes it (Helix’s own peak RSS is 53.7 MiB). ³ Kakoune’s
peak RSS from wait4 is 225.0 MiB: it holds more while loading the file
than once its first screen is up, when it is sampled. Vix’s peak RSS and
sampled figure agree (125.5 MiB). Idle CPU of “0” means a median of 0.0;
single samples of 0.5% (one 10 ms scheduler tick in 2 s) occur for Vix and
Kakoune.
Before and after T749 (Vix, 100 MB file, same method and machine):
| Time to first screen, ms | Memory, MiB | Idle CPU, % | |
|---|---|---|---|
Before (282b529f) | 99.4 (98.1–110.0) | 1100.9 (1100.8–1102.8) | 7.5 (7.0–8.8) |
| After (T749) | 87.0 (71.0–93.8) | 125.5 (125.3–125.5) | 0 |
What the numbers say, without spin:
- Startup. On a 10,000-line source file Vix shows its first screen in about 40 ms: behind Kakoune, mg, nano, Vim and Neovim (8–32 ms), level with micro, and about 5× faster than Emacs (189 ms) and Helix (197 ms) with their configurations disabled.
- Memory on ordinary files. Vix holds about 33 MiB with that file open: more than Kakoune, mg, nano, Vim, Neovim and micro (2.5–28 MiB), less than Emacs and Helix (54–58 MiB).
- Memory on a 100 MB file. Vix now holds 126 MiB, about 1.25× the file: second to Vim (117 MiB), level with Kakoune and Neovim (130 MiB), and well under Helix (525 MiB) and micro (360 MiB). Before T749 it held 1.1 GiB, the most of any editor measured. It shows the first screen in 87 ms (third, after Vim and Kakoune) and uses no CPU afterwards with no input. For files beyond a buffer’s reach, the Large File Viewer stays under 5 MiB.
What T749 changed. Measured with macOS’s malloc_history (allocation
stacks of a release build with debug symbols) and sample:
- Only ~110 MB of the 1.1 GiB was live: the rope holding the text. The rest
was freed memory the macOS allocator keeps resident, left by transient
full copies of the text, each built by doubling a
String(4, 8, … 128 MB — ~256 MB allocated per copy). About 2.6 GB was allocated in the first three seconds. - Every frame copied the whole buffer to find the longest line (for the horizontal scrollbar): ~1.8 GB of allocations in three seconds, and the whole of the 7.5% idle CPU (draws happen every 500 ms with no input). Now cached on the buffer’s revision and scanned in place.
- Opening read the file into a doubling
Vec(~264 MB allocated), then built the rope from it; now plain UTF-8 streams into the rope in 64 KiB blocks, so no second file-sized copy exists. - Persistent undo copied the text on every open to hash it, even with no saved history; now only when one exists.
- Code lenses copied the text and split it into lines to look for tests
in files with no test syntax (a
.log); now skipped for those. - Startup no longer asks the terminal about image support (a kitty
graphics query,
ESC [ c,ESC [ 16t,ESC [ 5 n); it asks the first time an image is opened. In a pseudo-terminal that answers no query at all, Vix now shows a small file in ~10 ms instead of stalling ~250 ms.
Not covered: the cost of editing a 100 MB buffer. After an edit the longest line is measured again (~20 ms on that file), and features that read the whole text when it changes were not audited for it.
Method
- Time to first screen is measured from just before
forkuntil two marker words — one on the file’s first line, one on its twentieth — have both been written to the terminal (escape sequences stripped). That counts process start, loading the file and drawing the first frame; it does not count a terminal emulator turning those bytes into pixels. - Each editor runs in a 120 × 40 pseudo-terminal with
TERM=xterm-256color, its user configuration disabled (table above), andHOMEand theXDG_*directories pointed at a fresh temporary directory, so no personal config, plugin, session or history is loaded. - The harness answers the queries editors send at startup (device
attributes, status report, cursor position, cell size, background color,
mode queries) as a typical xterm-compatible terminal does. This matters:
before T749 Vix probed the terminal for image support at startup and, in
a terminal that does not answer the status-report query (
ESC [ 5 n), waited about 250 ms for it — an earlier version of the harness that did not answer it measured Vix at ~297 ms and Neovim at ~170 ms. Vix now sends no query at startup (unlesstheme = "auto"). - Memory is the resident memory of the editor’s whole process tree,
sampled every 0.25 s for 3 s after the first screen; the cell is the
largest sample. For single-process editors it matches the process’s peak
RSS from
wait4(the number/usr/bin/time -lprints), which the script also records. - Idle CPU is the CPU time the process tree used during the last 2 s of those 3 s, with no input, as a percentage of one core.
- Warm cache only. The binaries and input files are in the OS page cache
(two discarded warm-up runs; the warm-up also absorbs first-launch work
such as Vix’s welcome screen). Cold-cache numbers need
sudo purgeand are not measured here. - Feature sets differ. Vix runs with its default features (syntax
highlighting, menus, file explorer, Git status). Of the others, Neovim
(
--cleankeeps its built-in syntax files), Helix and micro highlight the Rust file; Vim with-u NONE, nano with-Iand mg do not, and Emacs-Qopens it infundamental-modewith no highlighting (Emacs 30 has no Rust mode without a grammar or package). These are each editor’s own behavior with user configuration off, not equal workloads. - The 100 MB file is above two editors’ “ask first” limits: Vix’s
large_file_mb(50 MB by default) and Emacs’slarge-file-warning-threshold(10 MB). Both are raised so the file opens directly; with the defaults both editors stop at a question instead. - One machine, one day, with no build running but other background
activity not stopped. Spreads are min–max; isolated slow outliers (for
example nano 65.9 ms, mg 152 ms) are scheduler noise and are left in. A
trial run of nano during a
cargobuild took 175 ms instead of 10 ms on the small file, so run it on an idle machine.
Reproduce: cargo build --release -p vix-tui && scripts/bench-editors
(--runs, --big-runs, --json PATH, or a list of editor names to limit
it). It needs about 100 MB free in $TMPDIR, installs nothing, and deletes
its files afterwards.
Binary size budget (T514)
CI’s binary-size job (T008) only tracks a delta against the immediately
previous main build — useful for catching one PR’s regression, but a slow
multi-quarter creep across many individually-small additions wouldn’t show up
against a baseline that moves with it. This section is the number to compare
against over a longer horizon.
Measured 2026-09-19 (macOS/arm64, cargo build --release, [profile.release]
— lto = "thin", strip = true, opt-level = "z"): the stripped vix
binary is ~25.4 MB. Budget: flag it for a real look — not necessarily a
regression, could be a deliberate new bundled grammar or asset, but worth
asking why — if it crosses 35 MB (roughly 40% headroom) on any platform
CI measures. Update this number (and re-set the budget) the next time it’s
deliberately grown for a good reason, so the budget keeps meaning something.
Profiling a session (VIX_PROFILE)
Benchmarks measure one operation in isolation. To see how responsive Vix is
in real use, on your own files, run it with VIX_PROFILE set to a file:
VIX_PROFILE=profile.txt vix big.log
Use Vix as usual, then quit. Vix writes a summary to that file (and says where on exit):
Vix frame profile (VIX_PROFILE)
session: 42.3 s
phase count p50 ms p95 ms p99 ms max ms
input to frame 310 1.71 3.02 6.88 14.10
input handling 318 0.09 0.41 1.20 5.33
draw 402 1.42 2.31 4.97 11.62
tick 402 0.02 0.05 0.11 0.80
resident memory: start 14.2 MiB, peak 61.8 MiB, end 58.3 MiB (42 samples, every 1 s)
inputs slower than 16 ms to reach the screen: 0 of 310
slowest inputs (ms, at s into the session):
14.10 at 12.8 s
- input to frame is what you feel: from Vix reading a key, click or paste to the end of drawing the frame that shows its result. Anything over 16 ms (one frame at 60 Hz) is counted as slow, and the slowest ten are listed with when they happened, so you can match them to what you were doing.
- input handling, draw and tick (the background work polled before each frame) split that time up.
- resident memory is how much RAM Vix itself holds (its resident set),
sampled at most once a second after a frame (T830): at the start, the
largest seen and at the end. A steady climb while you open and close the
same kind of files points at something that keeps growing. It is read
through
sysinfo, which Vix already uses for Tools → System Information (where the same figure is the Vix resident memory row); on a platform it does not support the line says so.
Nothing is timed when VIX_PROFILE is unset. Only the terminal front end
records a profile.
Finding where the time goes (sampling profilers)
VIX_PROFILE and the benchmarks say how long; a sampling profiler says
where. Profile an optimized build that keeps its symbols. That is not the
release build: [profile.release] is opt-level = "z" and strip = true,
so its stacks have no function names and its hot spots are not the shipped
speed-optimized ones. [profile.bench] (opt-level = 3, strip = false)
is the one to sample, and every benchmark already runs under it.
The quickest loop profiles a benchmark that exercises the slow path. On
macOS the built-in /usr/bin/sample needs no setup: start it waiting for the
bench executable, then run the benchmark (from a second terminal, or start
sample in the background first):
/usr/bin/sample text_ops 5 -wait -mayDie -file text_ops.sample.txt
cargo bench --bench text_ops -- sentence_starts
sample attaches when a process whose name contains text_ops appears,
records five seconds, and writes a call tree plus a “Sort by top of stack”
summary to the file. The symbols are v0-mangled
(_RNvCs…_11vix_textops15sentence_starts is vix_textops::sentence_starts),
which is readable as it is. (Homebrew can shadow sample with an unrelated
tool, hence the full path.)
To profile a whole session instead, build the vix command with the same
profile and point a profiler at it. cargo build --profile bench writes to
target/release/, like a release build:
cargo build --profile bench --bin vix
Then use samply
(samply record target/release/vix big.log) or
cargo flamegraph
(cargo flamegraph --profile bench --bin vix -- big.log; on macOS it uses
DTrace and needs --root); on Linux, perf record -g target/release/vix big.log works the same way. A later plain cargo build --release overwrites
that binary with the stripped one.
Typing in a large file (measured 2026-11-17)
render/frame/after_keystroke (tui/benches/render_ops.rs) types and
deletes a character and draws a frame. Before this measurement it grew with
the file, because every edit made the next frame rescan the whole buffer for
its widest line (for the horizontal scrollbar): 1.2 ms at 1,000 lines,
2.2 ms at 20,000, and 4.9 ms at 500,000 lines (about 15 MB), on course for
the 16 ms frame budget at 100 MB. Now a buffer of 4 MB or more reuses the
widest-line width while you type and remeasures once you pause for 250 ms
(Editor::max_line_width); the 500,000-line case takes 1.7 ms, level with
the small ones. Same machine as the baseline above, under load, so read the
ratio rather than the absolute numbers.
Vi motions in a large file (T843, measured 2026-11-26)
editor/vi (tui/benches/editor_ops.rs) drives the real App key path
with the Vi keymap and the modal engine on: l + h, w + b, 3dw +
u and 2dd + u (each returns to where it started), and l + h
with a frame drawn after each key. The cursor is on the same line in every
buffer; only the unrelated text around it grows. Before T843 every motion
copied the whole buffer into a String and decoded it into characters, so
the cost grew with the file; now motions read the editor’s rope and only the
lines they cover (crates/vix-modal/spec/index.md, § Design: motions).
Run with --warm-up-time 1 --measurement-time 3 on a heavily loaded
machine, so the numbers are indicative; the shape (flat vs. linear) is the
result.
| Benchmark | 4 KiB before | 4 KiB after | 512 KiB before | 512 KiB after | 8 MiB before | 8 MiB after |
|---|---|---|---|---|---|---|
l + h | 8.2 µs | 1.4 µs | 1.08 ms | 1.6 µs | 17.6 ms | 1.5 µs |
w + b | 10.8 µs | 1.1 µs | 1.10 ms | 1.3 µs | 25.5 ms | 1.2 µs |
3dw + u | 182 µs | 197 µs | 1.07 ms | 200 µs | 22.5 ms | 194 µs |
2dd + u | 370 µs | 343 µs | 1.73 ms | 339 µs | 35.4 ms | 405 µs |
l + h, frame after each | 355 µs | 287 µs | 1.16 ms | 295 µs | 18.0 ms | 581 µs |
The remaining operator cost (about 0.2 ms for 3dw + u) is the edit and
its undo, not the motion, and does not grow with the file.
Key-to-frame in the real terminal, from VIX_PROFILE: the bench-profile
vix binary in a 120×40 tmux pane with a fresh HOME and
keymap = "vi", an 8 MiB text file, the cursor moved to its middle line,
then 100 × l/h and 100 × w/b, 25 ms apart:
| input to frame p50 | p95 | p99 | inputs over 16 ms | |
|---|---|---|---|---|
| Before T843 | 12.14 ms | 15.14 ms | 17.64 ms | 7 of 405 |
| After T843 | 0.34 ms | 0.85 ms | 1.17 ms | 1 of 404 ¹ |
¹ The 68760G that moved the cursor to the middle line (19.4 ms): a
counted G walks the lines it skips, once.
A keystroke in a very large file (T858, measured 2026-11-27)
T830’s fifth slice found the frame after a keystroke costing about 7 ms per
MiB of text, with Tree-sitter on or off, and five keystrokes at 64 MiB
raising resident memory by about 320 MiB. tui/examples/keystroke_cost.rs
reproduces it: it opens a generated file, puts the cursor in the middle and
types through App::on_key, with a tick and a frame after each key. With the
cursor at the top nothing was slow, which is why earlier measurements missed
it. /usr/bin/sample on 30 keys at 64 MiB (bench profile) put 89% of the
time under ui::draw → draw_editor_region → App::sticky_header →
App::active_tab_symbols: after every edit the sticky-scroll header copied
the whole buffer (Code::get_content) and ran vix_palette::symbols over
every line to find the one declaration above the top line, then cloned the
list of every declaration in the file (top frames: vix_palette::symbols,
memchr, regex_automata searches, memory copies, malloc/free). Most of
the rest (7%) was Editor::max_line_width → Code::max_line_chars: once
the last width was 250 ms old, the frame after a key scanned the buffer again
for its widest line, so a key after a pause cost 27 ms at 64 MiB. The undo
history was not the cause: it already stores each edit’s text, not copies of
the buffer.
Now the sticky-scroll header and the breadcrumb read up from their line to
the nearest declaration and remember what they saw across edits
(crates/vix-editor/spec/sticky-scroll/index.md), and the widest-line width
is brought forward by measuring only the changed lines
(Code::changed_since, crates/vix-editor-core/spec/index.md).
editor/keystroke (tui/benches/editor_ops.rs): type x and draw, then
Backspace and draw, in the middle of a plain-text buffer of Rust-shaped
lines. On a heavily loaded machine (load average about 40), with
--warm-up-time 1 --measurement-time 3, so read the shape, not the
absolute numbers (at 4 KiB the two builds measured 1.0 to 2.4 ms on repeated
runs):
| Benchmark | 4 KiB | 512 KiB | 8 MiB | 64 MiB |
|---|---|---|---|---|
| Before T858 | 1.0 ms | 7.2 ms | 136 ms | 982 ms |
| After T858 | 2.0 ms | 2.3 ms | 1.7 ms | 1.8 ms |
keystroke_cost, one key with a tick and a frame, cursor in the middle of a
.txt file:
| 8 MiB | 64 MiB | 64 MiB, 300 ms pause before each key | Resident memory, 5 keys at 64 MiB | |
|---|---|---|---|---|
| Before T858 | 43 ms | 380 ms | 380 ms | +396 MiB |
| After T858 | 0.15 ms | 0.14 ms | 0.5 ms | +0.8 MiB |
None of the keys after T858 makes a whole-buffer pass
(tui/tests/integration/big_buffer.rs,
a_keystroke_and_its_frame_make_no_whole_buffer_pass and
typing_in_a_large_file_costs_no_memory_per_key). What is left is periodic,
not per key: hot exit copied a changed buffer over 4 MiB into its backup at
most once a minute (moved off the UI thread by T859, next section), and
narrowing the widest line itself still remeasures the buffer once typing
pauses for 250 ms.
Hot exit and Tree-sitter after T858 (T859, measured 2026-11-27)
Hot exit. The idle pass backed up a changed buffer over 4 MiB on the UI
thread, at most once a minute: it copied the text (Tab::text), serialized
it into a second string and wrote that. tui/examples/hot_exit_cost.rs
opens a generated .txt file, types one key and times the
App::poll_hot_exit call that backs it up, then waits for the backup file
(bench profile, three runs each at 64 MiB):
| UI thread paused | Resident memory during the pass | Backup on disk after | |
|---|---|---|---|
| Before T859, 64 MiB | 120, 154, 212 ms | +67 MiB | the same |
| After T859, 64 MiB | 0.05 to 0.44 ms | +0.2 MiB | 115 to 126 ms |
| After T859, 8 MiB | 0.10 ms | +0.2 MiB | 25 ms |
Now the pass clones the rope (shared chunks, O(1)) and a vix-hot-exit
worker thread streams the JSON from the chunks into the atomic, owner-only
temp file (BackupStore::write_chunks,
vix_fileops::write_atomic_private_with), so no whole copy is made on
either thread. Rules for ordering, superseding and quit are in
crates/vix-undo-store/spec/hot-exit/index.md.
Memory per key with Tree-sitter. T858 saw a .rs file at 64 MiB grow
about 0.15 MiB per key. Re-measured on main with keystroke_cost (20
keys): at 64 MiB +0.9 MiB in all, flat, and at 8 MiB (the generator writes
slightly over SYNTAX_MAX_BYTES, so Tree-sitter is off) +0.5 MiB: since
T830 slice 5 turned Tree-sitter off above 8 MiB, nothing grows there. Just
under the limit, at 7 MiB of Rust, it still grew, and without bound:
keystroke_cost 7 400 rs | after 40 keys | 200 keys | 360 keys |
|---|---|---|---|
| Before T859 | +2.1 MiB | +30.7 MiB | +48.0 MiB |
| After T859 | +1.0 MiB | +1.2 MiB | +1.9 MiB |
(.txt at 7 MiB, for comparison: +1.1 MiB after 400 keys.) The cause was
not old trees, the highlight cache or undo: each key cancels the background
reparse in flight (vix-editor-core’s parse_worker_loop), and
Tree-sitter keeps a cancelled parse’s state in the parser so that the next
call resumes it. The next call was a newer snapshot, so the worker went
on growing one half-finished parse across every superseded key, and the
tree it finally produced could hold the old text’s nodes (the new test
a_cancelled_parse_does_not_leak_into_the_next_request got the previous
document’s functions back for a one-line struct). The worker now resets
its parser after a cancelled parse.
Quick Open in a large checkout (T845, measured 2026-11-27)
palette/quick_open (tui/benches/search_and_palette.rs) builds a checkout
of 20,000 or 100,000 empty files (open/pkg<n>/mod<n>/item<n>.rs, 100 to a
directory) and drives the real App. first_results is a fresh App
opening Quick Open until it lists files; keystroke types one character
and deletes it (two re-filters) after a query that every file matches, so
the whole index is scored and ranked: the worst case. Setup waits for the
background index and checks that all n files are indexed
and that the first, middle and last file are found by name.
Before T845 the index stopped at 5,000 files, so most of these checkouts
could not be found at all; the “before” keystroke is cheap only because it
scored 5,000 files. “Old matcher” is the full index with the matching code
as it was (an owned label, Path::strip_prefix and a lowercased copy of
every path, a full sort); “after” is T845’s (borrowed paths, a text prefix
test, an allocation-free ASCII fuzzy_score, top 200 by partial
selection). Measured on a heavily loaded machine (load average over 100 on
16 cores; palette/fuzzy/rank/20000 read 1.45–3.9 ms in these runs
against 1.37 ms in the baseline above), so read the ratios.
| Benchmark | Before (5,000-file cap) | Old matcher, full index | After |
|---|---|---|---|
first_results, 20,000 files | 9.72 ms | 9.94 ms | 9.64 ms |
first_results, 100,000 files | 11.7 ms | 11.1 ms | 10.7 ms |
| per keystroke, 20,000 files | 1.6 ms (5,000 indexed) | 9.6 ms | 2.7 ms |
| per keystroke, 100,000 files | 1.6 ms (5,000 indexed) | 62 ms | 9.7 ms |
First results cost what they did: the first pass is the old walk. Per
keystroke the worst case is about 0.1 ms per 1,000 indexed files, so the
safety cap FILE_INDEX_CAP is 150,000 files (about 15 ms, inside the
16 ms frame budget); a more selective query is cheaper, since a path that
cannot match is rejected before it is scored in full. See
crates/vix-palette/spec/index.md, § File index.
Workspace search in a large checkout (T830, measured 2026-11-27)
workspace_search/large (tui/benches/search_and_palette.rs, a timed
report, not a Criterion loop) builds a checkout of 100,000 small source
files (four lines each, src/pkg<n>/mod<n>/item<n>.rs, 100 to a
directory) in which five files hold marmalade, opens Find in
Workspace on a real App, waits for the background file index and types
the query. Cold is the first search over the whole index with nothing
remembered (the query less its last character: every file read; the files were just written, so
the OS cache is warm); narrowing is typing the last character, widening
the backspace before it (medians of 7). Measured on a heavily loaded machine
(load average about 30 on 16 cores), so read the ratios.
workspace_search/rescan is the existing Criterion bench (one character
typed and deleted after need, so two scans per iteration; at the time it
did not wait for the background index, so the 10,000-file case scanned the
first 5,000 files; since T869 it does, see § Workspace search latency).
| Benchmark | Before | Parallel reads | … and no canonicalize | After (… and the memo) |
|---|---|---|---|---|
| 100,000 files, first full search (cold) | 3.67 s | 1.53 s | 0.84 s | 0.88 s |
| 100,000 files, a narrowing keystroke | 3.08 s | 1.20 s | 0.86 s | 0.18 s |
| 100,000 files, a widening keystroke | 3.08 s | 1.20 s | 0.86 s | 0.89 s |
workspace_search/rescan, 1,000 files | 50.3 ms | 12.2 ms | ||
workspace_search/rescan, 10,000 files | 306 ms | 63.5 ms |
(Before the memo, narrowing and widening keystrokes cost the same: each read every file.)
Where the time went (a probe over the same 100,000 files, same load):
canonicalize 0.71 s on one thread and 0.62–0.65 s on 4, 8 or 16 (it
does not scale), metadata 0.16 s on one thread and 0.09–0.12 s on 8–16,
reading every file 1.8 s on one thread and 0.62 s on 8. The old scan did all
of that on one thread, plus a regex call per line. The new one reads on
every core, replaces canonicalize with one lstat and a per-directory
lookup, and skips, with one lstat each, the files the last scan found no
candidate in when the query only got longer. A file watcher could save the
remaining lstats (about 0.1 s), not the reads, so none was added; see
crates/vix-workspace-search/spec/index.md, § The in-process scan.
Workspace search latency (T869, measured 2026-11-28)
Audit item PQ-08 found the project-search key handler scanning the whole
index before it returned. Since T869 a keystroke only requests the search;
the scan runs on a worker thread and its hits land on a later tick
(spec/find-and-replace, § Responsiveness). Three times are now measured
apart: key-to-return (App::on_key, what typing waits for), first
result (request to the first hits posted) and complete (request to the
summary). All numbers are [profile.bench] builds (opt-level = 3, the
build cargo bench uses), macOS arm64, 16 cores, under load (load average
13–20 from other builds), so read the ratios.
cargo run --profile bench --example workspace_search_latency -p vix-tui -- 10000 40:
10,000 one-line files, a tenth holding needle, 40 samples each. Cold
opens a fresh App per sample (no scan memo, every file read; the OS file
cache is warm) and types ne; warm types l after need in one App,
so the memo skips the files the last scan found nothing in. Before is the
same build with the request routed to the one-thread search, so key-to-return
equals completion. Milliseconds, p50 / p90 / p99 / max:
| Case | Before: key-to-return | After: key-to-return | After: first result | After: complete |
|---|---|---|---|---|
| Cold | 142 / 145 / 147 / 148 | 0.14 / 0.15 / 0.17 / 0.63 | 81.5 / 82.7 / 83.4 / 88.7 | 133 / 135 / 135 / 143 |
| Warm | 26.5 / 27.2 / 27.4 / 27.6 | 0.19 / 0.20 / 0.21 / 0.21 | 12.9 / 13.1 / 13.3 / 13.3 | 25.9 / 26.6 / 26.8 / 26.8 |
cargo bench --bench search_and_palette -- workspace_search (Criterion,
the l keystroke after need; rescan is that keystroke and its
backspace, each with its scan to completion, the number this bench always
gave; it now waits for the background file index, which it did not before,
so its 10,000-file case scans all 10,000 files instead of the first 5,000):
| Benchmark | 1,000 files | 10,000 files |
|---|---|---|
workspace_search/keystroke | 63.6 µs | 227 µs |
workspace_search/first_result | 2.04 ms | 10.6 ms |
workspace_search/complete | 2.25 ms | 20.0 ms |
workspace_search/rescan | 10.6 ms | 102 ms |
The keystroke’s remaining cost is the snapshot: copying the file index’s
paths and each named buffer’s text. The scan itself is unchanged (T830’s
workspace_search/large, 100,000 files, timed to completion: cold 0.91 s,
narrowing 0.15 s, widening 0.91 s), and it now never delays a keystroke,
Esc or the frame drawn after it. On main before T869 the audit’s
reproduction, typing x, y, z with the whole index in, returned in
1.6 / 102 / 16 ms in this build (the audit measured 0 / 195 / 167 ms in a
debug build; x alone is under the 2-character minimum and scans nothing).
Reading the numbers
Benchmark what the user waits for — a keystroke, a frame, a file open — not what runs once at startup or is dominated by I/O the user isn’t watching. The sizes that matter are the large-buffer ones: an editor is judged on the 20,000-line file, not the 200-line one, and the query-compilation regression that motivated this whole suite (opening a 200-line file cost 26 ms because of an uncached Tree-sitter query) only stood out against the 5,000-line case.
Criterion stores each run under target/criterion/ and reports the percentage
change from the previous run — measure, change, measure again, read the
delta. Don’t chase a percentage on a benchmark whose absolute time is a few
microseconds; noise dominates there. Do chase one on editor/open’s largest
sizes or editor/random_edits — those are seconds, and a real regression
shows up as a real number of seconds.