[Benchmark] Share one ClientSession across benchmark requests - #8114
Closed
kevincheng2 wants to merge 1 commit into
Closed
[Benchmark] Share one ClientSession across benchmark requests#8114kevincheng2 wants to merge 1 commit into
kevincheng2 wants to merge 1 commit into
Conversation
async_request_eb_openai_chat_completions already accepts an optional session, but benchmark_serving never passes one, so every request opens a new aiohttp ClientSession and therefore a new TCP connection. On long runs (--num-prompts in the tens of thousands) the accumulated TIME_WAIT sockets can exhaust local ports and perturb the latency being measured. Create one ClientSession with a bounded connection pool and hand it to every request when the backend function accepts a session parameter, so backends without that parameter keep working unchanged.
kevincheng2
force-pushed
the
bench/shared-client-session
branch
from
August 24, 2026 08:38
8d14090 to
b3f5aff
Compare
Collaborator
Author
|
/re-run all-failed |
Collaborator
Author
|
Closing this — the connection reuse change is not needed for now. The decode-speed measurement fix is tracked separately in #8113. |
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.
Motivation
async_request_eb_openai_chat_completionsalready accepts an optionalsession, butbenchmark_servingnever passes one, so every request opens a newaiohttp.ClientSessionand therefore a new TCP connection. On long runs (--num-promptsin the tens of thousands) the accumulated TIME_WAIT sockets can exhaust local ports and perturb the latency being measured.Modifications
Create one
ClientSessionwith a bounded connection pool inbenchmark()and hand it to every request when the backend request function accepts asessionparameter, detected viainspect.signature. Backends without that parameter are called exactly as before. The session is closed afterasyncio.gathercompletes.This only touches the benchmark client. No engine, kernel or model code is changed.
Usage or Command
No new flags. Run the benchmark as before:
python benchmarks/benchmark_serving.py \ --backend openai-chat \ --model <model> \ --endpoint /v1/chat/completions \ --dataset-name EBChat \ --dataset-path <dataset> \ --num-prompts 20000 \ --max-concurrency 64The connection pool is sized at
max_concurrency * 2(unbounded when--max-concurrencyis not given). Socket accumulation can be observed withss -tan state time-wait | wc -lduring a long run.Accuracy Tests
Not applicable — this PR does not affect model outputs. It changes only connection reuse in the benchmark client.
pre-commit runpasses on the changed file. Backends whose request function has nosessionparameter keep their previous call signature, so their behavior is unchanged by construction.Checklist
[Benchmark])pre-commitbefore commit.benchmarks/have no unit test harness in this repo; the change is guarded by aninspect.signaturecheck so unsupported backends are called exactly as before.releasebranch... — targetsdevelop.