Repository navigation
Stop --clients-start runs at --test-time instead of the next step - #742
Conversation
03d1b75 to
46ccb7f
Compare
In staircase mode the step timer is EV_PERSIST, and the deadline was only checked when it fired. Once the clients stopped at --test-time, that pending timer was the only event left and kept event_base_dispatch() running until its next tick: --test-time 2 --step-duration 20 took 20 s of wall time, --test-time 5 --step-duration 3 took 6-7 s. The results were not affected, the process just idled. setup_staircase_timer() now also adds a one-shot timer at benchmark_start_time + test_time that removes the step timer, so the thread's loop ends when its clients do. The step timer stays persistent, so the step schedule does not drift. If either event_new() fails, log it instead of passing NULL to event_add(); without the deadline timer the old behaviour (stop at the first tick past the deadline) remains, which is also why handle_end_stalled_clients() still removes the step timer. The live progress line now caps its staircase client count at the last step due before --test-time, as the JSON "Active Clients" does since #722. On the final line it used to count a step that never ran (4 conns instead of 3 for -c 6 --test-time 3 --step-duration 1). The StatsD "connections" and Prometheus memtier_connections gauges are fed from the same count, so they change the same way. Tests, both failing on master: - test_staircase_exits_at_test_time runs --test-time/--step-duration 2/20, 5/2, 4/2 and 5/3 and requires the worker threads' lifetime (JSON CPU cpu_wall_seconds, which excludes process startup) to stay below test_time + 0.5 s; without per-thread CPU accounting it falls back to process wall time < test_time + 3 s. It now also runs on oss-cluster. - test_staircase_progress_clients_match_json checks that the last progress line's conns equals the last JSON Active Clients entry. Fixes #728 Co-Authored-By: Claude Opus 5.5 <[email protected]>
46ccb7f to
83f99bc
Compare
|
🤖 Automated first-pass review — a human maintainer's review is still required before merge. Thanks for this. The root cause analysis matches the code, and the one-shot deadline timer seems like the right fix: the step timer stays A few small things:
The fix itself looks solid to me. None of the points above should block merging. |
|
Thanks. Answering the 21:26 version of the review point by point:
|
Problem
With
--clients-start, the process kept running after--test-timeuntil the next--step-durationtick. The results were correct ("Total duration" equals--test-time), but the process sat idle:--test-time 2 --step-duration 20took 20 s of wall time.Root cause
client_group::setup_staircase_timer()adds anEV_PERSISTstep timer, andhandle_staircase_step()checks the deadline only when that timer fires. Once the clients stop at the deadline, that pending timer is the last event left on the thread's base. It keepsevent_base_dispatch()running until the first tick at or aftertest_time.Fix
setup_staircase_timer()also adds a one-shot timer atbenchmark_start_time + test_time, and that timer removes the step timer. The loop now ends when the clients do. The step timer staysEV_PERSIST, so the step schedule does not drift. The repeated delete/free blocks are now oneremove_staircase_timer().event_new()failures: a failure of either timer is now logged instead of passing NULL toevent_add(). If only the deadline timer fails, the old behaviour remains: the run stops at the first tick past the deadline. That is whyhandle_end_stalled_clients()still callsremove_staircase_timer(); its comment now says so.(test_time - 1) / step_durationsteps, as the JSON "Active Clients" does. Before, the final line counted a step that never ran:-t 1 -c 6 --test-time 3 --step-duration 1showed4 conns, and now shows3 conns.handle_staircase_step()are now one.Visible change: StatsD and Prometheus
The StatsD
connectionsgauge and the Prometheusmemtier_connectionsgauge are fed from the same capped count. After the deadline they no longer include a step that never ran.Test evidence
Base: origin/master 8ef3971 (includes #722 0fc29f4, #724 cde91ea and #730).
test_staircase_exits_at_test_timeruns four--test-time/--step-durationcases: 2/20, 5/2, 4/2 and 5/3 (-t 2 -c 4 --clients-start 1 --clients-step 1).ALL STATS.CPU.cpu_wall_seconds, so process startup does not count, and requires it to stay belowtest_time + 0.5s.test_time + 3s.test_staircase_progress_clients_match_jsontakes-t 1 -c 6 --test-time 3 --step-duration 1. It parses the\r-separated stderr and requires the last progress line'sconnsto equal the last JSON "Active Clients" entry, which is 3.4 conns, JSON 3)Wall time of the whole process, measured by hand with the fixed build (
-t 2 -c 4):For comparison, a run without staircase at
--test-time 2takes 3.0 s, because the main loop polls once a second. Before and after the fix, "Total duration" equals--test-timeand "Unanswered requests" is 0.Other tests:
tests/test_client_staircase.pyon--env oss: 15/15 pass.tests/test_retry_on_error.pyon oss: 28/28 pass.tests/test_cluster_slots_bad_reply.pyon--env oss-cluster --shards-count 3, which covers the late-staircase path from Retry CLUSTER SLOTS after an empty, error or malformed reply instead of hanging #667: 16/16 pass.Affected versions
2.3.0 through 2.5.2 (the latest release), and master.
EV_PERSISTstep timer. The first tag that contains it is 2.3.0.Fixes #728
🤖 Generated with Claude Code