Repository navigation
perf(tui): keystroke latency: @file completion from one fd listing, long-line fast paths, regular-mode frames - #77
Conversation
…ting, long-line fast paths, regular-mode frames - @file completion: one fd walk of the folder per completion (the @ token being typed), filtered in-process for each key with fd's own matching (regex search in the file name, '.' matches any character, smart case) and caps; until the listing is ready, keys run fd as before. Folders over 100,000 entries keep fd per key, filtering complete results for the keys that extend the query. 14-31 ms per key becomes 0.1-0.7 ms after the first key. - Editor: lines whose characters are graphemes of their own (ASCII, Latin, typographic punctuation, CJK, kana, Hangul, fullwidth) wrap without Intl.Segmenter; the grapheme at the cursor is looked up directly (stepping off the first half of a surrogate pair, where JSC's Segments.containing() returns the grapheme before as well); the autocomplete trigger regex is skipped for text without a trigger character. - Regular mode: fake-cursor resolution reuses the previous frame's result for unchanged lines.
There was a problem hiding this comment.
If your organization's extra usage balance is empty, an organization admin can add extra usage credits at claude.ai/admin-settings/usage. If its monthly spend limit was reached, an admin can raise it on the same page. If neither applies, contact Anthropic support.
Once extra usage is available, someone with write access to this repository can comment @claude review on this pull request to trigger a review.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6c51fd9bed
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
A second @ token started before the first folder listing finished started a new walk, and the first fd kept walking (up to 100,001 entries). Each listing now has an AbortController: a new walk of the folder, a completion in another folder, or the folder's eviction kills the previous fd. An aborted walk does not mark the folder as unlistable.
|
Fixed in 5c30306. Each folder listing now has an AbortController, and its fd is killed when a new walk of the same folder starts, when a completion starts in another folder, or when the folder is evicted. An aborted walk no longer marks the folder as unlistable. The new test uses an fd wrapper whose listing never ends. It checks that each superseded listing process is killed and that only the current one keeps running. Without the fix the test fails. |
Problem
Typing in the interactive editor did work in proportion to things other than the keystroke:
@filecompletion started twofdprocesses per key (after a 20 ms debounce): 14-31 ms per key on a 2.7K-file repo, 0.2-1.3 s per key on a 1.46M-file tree when few names match.Intl.Segmenteron every key (wrap, width, Backspace/Delete/Left/Right): 5.0M instructions per key+render at 2,000 characters, 18.3M at 8,000.Fix
FdFolderIndexinautocomplete.ts). The first key of an @ token starts one fd walk of the folder (same options, no pattern). Later keys filter it in-process with fd's semantics: regex search in the file name,.matches any character (fd sets dot_matches_new_line), smart case, Unicode simple case folding. The 100-result caps and the ranking are unchanged. A query that extends the previous one filters the previous matches.., no leading-, no/); others run fd.editor.ts). A line whose characters are each a grapheme of their own is wrapped and measured without segmenting it: ASCII, Latin, typographic punctuation, CJK ideographs, kana, Hangul syllables and fullwidth forms. The grapheme at the cursor is looked up withSegments.containing(). JSC'scontaining()is wrong on the first half of a surrogate pair: for "b👍" at index 1 it returns "b👍" at 0 (V8 gets this right). The lookup steps to the second half, and a test covers it under bun. Text without a trigger character skips the autocomplete trigger regex. Paste markers keep the old path.tui-main-screen.ts). Fake-cursor resolution reuses the previous frame's result for unchanged lines. It returns a copy, becauseextractCursorPosition()edits the array; a test covers this.Numbers (0.9.5 runtime, AOT, JIT off; base = 16807c4)
Identical behaviour
editor-long-line.test.tschecks the new paths against the old ones.Editor(250K+ random keys under bun: up/down, word moves, pastes, width changes) gave identical renders, text and cursor.autocomplete-fd-index.test.tschecks completion against fd.npm run checkis clean, and all 1,156 tui tests pass.Not done