BenchmarkLargeRequest served httptest.NewRequest's context.Background,
which never ends. holdBody lists only a body whose context can end, so
the benchmark measured a gateway that never held a body: decodeJSON
copied every value, and nothing kept for a body's later readers was
ever kept. A served request's context ends when it is answered; each
request now gets one that does.
Same tree, -benchmem, -benchtime=30x, ~2 MB conversation (B/op):
anthropic 61.27 MB with Background, 55.37 MB with an ending context
chat 52.64 MB 44.83 MB
responses 75.28 MB 55.37 MB
The rest of this series is measured with it.
Run (darwin arm64, go1.26.8, sandbox HOME, load 40 to 90 from other
sessions' suites):
- go test ./... -count=1 -timeout 45m on the series' final tree at
ba319a758: exit 0, all 68 packages ok (gateway 1498s, agent 1633s).
- After the rebase onto b855cfee9 (two redact commits): go test
./internal/redact ./internal/gateway -count=1 -timeout 45m, both ok
(gateway 917s).
- go test -race -count=3 on the Held, ReadersOfAHeldBody, RecentRing,
RequestBody, CaptureRequest, folder, WorkPlace, WorkDir and Turn
tests: ok, after
TestReadersOfAHeldBodyParseItOnce's byte bound was skipped under
-race (the third commit says why); that test and
TestHeldFactsGoWithTheirBody then passed -count=30 with and without
-race.
- Each commit alone: go vet ./internal/gateway and gofmt -l clean.
- Final tree: gofmt -l clean; go vet ./... for darwin, GOOS=windows and
GOOS=linux -tags nogui, all exit 0.
Not tried: a second 60-minute soak after the series (the one before is
the "before" here; the "after" numbers are the benchmark's), the GUI
suite (nothing in it changed), Windows and Linux test runs (vet only).