Repository navigation
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Problem
CI job
integration (api)dies with "The runner has received a shutdown signal" (exit 143). It happens onmainand on PR branches. Theinternal/apitest binary needs more memory than the runner has.Each router the suite builds makes its own
routing.Writer. Each writer has two channels of 20,000 rows (internal/routing/writer.go:22,152-153). The suite closes its routers. But a finished suite stays in memory until the package ends, because goroutines of its nodes never end:Evidence (goroutine dump after
m.Run, suites^Test[A-C]): 1,024 goroutines are still running, and the heap still holds 2.37 GB. Among them: 96api.(*Server).expireProxies(relayws.go:452, started withcontext.Background()atserver.go:680), and 192relay.(*Bus).subscribeblocked atbus.go:219. A heap profile written after the last test of a full run holds 60.88 GB inuse inrouting.NewWriter(virtual: most of it is never touched, but the GC counts it as live heap).What this PR does (test-side only)
RouterSuite.routerWriterbuilds the writer the router would build for itself (routing.newRecorder: Store, Live, Logger, andCountedfrom the gate), withQueueSize: suiteQueueSize(1,000). The writer is closed when the suite ends, as the router'sClosewould do. Users:RouterSuite.routers: STT, TTS, both recordings routers, search, decision, image, detection, OCR, the STS stub, and the LLM router when the suite does not ship;telephonyRecorder,meteringRecorder, the session managers insessionManagerandotherNodeHolding;shippingWritergets the sameQueueSize.Production defaults are unchanged.
Measurements
Command:
scripts/run-api.sh <binary> <worktree> <db> <out>. It runs the prebuiltinternal/apibinary with CI's skip list,-test.count=1 -test.timeout=30m,GOMAXPROCS=4(so-parallelis 4, as on CI's 4 vCPU), under/usr/bin/time -l. Machine: local macOS (14 CPU, 48 GB). One run per row.TestTelnyxUnpaidSuite/TestAThreadTaskWhoseSessionEndsMidTurnSettles)=== RUN, 4,409 PASS, 52 SKIP each, and no fails. The fail lists are the same (both empty).TestMainprobe (not committed) printed norouter_usage_lost_totalseries after the PR's run, so the smaller queue lost no row.Mutations
suiteQueueSize = 20_000(the leak back)routerWriterwithout itsClosecleanupCountednot passed from the gatenewRecorderbuildsQuestions
NewServersubscribes to the relay and startsexpireProxiesoncontext.Background()(server.go:676-682), and nothing stops them. The comment there says closing the Redis client ends them, butexpireProxiesonly watches its context. AServer.Closethat cancels that context would let every finished suite go. Should that be a follow-up ticket?unverifieduntil CI runs it.🤖 Generated with Claude Code