Skip to content

perf(agent): the laptop agent allocates a fraction per request and asks boxes at once - #47

Merged
sean-brydon merged 9 commits into
mainfrom
perf/laptop-agent
Oct 10, 2026
Merged

sean-brydon merged 9 commits into
mainfrom
perf/laptop-agent

Conversation

@sean-brydon

Copy link
Copy Markdown
Collaborator

Part 1 of the overnight performance pass, split out of #46. This is the laptop agent's share, without the trust-store cache, which gets its own PR for review.

  • Proxy request log: logging no longer copies the host's whole log on every request. Busy host: 64 KB and 19 µs → 0 B and 0.1 µs per request.
  • Pooled copy buffers (new internal/copybuf) for proxied requests, port forwards, box streams and the app's box requests. Proxied GET 82 → 15.5 KB, forwarded connection 73 → 7.8 KB.
  • routes.json cached until the file changes (statefile.Cache, keyed on dev, inode, size and ns times): 14.9 → 2.2 µs per lookup.
  • worktree.location.localhost hosts resolve without building the agent's whole status: 65 → 38 µs and 84.6 → 13.8 KB per proxied GET.
  • Kits and team suggestions ask boxes concurrently (up to 8 at a time): 206 → 51 ms with 4 boxes at 50 ms each.
  • App → box relay: pooled buffer and cached route settings. 54 → 18 KB and 81 → 31 µs per request.

Benchmarks are in the repo (bench_*_test.go). Details and charts: https://claude.ai/artifact/E9rDKdK8BnzazAzdGGBG4C (private until shared).

Checks: go vet, go test -race on agent, proxy, forward, copybuf, statefile, wire and cmd. The full suite passed on the combined branch in #46.

🤖 Generated with Claude Code

sean-brydon and others added 8 commits October 10, 2026 09:38
…and fan-out

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e log

Past 200 requests a host's log was copied into a new slice on every
request (about 64 KB and 8 us each for a page and its API host). It now
grows to twice the limit and drops the old half in place.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
httputil.ReverseProxy and io.Copy between a socket and an HTTP/2 stream
each made a fresh 32 KB buffer per request or connection. They now share
a pool (internal/copybuf).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…xied request

The proxy read and parsed routes.json first thing for each request it
relayed (about 33 us on macOS). The routes are now kept until a stat
shows the file changed, so edits from the CLI still apply at once
(statefile.Cache).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… whole status

Each request to a worktree name without a box built the agent's full
status, which reads three files, just to list the boxes' names.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…turn

The Kits view's installed list and team suggestions asked each online
box one after another, so four boxes took four answers' time and one
slow box held up the rest by up to its whole timeout. They now ask up to
eight boxes at once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…settings read each

Every request the app sends a box through the agent made a 32 KB copy
buffer and read box-routes.json while syncing the boxes. The buffer now
comes from the shared pool and the route settings are kept until the
file changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
berth Ready Ready Preview Oct 10, 2026 8:45am UTC
berth-docs Ready Ready Preview Oct 10, 2026 8:45am UTC

Request Review

@sean-brydon
sean-brydon merged commit bc427de into main Oct 10, 2026
2 of 3 checks passed
@linear-code

linear-code Bot commented Oct 10, 2026

Copy link
Copy Markdown

ENG-5870

This branch was successfully deployed

2 active deployments
Preview – berth-docs — 78442f4f Deployed Oct 10, 2026 by vercel[bot]
Preview – berth — 78442f4f Deployed Oct 10, 2026 by vercel[bot]
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