Repository navigation
fix(benchmarks): run benchmark.py users in processes with asyncio - #257
Draft
kkurzacz-intel wants to merge 4 commits into
Draft
kkurzacz-intel wants to merge 4 commits into
kkurzacz-intel wants to merge 4 commits into
Conversation
benchmark.py ran every user as a thread in one process, so at high concurrency the GIL delayed requests long enough that Envoy closed TLS handshakes the client had not finished, and the immediate retries pushed runs past the failure limit with no successful requests. Users now run as asyncio tasks in several processes (16 users each). Every request still opens its own TCP and TLS connection, users start over a short ramp, errors back off with jitter, and tokens are counted in the main process after each response. The options, output file and CSV columns are unchanged. Signed-off-by: Kurzacz, Kamil <kamil.kurzacz@intel.com>
…sses Signed-off-by: Kurzacz, Kamil <kamil.kurzacz@intel.com>
… settings benchmark.py now stops with exit code 1 before any load when the bearer file is missing or has fewer than -c tokens. Before, the workers without a token quit with a log line and the run went on with fewer users, still exiting 0 under a -c <users> file name. The aiohttp session also reads HTTP(S)_PROXY and no_proxy, as requests did. Signed-off-by: Kurzacz, Kamil <kamil.kurzacz@intel.com>
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.
benchmark.pyruns every simulated user as a thread in one Python process. At high concurrency the GIL delays requests long enough that Envoy closes TLS handshakes the client hasn't finished (SSL: UNEXPECTED_EOF_WHILE_READING). A failed worker then retries immediately, so 128 workers reach the failure limit (-e) within seconds and the run ends with no successful requests. The delay also lands inside the measured TTFT and TPOT.This keeps the tool's interface and replaces how it generates load:
Users run as asyncio tasks, split over processes.
-psets how many processes the-cusers are split across: each process runs its share of users in parallel with the others, so users in different processes never wait for each other's Python work. Users are dealt round-robin (-c 10 -p 3gives users 0,3,6,9 / 1,4,7 / 2,5,8). The default,-p 0, uses one process per 16 users (at most the CPU count), so-c 128gets 8 processes.-pdoesn't change what a user does: each still sends one request at a time, on a new connection.Every request still opens its own TCP and TLS connection (
force_close), so users stay independent, as before.Users start over a 2 s ramp on top of
-u(--ramp), so 128 handshakes don't land on Envoy at once.After an error a user backs off (0.5 s doubling to 8 s, with jitter) instead of retrying at once. Errors count toward
-eas before, and 429 still waits 5 s without counting.The request loop only records timestamps (
perf_counter) and the answer text. Tokens are counted in the main process after each response, so tokenizing can't delay a request.The bearer file (
-b) is checked before any load: if it's missing or has fewer than-ctokens, the run stops with exit code 1 and says which line is missing. Before, each worker without a token loggedno bearer, quittingand the run went on with fewer users, still exiting 0 and writingbench_…_c-<users>_…as if every user had run (2 tokens with-c 4: 2 users loaded, exit 0; no file: empty CSV, exit 0).Proxy settings (
HTTP(S)_PROXY,no_proxy) apply as they did withrequests(trust_env=True).Unchanged: every option, the warmup and failure semantics, the
bench_<date>_c-<users>_d-<delay>.result.csvfile and its columns, soparse.py,benchmark_sweep.sh,run_benchmark_sweep.shand the nightly playbook work as they are. New dependency:aiohttp.Evidence (single-node GNR, 2× Xeon 6760P, same deployment)
downstream_pre_cx_timeout(connection opened, TLS never completed)The 4 failed cases all succeed with the new load generator (474 to 2,793 successful requests each). The client process under the current tool was a single process at about 114% CPU with 418 threads.
Not yet shown: unchanged numbers
The runs above differ in more than the client (vector DB size, dates), so they don't show whether the results match at concurrency levels both tools handle. A controlled A/B on the same deployment, alternating the two clients, is planned and will be added here. Expected: equal within noise at low concurrency, lower TTFT at 32+ users where the current client's own delay is counted.
Testing
parse.pyreads the CSV unchanged.generate_uat_to_file.sh: 8 processes, exit 0, 1 client error;parse.pysummary as usual.