Repository navigation
Stop the --run-count series on Ctrl+C - #698
Conversation
|
🤖 Automated first-pass review — a human maintainer's review is still required before merge. Thanks for this. I went through the diff and the description, and I have a few comments below. On the behaviour decision you asked about: I think ending the whole series on Ctrl+C is what a user expects, so I wouldn't push back on it. Keeping the
The core fix looks solid. I'd mainly like the first point confirmed as intended before this merges. |
0c47a31 to
0be4a85
Compare
|
Thanks for the review. Taking the points in order (pushed in 10846ec):
|
10846ec to
0373d28
Compare
With --run-count=N, Ctrl+C stopped only the current run. g_interrupted stays set and the run loop in main() never looked at it, so every remaining run started anyway: a 1 s settle pause, then 1 s of full load (the supervisor sleeps before it checks g_interrupted), then another "Interrupted by user". Those fragments were counted in BEST/WORST and in "AGGREGATED AVERAGE RESULTS (N runs)", where N was cfg.run_count. The loop now stops before starting another run once g_interrupted is set, checked before and after the settle pause. The run that was interrupted is kept (it is marked Interrupted), and run 1 always runs so the summary is never empty. A stderr line says how many runs were done. The section layout still follows --run-count; the "(N runs)" header uses the runs that happened, and aggregate_average() marks the average Interrupted if any of its runs was, like merge() already does. Test F27 relied on run 2 starting after Ctrl+C to scrape run 1's run-end snapshot in the gap. It now writes the results to a one-page FIFO that it does not read, so memtier blocks after publishing the run-end snapshot and the exporter stays up until the test drains it. It still fails if the run-end publish skips the live histograms. Fixes #690 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Address review of the #690 fix: - The aggregate section stays "AGGREGATED AVERAGE RESULTS (<run_count> runs)", the key in-repo consumers build from --run-count. The number of runs it holds is now reported as "Runs completed" in the JSON "run information" section, and as a text line when the series was cut short. - A Ctrl+C that lands in the settle pause between runs stops the series without interrupting any run. BEST, WORST and the aggregate are now marked Interrupted whenever fewer runs completed than requested. - Add a test that interrupts in the settle pause after run 1. It fails if the g_interrupted check after the pause is dropped. The run-count tests also check "Runs completed" and that the one-run average equals that run. - F27 skips when the FIFO cannot be shrunk to 4 KiB (64 KiB pages). - Reword the loop comment: SIGINT can be delivered to another thread, in which case sleep() is not cut short. Refs #690 Co-Authored-By: Claude Opus 5.5 <[email protected]>
When Ctrl+C cuts the --run-count series short, mark every completed run Interrupted before any section is printed, instead of only BEST and WORST after the per-run sections. With --print-all-runs, RUN #k now agrees with BEST/WORST for the same run. The aggregate picks the flag up through aggregate_average(). Add a test for Ctrl+C during the last run (--run-count=2, all runs done, nothing skipped). There the aggregate's Interrupted flag comes only from aggregate_average() carrying it over from the interrupted run, which no other test covered. The run-count tests now also run with --print-all-runs and check RUN #1's flag. Refs #690 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Marking every run of a cut series Interrupted made a run's flag depend on --run-count: a run 1 that completed cleanly before a Ctrl+C in run 2 was "true" with --run-count=3 but "false" with --run-count=2, and a consumer that drops interrupted runs would lose complete data. Each RUN #k now keeps its own flag, true only for the run that saw the signal. BEST and WORST are runs, so they carry that run's flag. Only the AGGREGATED section is marked when the series was cut short (or, via aggregate_average(), when any run was interrupted). A cut series is visible from "Runs completed" < run_count and the text line. The settle-pause test now expects RUN #1/BEST/WORST "false" and AGG "true". F27: comment why run_end is re-checked after assertTrue. Refs #690 Co-Authored-By: Claude Opus 5.5 <[email protected]>
0373d28 to
5cf0496
Compare
|
Thanks. On the question from the 10:42 edit: agreed, and changed in 5cf0496.
|
|
Re the automated review as edited at 10:54:
|
test_interrupt_between_runs_stops_run_count waited for "[RUN #1 100% ... 0 threads" before sending SIGINT. On a slow build (the TSAN CI cells) the progress of a --test-time run goes past 100% ("[RUN #1 104%, 1 secs] 0 threads"), so the trigger never matched, memtier ran all three runs, and the SIGINT went to an exited process. memtier itself handled the signal fine: under TSAN the 0-threads line comes about 1.002 s before "[RUN #2", so the signal sent 0.4 s after it lands in the settle pause as intended. Match any percentage, and fail clearly if the trigger has not fired before memtier exits. Refs #690 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Re the automated review as edited at 11:10:
|
After the rebase onto #698, its "skipping the remaining runs" note still said "Interrupted by user (Ctrl+C)" for a SIGTERM. It now names the signal, like the per-run interrupt message, through one helper. A second SIGINT or SIGTERM now resets the handler to the default action and re-raises, so it terminates memtier immediately. This keeps a way out of a shutdown that is stuck, which a process without a handler always had. Document the interrupt behaviour in the README and the --run-count help line (and man page), and add tests: SIGTERM during run 1 and in the settle pause of --run-count 3, and a second SIGTERM killing memtier while it is held in open() of a --json-out-file FIFO. Fixes #704 Co-Authored-By: Claude Opus 5.5 <[email protected]>
After the rebase onto #698, its "skipping the remaining runs" note still said "Interrupted by user (Ctrl+C)" for a SIGTERM. It now names the signal, like the per-run interrupt message, through one helper. A second SIGINT or SIGTERM now resets the handler to the default action and re-raises, so it terminates memtier immediately. This keeps a way out of a shutdown that is stuck, which a process without a handler always had. Document the interrupt behaviour in the README and the --run-count help line (and man page), and add tests: SIGTERM during run 1 and in the settle pause of --run-count 3, and a second SIGTERM killing memtier while it is held in open() of a --json-out-file FIFO. Fixes #704 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Behaviour decision (for maintainers to push back on): Ctrl+C now ends the whole
--run-countseries. The run that was interrupted is kept and markedInterrupted: true. No later run starts.--run-count: BEST / WORST /AGGREGATED AVERAGE RESULTS (<run_count> runs). This is the key that in-repo consumers build from the run count (tests/test_cluster_redirect_stats.py:145,tests/tests_oss_simple_flow.py:489,tests/test_hdr_histogram.py:220).--print-all-runs, theRUN #k RESULTSsections are also cut back to those runs."Runs completed"in the JSONrun informationsection. The count includes the interrupted run;1 Runs completed (of 3, interrupted);Interrupted by user (Ctrl+C), skipping the remaining runs (k of N done).RUN #kisInterrupted: trueonly for the run that actually saw the signal. A run that completed cleanly before the cut staysfalse, whatever--run-countis, so a consumer that drops interrupted runs keeps complete data. BEST and WORST are copies of a run, so they carry that run's flag.Runs completedbeing lower thanrun_countinconfiguration, and from the text line.Also affected, besides Ctrl+C:
aggregate_average()now carries over any run'sInterruptedflag. So when a--connection-stage-timeoutabort ends run 1 of a--run-countseries (the abort callsinterrupt(), and the next run resets the abort flag and continues), AGGREGATED is now markedInterrupted: "true"too. This is intended: the average includes a truncated run. Only that run and the aggregate are marked.Problem
With
--run-count=N, Ctrl+C stopped only the current run. memtier then started every remaining run anyway. Each one sent about 1 s of full load, was interrupted, and was counted in BEST/WORST/AGGREGATED. The aggregate saidInterrupted: false.Root cause
g_interruptedis set once bysigint_handler()and is never cleared. The run loop inmain()never checks it.run_benchmark()callssleep(1)before it checksg_interrupted, so each extra run sends a full second of load. Together with the 1 s settle pause between runs, that is about 2 s per remaining run.run_stats::aggregate_average()did not carrym_interruptedover from its runs.merge()already does.Fix
main(): before starting run 2 and every later run, checkg_interruptedboth before and after the settlesleep(1). The signal can arrive during the pause; if it goes to another thread,sleep()is not cut short, and the second check still catches it. Run 1 always runs, soall_statsis never empty.Runs completedand the stderr note described above.all_stats.size() < cfg.run_count), mark the aggregate Interrupted. Per-run flags are left alone.aggregate_average(): the average is marked interrupted if any of its runs was.Tests
Pass/fail counts are from local runs.
test_interrupt_stops_run_count(new). Sends SIGINT 1.5 s into--run-count=3 --test-time=30. It checks:Interrupted by userline, and no[RUN #2;Runs completed == 1;AGGREGATED AVERAGE RESULTS (3 runs)are allInterrupted: "true";Results: origin/master 3/3 FAIL; this branch 5/5 PASS, plus PASS on oss-cluster with 3 shards.
test_interrupt_between_runs_stops_run_count(new). Runs--run-count=3 --test-time=1. The test waits until run 1's last progress line ([RUN #1 <any>% ... 0 threads; on TSAN builds progress goes past 100%, which is what broke the first CI run), waits another 0.4 s so the SIGINT lands inside the settle pause, then sends it. It checks: no[RUN #2,Runs completed == 1, RUN pcre required for build #1 / BEST / WORSTInterrupted: "false"(run 1 completed cleanly), and the aggregateInterrupted: "true".g_interruptedcheck after the pause--enable-thread-sanitizer,setarch -R, CI suppressions), this branchif (series_cut) average.set_interrupted(true);test_interrupt_last_run_marks_aggregate(new). Runs--run-count=2 --test-time=2and sends SIGINT 0.5 s after[RUN #2appears. It checks: oneInterrupted by userline, no skip note,Runs completed == 2, RUN pcre required for build #1Interrupted: "false", RUN CentOS release 6.4 (Final) installation torture #2 andAGGREGATED AVERAGE RESULTS (2 runs)Interrupted: "true".if (i->m_interrupted) m_interrupted = true;inaggregate_average()This is the only test that catches that mutant. In the series-cut tests, the cut-series marking also sets the aggregate's flag, so they pass on it.
All three interrupt tests run with
--print-all-runsand check thatRUN #1 RESULTSand BEST/WORST carry the same flag.F27intests/test_prometheus.py(from Export every operation in memtier_latency_seconds (fixes #637) #665). It relied on run 2 starting after Ctrl+C, so that it could scrape run 1's run-end snapshot in the gap before run 2. That gap no longer exists.--out-file) to a FIFO shrunk to one page (F_SETPIPE_SZ4096) and does not read it. memtier publishes the run-end snapshot and then blocks writing the results. Nothing is written to the out file before the run loop ends, so the exporter stays up._count == ops_total, then drains the FIFO and checks exit code 0.F_SETPIPE_SZ, or 64 KiB pages).Results: this branch 8/8 PASS, plus PASS on oss-cluster. The mutant with
prom_publish_run_endusingprom_drain_latency(cfg, threads, false)fails 8/8 (for example_count 1522688 != ops_total 1749472).Existing tests:
test_interrupt_signal_handling,test_print_all_runsandtest_aggregated_average_totals_histogramstill pass.Manual repro:
timeout -s INT 2 memtier_benchmark --test-time=30 --run-count=3 --print-all-runs ...Interrupted by userlines (2.0 s, 1.0 s, 1.0 s), 6.1 s wall time, and an aggregate withInterrupted: false.RUN #1, BEST, WORST andAGGREGATED AVERAGE RESULTS (3 runs), allInterrupted: true(run 1 saw the signal) with the same Ops/sec, andRuns completed: 1.Fixes #690
Affected versions
2.3.0 through 2.5.2 (latest) and master.
sigint_handler/g_interruptedand the check insiderun_benchmark(), but not in the--run-countloop. Before that commit, SIGINT killed the process. The first tag that contains it is 2.3.0.Found during the review of PR #665.
🤖 Generated with Claude Code