Repository navigation
fix(serving,ci): use shared bounded LIFO upstream pool and run keep-alive tests in CI - #86
Merged
ghchinoy merged 1 commit intoNov 21, 2026
Conversation
This was referenced Nov 21, 2026
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.
Summary
Follow-up to #81 addressing the two review items noted before merging:
deploy/cloudrun/server/structured_server.py,deploy/cloudrun/server/dgem.patch):_UPSTREAM_LOCAL = threading.local()with a lock-guarded, bounded LIFO pool (_UPSTREAM_POOL, capped atmax(MAX_INFLIGHT * 2, 16)) so connections are actually reused acrossread_manyworker threads,decide()chunkThreadPoolExecutors, and per-connectionThreadingHTTPServerhandler threads instead of opening a fresh socket per read and leaving it unclosed until GC.attempt == 1) so multiple idle closed sockets in the pool cannot burn the single retry.resp.will_closeorresp.status >= 500, and adds_close_upstream_pool()for clean teardown.read_manywhenn == 1(samples: 1fast path).read_manykeep-alive regression tests + CI wiring (deploy/cloudrun/server/test_upstream_keepalive_and_logprobs.py,.github/workflows/build.yml,AGENTS.md):read_manyreuse forn=1andn=4batches, fresh-dial retry with multiple stale pooled sockets, and 5xx socket eviction.deploy/cloudrun/server/test_upstream_keepalive_and_logprobs.pyinto.github/workflows/build.yml(test-matrix) andAGENTS.md.Verification
./scripts/regen_serving_patch.sh(clean GNUdiff -uregeneration and re-application againststructured_server.upstream.py)python3 -W default -m unittest -v deploy/cloudrun/server/test_upstream_keepalive_and_logprobs.py deploy/cloudrun/server/test_server_key.py deploy/cloudrun/server/test_media_fields.py deploy/cloudrun/server/test_upstream_errors.py deploy/cloudrun/server/test_predict_route.py deploy/cloudrun/server/test_ready_route.py(25testsOK)unset DGEM_VERTEX_URL && go vet ./... && go test ./...python3 -m unittest scripts/matrix/test_matrix.py