Skip to content

Add configurable progress display interval - #129

Merged
fcostaoliveira merged 9 commits into
redis:masterfrom
wanghenshui:add-timespin
Oct 17, 2026
Merged

fcostaoliveira merged 9 commits into
redis:masterfrom
wanghenshui:add-timespin

Conversation

@wanghenshui

@wanghenshui wanghenshui commented Jun 11, 2020 •

Copy link
Copy Markdown
Contributor

Problem

Long-running stress tests can produce more progress output than operators need. --progress-interval=5 now renders progress every five seconds, with a final update on normal completion. The default remains one second, and connection errors and other diagnostics retain their existing behavior.

Root cause

The original proposal changed the sleep in the main supervision loop. That loop now also enforces connection-stage deadlines, responds to interruption, and publishes live metrics and CPU samples, so changing its sleep would delay unrelated work.

Fix

Use a monotonic clock to gate only progress rendering, for both the normal and --realtime-latencies displays. Supervision, StatsD/Prometheus exports, CPU sampling, and latency histogram accumulation continue at their existing cadence. Instantaneous values still describe the most recent sample; average percentiles retain samples from hidden ticks. Each run has its own display timer, and normal completion renders its final frame even when the requested interval has not elapsed.

Accept positive whole seconds from 1 through UINT_MAX; zero, negative, fractional, malformed, and overflowing values fail during argument parsing. This is a new option, so zero has no released compatibility contract. Help, the man page, README, shell completion, --show-config, and the additive JSON configuration field progress_interval document the setting. Error suppression remains outside this feature's scope, as discussed in the original author response.

The branch preserves the original contribution and merges current master, including #257 and its already-merged fork CI prerequisite. The new setting is long-only: its name describes an interval in seconds and leaves the -f short option unassigned.

Tests

  • Six focused regression tests cover default and custom cadence in both displays, the long option and maximum interval, final frames in two runs, invalid values, unchanged StatsD/CPU sampling, JSON results, and preservation of a deliberately slow first request in the final realtime p100.
  • The focused tests fail on three discriminating mutations: unthrottled output emits five/six frames instead of at most four, omitting the final-frame exception emits zero frames for two short runs, and accumulating histograms only on displayed ticks loses the slow first request. All six tests pass with the implementation.
  • A silent setup peer aborts at 2.005 seconds for both intervals 1 and 100; SIGINT finishes at 0.502 seconds or less for both. Restoring the original proposal’s whole-loop sleep makes interval 100 exceed the six-second deadline guard.
  • Build and formatting pass, and all 14 C++ unit programs pass locally. Additional interaction controls preserve TLS/Unix backlog behavior, verification statuses, JSON closure, hidden latency samples and live metrics. Final CI remains required.

Affected versions

This adds an optional display setting; no released memtier version implements --progress-interval, so there is no released bug introducer or backport range. The one-second default preserves existing behavior.


Note

Low Risk
New optional output throttle with a 1-second default; core supervision and metrics paths are intentionally unchanged aside from display gating.

Overview
Adds --progress-interval=SECONDS so operators can throttle how often stderr progress is rendered (default 1 second, unchanged behavior). The supervisor loop still wakes every second; only display of the single-line progress line and --realtime-latencies blocks is gated with a monotonic clock, while StatsD/Prometheus exports, CPU sampling, timeouts, and per-second latency histogram accumulation keep their existing cadence. A final progress frame is still printed on normal completion (including when the interval is very large or across --run-count runs).

The option is validated as a positive whole second up to UINT_MAX, surfaced in --show-config, JSON progress_interval, help/man/README, and bash completion. Integration tests cover validation, throttling for both display modes, unchanged metrics sampling, and realtime latency samples from ticks that were not printed.

Reviewed by Cursor Bugbot for commit 2e9eacd. Bugbot is set up for automated code reviews on this repo. Configure here.

Test-only follow-up 2e9eacd replaces a timing-sensitive single slow request with slow samples spanning multiple hidden ticks. All six committed tests pass. Independent sanitizer checks pass seven positive scheduling cases and reject three accumulation mutants; the original fixture fails under an injected startup delay with correct runtime. Runtime code is unchanged; final CI is required.

🤖 Generated with Claude Code

@wanghenshui

Copy link
Copy Markdown
Contributor Author

ping @yossigo

@yossigo

yossigo commented Jun 11, 2020

Copy link
Copy Markdown
Contributor

@wanghenshui thank you! Just be sure I understand correctly, so you basically want the ability to bump up the print rate to overcome lots of messages produced by benchmark_*_log() prints on connection errors, etc.?

Did you consider an option to suppress those messages altogether, possibly narrowing it down to an additional errors counter?

@wanghenshui

Copy link
Copy Markdown
Contributor Author

@wanghenshui thank you! Just be sure I understand correctly, so you basically want the ability to bump up the print rate to overcome lots of messages produced by benchmark_*_log() prints on connection errors, etc.?

Did you consider an option to suppress those messages altogether, possibly narrowing it down to an additional errors counter?

we use memtier_benchmark as a stress tool, stress our redis-like server every day, print a log per second is also too much for analyze.

narrowing it down to an additional errors counter is also a good idea, maybe i implement it in next PR

@fcostaoliveira fcostaoliveira changed the title add print frequency Add configurable progress display interval Oct 17, 2026
@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

🤖 Automated first-pass review — a human maintainer's review is still required before merge.

Thanks for picking this old one back up. Gating only the rendering, and leaving the supervision loop's sleep(1) alone, looks right to me. The original whole-loop sleep would have held back the connection-stage deadlines, StatsD and CPU sampling, and the new test checks that those keep their cadence. The flag is wired through everywhere the new-CLI-option checklist asks for: enum, long_options[], switch case, struct field, default, usage(), man page, bash completion, and tests. progress_interval is only an added JSON config key, so nothing existing breaks for JSON consumers. A few comments:

  • The retry tails print errors N (+M) / retries N (+M), and prev_errors / prev_retry_attempts still update on every tick, including hidden ones. With --progress-interval=60 --retry-on-error, a shown frame could say (+0) even after hundreds of errors in the previous 59 seconds. The README does say instantaneous values describe the most recent sample. Still, I think most people will read (+M) as "since the last line I saw". Did you consider keeping separate "last displayed" baselines just for these deltas, so the totals and the + stay consistent? The same question applies to the realtime miss/abort "cur" values, though those read more naturally as per-second rates.

  • Moving the hdr_add into rtl_totals_hist out of the realtime branch looks equivalent to the old code: rtl_totals_hist is only allocated under --realtime-latencies, and inst_samples is the same non-empty check as before. The test with the slow first request is a good check that the gate really does fail without this move.

  • I checked the std::chrono::seconds(cfg->progress_interval) comparison at UINT_MAX. It promotes to steady_clock's nanosecond duration, which is about 4.3e18 and fits in int64, so the maximum value can't overflow there. Fine as is, I'm just noting I checked.

  • Nitpicking: about 150 lines of the diff are the realtime/single-line display blocks re-indented under the new if, so git blame on that block will now point at this PR. I wonder if moving the rendering into a small helper (or computing a render_progress bool and returning early from a helper) would keep the diff to the actual change. Not a blocker; clang-format makes this mostly mechanical anyway.

  • Nitpicking: the man page and usage() text run to four lines, which is long next to the neighbouring one-liners. The details about supervision and the instantaneous sample probably fit better in the README section you already added.

Overall this looks solid to me. I'd mostly like an answer on the (+M) delta question before merge.

(would file this as a comment, not a formal block)

@fcostaoliveira

Copy link
Copy Markdown
Collaborator

The intended scope is progress rendering only. The refreshed description follows the original author’s clarification that one progress update per second is too verbose; connection errors, supervision and metrics retain their existing cadence.

I kept the proposed --print-frequency/-f interface to preserve this PR’s feature identity; help and README explicitly define its value as a positive interval in seconds. This does not reserve a second alias or change existing options.

Fixed the man-page drift in 5303487: the cadence/sample wording now lives in usage(), and the option’s man-page section is generated verbatim by help2man. Regeneration preserves that text; unrelated generated header/version material was kept out of this small fix. Rebuild and the generated-section equality check pass; runtime is unchanged.

The CI fallback is the same integration prerequisite as #257: fork runs otherwise fail during matrix expansion because the repository variable is empty, even with all visible jobs green. Configured values take precedence over the fallback, which matches the upstream seven-image list. Once #257 merges this shared prerequisite will disappear from this PR’s base diff.

@fcostaoliveira

Copy link
Copy Markdown
Collaborator

I agree with the naming/short-option point after the independent maintainer pass. Final head849f8a2 now exposes long-only --progress-interval, with progress_interval in config/JSON; the unreleased --print-frequency/-f proposal is removed. Help, generated man text, README, completion and tests match.

The single gate around rendering stays: it makes the boundary between sampling and display explicit, whereas scattered fprintf guards would duplicate policy throughout the block. The histogram accumulation remains outside it. The maintainer review supports that tradeoff.

The shared CI fallback has landed in #257 and is now incorporated through a normal master merge, so it is no longer a feature-specific change here. No default special-case was added: the same monotonic interval condition applies consistently, and a normal completion still forces its final frame.

Timing checks pass6/6 in both optimized and combined ASan/LSan/UBSan builds, including the StatsD/CPU assertions. Independent controls caught a signed UINT_MAX narrowing mutant and verified long-running maximum intervals. A valid timed run can finish at101%, so the test now checks numeric completion>=100 rather than requiring an exact100% string; the renamed final suite passes6/6, and the merged head passes14unit programs. No local TSan execution is claimed; final CI remains required.

@fcostaoliveira

Copy link
Copy Markdown
Collaborator

Confirmed: rtl_totals_hist starts NULL and is allocated only with --realtime-latencies; hdr_add is guarded by that pointer and a nonempty instantaneous sample. Moving accumulation outside the render gate does not add a cumulative histogram in normal display mode.

The “cur” fields deliberately remain the most recent supervisor sample, even with a ten-second display interval. Changing their aggregation window would change existing metric/percentile semantics; help and README make this explicit, and independent output controls match the displayed values to the corresponding StatsD tick. Interrupt/setup-abort paths intentionally retain their previous early-break behavior; only normal completion forces a final frame.

The slow-first-request fixture is explicitly a standalone plaintext fake-peer test, regardless of the surrounding environment. Keeping it in the common adapter ensures it runs in ordinary test discovery; repeated matrix execution is not evidence of TLS/cluster coverage. The separate interaction probes exercise actual TLS/abstract backlog with hidden samples and live metrics. I am not claiming the fake-peer repeats as additional transport coverage.

I retained the single renderer gate for a clear sampling/rendering boundary. The remaining completion alias was removed in2ceba05; help/man now distinguish separate error diagnostics from counters inside progress frames. The independent maintainer recheck confirms completion, CLI names and generated documentation agree. All seven review lenses now converge; full final-head CI remains required.

@fcostaoliveira

Copy link
Copy Markdown
Collaborator

CI follow-up: the TSAN plaintext job failed only the hidden-latency fixture (final p100 0.439 ms versus the expected >200 ms); no ThreadSanitizer race was reported. A single early delayed request can fall out of the worker's per-second live histogram before a late supervisor snapshot. Test-only commit 2e9eacd now supplies slow samples across several hidden ticks, while retaining the final-frame latency and exact operation-count assertions. All six tests pass locally. Independent mutation/repetition checks and fresh full CI are required before merge; runtime code is unchanged.

@fcostaoliveira

Copy link
Copy Markdown
Collaborator

Reply to the review edited at 08:24:42 UTC:

The retry (+M) values intentionally remain deltas for the most recent supervisor sample, just like the other instantaneous fields. Cumulative error/retry totals still include every hidden tick. With a long display interval, a final (+0) alongside a larger cumulative total is therefore possible and expected. We considered separate last-displayed baselines, but that would make those two fields describe a different time window from the adjacent rates and change their existing sampling semantics. This option controls rendering frequency only; the README explicitly documents the latest-sample interpretation, and we retain it consistently for retries and realtime miss/abort values.

The mechanical enclosing render gate is retained to keep one policy boundary; extracting the entire rendering block would add a larger refactor and many live-stat arguments. The help/man detail is also retained so the distinction between display cadence and supervision/sampling is visible without consulting the README.

The test has since been strengthened: a single early slow request was timing-sensitive under TSAN because the worker can reset its per-second live histogram before the first supervisor snapshot. Test-only head2e9eacd supplies slow requests across several hidden ticks. An independent ASan/LSan/UBSan follow-up passed7 exact/correct-runtime cases, including1500ms/2200ms delays before the first supervisor tick; all3 faulty accumulation variants were rejected. The old fixture failed under the same1500ms delay with correct runtime, confirming the fixture defect. No production code changed. All six committed tests pass locally; fresh fullCI remains required before merge.

@fcostaoliveira
fcostaoliveira merged commit 563f372 into redis:master Oct 17, 2026
131 checks passed
@wanghenshui

Copy link
Copy Markdown
Contributor Author

thank you!

@wanghenshui
wanghenshui deleted the add-timespin branch October 23, 2026 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants