Repository navigation
End a --test-time client that never had a reply at its deadline - #869
Conversation
With --reconnect-on-error, a client that had sent workload but never got a reply had its end time stamped at "now" by client::set_end_time(): when its reconnect after the deadline completed, or when its thread ended. Such a client takes part in the run's duration average (#821), so Total duration came out above --test-time and Ops/sec was deflated. With two clients, one served normally and one whose SET was held 2 s past a 4 s deadline, the run reported about 5000 ms and 80 ops/sec (5500 ms and 73 with --max-reconnect-attempts=5) instead of 4000 ms and 100. Cap such a client's end at its own start plus --test-time, as Ctrl+C after the deadline already does (#747): it has no op past the deadline to account for. A client with replies still ends at "now", since that time can cover replies it drained after the deadline. A client that never submitted stays out of the average, and --requests runs have no deadline, so neither changes. Staircase clients are timed from the benchmark's start, so they end at the run's deadline. end_client_after_run() keeps leaving such a client unended when its server is gone after the deadline: that run still fails, as #666 documents. test_unanswered_end_time.py runs that scenario against a scripted peer, standalone and in cluster mode, with unlimited and finite reconnect attempts. The peer closes B only after A has ended and closed its connection, so B's drop is always past the deadline. Fixes #867 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🤖 Automated first-pass review — a human maintainer's review is still required before merge. Thanks for this. I went through the
The tests are what I'd hope for. The four The core fix looks good to me. The helper is optional. |
test_unanswered_end_time.py only checked an unanswered client that starts with the benchmark and is dropped after its deadline. Three cases, using the same scripted peer, now cover the other conditions of the cap: - B's first connection is closed on AUTH, so its clock starts about 1 s late. Its end must be its own start plus --test-time: a deadline taken from the benchmark's start reports about 2500 ms instead of 3000. - B is answered, but one SET is held until 2 s past A's end. A client with replies ends when that reply is drained, so Total duration stays about 1000 ms above --test-time; capping it would report 3000 ms. - B's SET is dropped and its reconnect is closed on AUTH, so B gives up about 1 s in and the run fails. Total duration must not exceed memtier's reported wall time; always capping would stamp B's end in the future and report about 2000 ms for a 1 s run. The client.cpp comment now says why the client's own start is used rather than run_deadline(), and deadline is declared where it is used. The README sentence is scoped to the client's share of the duration, and says that a client with replies still includes its time past the deadline (#870). Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Review summary for a53d066. All 7 lenses approve (semantics, output, tests, lifecycle, interactions, maintainability, build).
On the shared deadline helper: the overflow-safe "own start + test time, only once past" arithmetic is the only part this cap shares with |
…er the deadline (#876) With --reconnect-on-error, a --test-time client that got replies, all before its deadline, and then stalled had its end time stamped at "now" by client::set_end_time() when its reconnect after the deadline completed. #869 capped this only for a client that never had a reply. With one client served normally and one answered 20 times and then held past a 4 s deadline, the run reported about 5100 ms and 82 ops/sec (5600 ms and 75 with --max-reconnect-attempts=5) instead of 4000 ms. Record when each client's last reply was read, from the timestamp process_response() already takes, so a reply costs no extra clock read. Once a client's own start plus --test-time is past, end it at that deadline or at its last reply, whichever is later, and no later than now. Replies drained after the deadline still count, but the idle time after them does not. In cluster mode the last reply is per client, whichever shard it came on, and setup replies do not count. This applies to every answered client past its deadline, so a rate-limited client that ends on a timer tick after it no longer counts that gap. end_client_after_run() is unchanged, so a run whose server is gone after the deadline still fails (#666). test_answered_end_time.py runs the stalled client against a scripted peer, standalone and with two cluster shards, with unlimited and finite reconnect attempts; a client answered past the deadline that then idles; and a cluster client answered late on one shard while the other shard's reconnect setup is held. test_run_count_partial_ranking.py now expects a run whose worker drops after its deadline to end at the deadline. Not covered: a stalled reconnect setup can still let new requests go out past the deadline (#879), and the interrupt, dead-server and drain-grace end paths still cap at the deadline (#880). Fixes #870 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Fixes #867.
Problem
In a
--test-timerun with--reconnect-on-error, a client that sent workload but never got a reply had its end time stamped at "now" byclient::set_end_time(). That happens when its post-deadline reconnect completes ("Done, no requests to send"), or when its thread ends. Since #821 such a client takes part in the run's duration average, soTotal durationcame out above--test-timeandOps/secwas deflated.The issue suggested widening the gate in
end_client_after_run(), but that path isn't the one stamping this client. Widening it would also break #666's rule: when the server is gone after the deadline, a client with no reply is left unended on purpose so the run fails.Change
client::set_end_time()caps the client's end at its own start plus--test-timewhen all of these hold:--test-timerun;The deadline check is the same overflow-safe one that
set_end_time_interrupted()uses for Ctrl+C after the deadline (#747), so both paths now agree. The cases this leaves alone:--requestsruns: have no deadline, so nothing changes.The README's reconnect note now says this extra time is not in the reported duration.
Results
Scripted peer, 2 clients (A served normally, B's first SET held past the deadline),
--rate-limiting=100,--test-time=4(the cluster row:--test-time=3, ideal 3000 ms). Ideal: about 4000 ms, 100 ops/sec. Two runs each, except where noted.--max-reconnect-attempts--max-reconnect-attempts=5--test-time=3(unlimited / finite attempts)--requestsTests
tests/test_unanswered_end_time.py: 4 cases, standalone and cluster, with unlimited and finite attempts. The peer releases B's held SET only after A has closed its connection, plus 2 s, so there is no SIGINT and nothing races memtier.--test-timeand Ops/sec within 8% of Count over that time.make check: 18/18, and clang-format 18 is clean.Not covered
A client that did get replies, all before the deadline, can still have its end stamped late by a post-deadline reconnect: for example, B answered on one shard and held on another. Fixing that needs a per-client last-reply time and changes timing for answered clients, so it's tracked separately as #870.
Affected versions
The uncapped end time has been in every release: up to 2.5.2,
set_end_time()always stamps "now". On master since 0bb7fc5 (#666, unreleased), only clients with replies are capped, inend_client_after_run().🤖 Generated with Claude Code
Note
Medium Risk
Changes core
--test-timeduration accounting for reconnect edge cases; behavior is narrow (no replies + submitted workload) but affects reported throughput and run timing metrics.Overview
Fixes #867: in
--test-timeruns with--reconnect-on-error, a client that submitted workload but never received a reply no longer has its stats end time stamped at a post-deadline reconnect or thread shutdown.client::set_end_time()now caps that client at its own start time plus--test-time(overflow-safe, same pattern as interrupt handling), instead of using the benchmark-wide deadline—so late-starting clients are not shortened and Total duration / Ops/sec stay aligned with--test-time. Clients with replies still end at “now” so time spent draining replies after the deadline remains counted (#870).The README reconnect section documents that this extra reconnect wait is excluded from an unanswered client’s duration share.
New integration tests (
tests/test_unanswered_end_time.py) drive a scripted peer for standalone and cluster mode, unlimited/finite reconnect attempts, late start, post-deadline drain for answered clients, and early give-up before the deadline.Reviewed by Cursor Bugbot for commit a53d066. Bugbot is set up for automated code reviews on this repo. Configure here.