Repository navigation
Conversation
Every statusline invocation is a fresh process, so per-render fixed costs multiply by the number of concurrent Claude Code sessions (sirmalloc#397): - terminal: one ps spawn answers both walk questions per ancestor (`-o ppid= -o tty=`; two flags, not a comma list - FreeBSD's parser collapses the comma form). The walk re-runs per render on macOS, so halving its spawns halves that cost. The walk now starts at process.ppid and reads each generation's TTY before terminating on its PPID, keeping the old two-spawn walk's generation coverage. - usage-fetch, claude-service-status: load https-proxy-agent (and its transitive undici/proxy module graph) on demand, only when a proxy is actually configured. node --cpu-prof shows the graph gone from startup (compileForInternalLoader 40.7ms -> 7.5ms per render). Benchmark (13MB transcript, 4 parallel workers x 20 renders via stdin): 27.2 -> 20.6 CPU-seconds total, 0.34 -> 0.26 CPU-s per render (-24%), wall 7.5s -> 5.6s. Closes sirmalloc#397 Co-Authored-By: Claude Code <[email protected]>
Union: the fork's lazy async proxy-agent request builder keeps its await-import, upstream's per-model apiPath parameter rides along. Co-Authored-By: Claude Code <[email protected]>
…awn walk Upstream's it.each COLUMNS=0/wide tests mock the old two-spawn ps protocol (ppid probe, then tty probe); this PR's walk answers both questions with one ps spawn started at process.ppid, so the mock threw Unexpected command and the walk bailed with null on CI. The mocks now describe the PR's protocol; the tests' intent (invalid COLUMNS falls back to probing) is unchanged. Co-Authored-By: Claude Code <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Closes #397. With several concurrent Claude Code sessions every statusline invocation is a fresh process, so per-render fixed costs multiply by session count. Two of those fixed costs are payable once instead of per repaint:
pswalk per render, with two spawns per ancestor (-o ppid=then-o tty=);https-proxy-agent(and its transitive undici/proxy module graph) was loaded at startup even when no proxy is configured.What this does
ps -o ppid= -o tty= -p <pid>spawn answers both walk questions per ancestor (two-oflags, not a comma list — FreeBSD's parser collapses the comma form). The walk now starts atprocess.ppidand reads each generation's TTY before terminating on its PPID, keeping the old two-spawn walk's generation coverage (a PPID of 0 no longer hides a valid width on the same ps row)../proxy-agentis now dynamically imported inside the "proxy actually configured" branch, so the undici/proxy graph leaves startup entirely.node --cpu-prof:compileForInternalLoader40.7ms → 7.5ms per render.Measurement
13MB transcript, 4 parallel workers × 20 renders via stdin:
Verification
bun testandvitest.HTTPS_PROXY, stalled-proxy deadline) unchanged and green — the lazy load is behavior-invariant; the win is startup cost, shown by cpu-prof above.git-hardening-execLFS failure under Bun on macOS). Note:usage-fetch.test.tsis red under vitest on macOS for pre-existing reasons (its subprocess probe hits Node ESM extensionless resolution) — green under bun.🤖 Generated with Claude Code