Skip to content

perf(cli): avoid eager terminal width setup at startup - #757

Merged
wesm merged 1 commit into
mainfrom
perf-cli-startup
Oct 2, 2026
Merged

wesm merged 1 commit into
mainfrom
perf-cli-startup

Conversation

@wesm

@wesm wesm commented Oct 2, 2026

Copy link
Copy Markdown
Member

Speeds up CLI commands by removing unnecessary terminal-width setup at process startup. The existing dependency eagerly built Unicode lookup tables even for docbank version. Updating go-runewidth from v0.0.27 to v0.0.30 picks up the upstream lazy-initialization fix.

Measured medians on Linux/amd64 with CGO SQLite and warm filesystem caches:

Workload Before After
docbank version 46.6 ms 21.9 ms
docbank ls / with a running daemon 59.0 ms 32.2 ms
128 separate add invocations, one 1 KiB file each 7.27 s 4.00 s
One add invocation with all 128 files 223 ms 197 ms

Startup measurements use 40 invocations per binary; listing uses 60. Import measurements use three runs per case, with unique synthetic content and fresh vaults. Source generation and daemon startup are excluded from import timing. The bulk comparison shows why passing multiple paths or a directory is still much faster than launching a process per file.

BenchmarkCLIStartup measures real subprocesses so future investigations include package initialization. This addresses startup on current main, not the original v0.14.0 directory-scaling problem; these are not M2 measurements.

Every command paid for building Unicode width tables before it could run,
even version and help. Use the upstream lazy initialization fix to remove
that work from commands that do not need it. On Linux, the measured median
version invocation fell from 46.6 ms to 21.9 ms.

Keep a subprocess benchmark because in-process command benchmarks miss
package initialization and would not reveal this regression.

Generated with Codex
Co-authored-by: Codex <noreply@openai.com>
@roborev-ci

roborev-ci Bot commented Oct 2, 2026

Copy link
Copy Markdown

roborev: Combined Review (cfc9461)

Verdict: No findings at or above medium severity.


Reviewers: 2x codex, codex (security) | Synthesis: codex | Total: 2m13s

@wesm
wesm merged commit 6c922f7 into main Oct 2, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant