Skip to content

perf: a deadline only for Tab, not for every key - #8

Merged
tannevaled merged 1 commit into
mainfrom
perf/ctx-for-tab
Nov 10, 2026
Merged

tannevaled merged 1 commit into
mainfrom
perf/ctx-for-tab

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

Session.key created a context.WithTimeout(CompleteTimeout) for every keystroke, but only Tab reaches the completer. That is four allocations and a runtime timer per key for nothing. Only Tab now gets the deadline; every other key gets context.Background().

Measured through wasmbox's keystroke benchmark (type a key, erase it; allocations are exact, times indicative: 1-minute load 9.9, above the 8 limit):

half before after
key to session to Post to Drain, js/wasm 16.3 us, 22 allocs 10.6 us, 14 allocs
key to session to Post to Drain, native 11.8 us, 22 allocs 8.8 us, 14 allocs
whole keystroke with 2 repaints, allocs 32 24

TestTabCompletionHasADeadline keeps the deadline on Tab. 100 % coverage, -race clean. Refs wasmdesk/wasmbox#175.

🤖 Generated with Claude Code

Session.key made a context.WithTimeout (four allocations and a runtime timer)
for every keystroke, though only Tab asks the completer. Other keys now get
context.Background(). Per key: 11 to 7 allocations. Refs wasmdesk/wasmbox#175.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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