Skip to content

Cover short-run timestamp averaging and restore monitor test workloads - #816

Merged
fcostaoliveira merged 3 commits into
masterfrom
codex/test466-short-run-stats-20261023
Oct 23, 2026
Merged

fcostaoliveira merged 3 commits into
masterfrom
codex/test466-short-run-stats-20261023

Conversation

@fcostaoliveira

@fcostaoliveira fcostaoliveira commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

The short-run timestamp follow-up in #466 remained incomplete: no explicit second-boundary regression, monitor replay still used the 4,000-request workaround, and no small real-server throughput marker covered #463.

Root cause

The old timestamp helper averaged seconds and microseconds separately. The issue's two 200-microsecond intervals straddle a second boundary and expose that truncation deterministically. Production arithmetic is already fixed; this change closes the coverage gap using the existing C++ unit harness, without adding another test framework.

Simply restoring 1,000 requests weakens the monitor latency test: independently disabling the producer cap still passed its 50ms ceiling (13.311ms p99, versus 0.255ms with the cap on this host). A timing ceiling alone cannot protect that smaller workload.

Fix

  • Extend the existing run_stats unit through the production merge API: exact 200us duration and 10,000 ops/sec across a second boundary, every weight 2–16, and fractional averaging steps below one microsecond while retaining a one-microsecond duration.
  • Restore both monitor workloads to 1,000 requests. Add a deterministic check to the existing two-shard C++ fixture: a full global in-flight budget holds the producer, permits staged monitor commands to drain, and releases production after a reply. Keep the generous real-cluster p99 check as a smoke test and document its limits.
  • Add the requested 200-request/one-client/one-thread Python marker, validating JSON count/rate and exactly 200 successful server SETs. Both changed integration helpers honor the environment's authentication.

No production code or output format changes.

Tests

  • All17 C++ unit programs pass; C++ format check, Ruff F, Black on the new Python file, and diff checks pass.
  • Restoring the actual pre-fix(run_stats): normalize through int64_t microseconds in timeval_factorial_average (#463) #465 helper in an isolated object makes the run_stats unit fail38 checks, including the new boundary/weight assertions. The current helper passes.
  • Removing only the backpressure cap makes the new deterministic check fail at its producer-budget assertion. The smaller real-server timing test alone accepts that mutant, as documented above.
  • Actual RLTest: standalone1/1 and three-shard cluster3/3 pass with authenticated private endpoints. The short-run marker checks server execution counts as well as JSON. No claim that wall-clock timing in that smoke forces the rounding bug; the deterministic C++ case supplies that gate.
  • Initial validation mistakes (missing auth propagation, assuming an optional Errors field, and constructing a staged test command without its required argument) were corrected before these successful results. Seven independent reviews and full new-head CI remain required.

Affected versions

This is test coverage for already-fixed arithmetic. The old helper was introduced by58a1bdbd7c0667d6a53519f88ba93b019690a6d0; containing tags begin at1.2.16. Source inspection confirms the old formula through2.4.3. Mainline fixb4b18c0cf430b6006fcf5f855a58ca6d6e28552a is in2.5.0–2.5.2; backport405d596bffc167291d86046a727785c218a27a7c also fixes2.4.4. The monitor workaround came with1e596c16e57ccafdfa55c9b27eeb24be66506ad9, present in2.4.0–2.5.2 and current master. These ranges are established by git tag --contains plus release-source inspection, not runtime tests of every release.

Fixes #466

🤖 Generated with Claude Code


Note

Low Risk
Adds and adjusts tests only; no runtime, auth, or stats logic changes in production code.

Overview
Test-only follow-up for #466: closes gaps around short-run stats (#463) and monitor-cluster backpressure without changing production code.

run_stats_merge_test adds test_submillisecond_merge, exercising run_stats::merge() across second boundaries so merged duration stays 200µs (not the old ~500ms bug), ops/sec is correct, merge weights 2–16 stay exact, and 1µs durations survive fractional averaging.

Monitor / backpressure: integration workloads drop from 4000 → 1000 requests now that timestamp averaging is fixed; docs note the real-cluster p99 smoke cannot catch a disabled producer cap at that size. cluster_transaction_test adds a deterministic hold_pipeline regression (global in-flight budget pause, staged drain, resume after reply). Monitor helpers pass --authenticate when the env has a password.

New test_short_run_stats.py: 200-request real-server smoke checks JSON Count, zero connection errors, 200 server SETs, and positive Ops/sec; exact rounding stays in C++.

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

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

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

Thanks, this is test-only and the reasoning in the description holds up. I went through the run_stats cases by hand. The first merge averages 1700999900 and 1701000050 to 1700999975. The arithmetic-progression series lands exactly on +16i at every weight, because diff = 16(i+1) divides evenly. The tiny-offset loop keeps start at epoch_usec and duration at 1us, since every floor(1/w) step after the first is 0. So the new asserts match timeval_factorial_average as written today. The description also says the old helper fails these asserts, which is the bar test_json_output_integrity.py set in #364.

One structural question:

  • check_monitor_backpressure() runs at the end of check_repin_routes_to_staged_owner(), after flipping config.transaction = false / config.pipeline = 1 on that test's config. It works, since it only needs a two-connection client whose second shard isn't conn_disconnected. But a future failure in the cap check will show up inside the Cluster --transaction --pipeline > 1: lone key index left in m_key_index_pools crashes with vector::_M_range_check #580 re-pin test, and a change to that fixture could quietly change the backpressure preconditions. The added check()s on connection count and config guard against part of that. Did you consider giving it its own small fixture (or at least its own top-level check_* call in main())? I may be wrong and the shared socket/listener setup isn't worth duplicating.

Nitpicking: the comment above the series loop says "every weight 2..16", but the loop also covers weight 1 (the initial merge into an empty run_stats). That's harmless, but the comment could just say 1..16.

I'd be fine with this as is. The fixture placement is the only thing I'd want a second look at.

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

@fcostaoliveira

Copy link
Copy Markdown
Collaborator Author

Addressed the fixture-precondition point in cf493c2: the helper now explicitly checks requests==0 and pipeline==1, so an earlier request-limit return cannot silently satisfy the producer-budget assertion after a fixture change. The comment now describes the enduring purpose rather than this PR. The fixed unit passes and the isolated cap-removal mutant still fails at the intended producer-budget assertion.

I considered a separate top-level test. This keeps the existing two-shard socket/protocol fixture, with the backpressure assertions in their own named helper. The local config changes occur after the repin assertions and immediately before fixture destruction; they do not leak into another test. Duplicating that setup for these three checks would add socket and cleanup code without strengthening the regression. The explicit precondition and assertion messages make the additional contract clear.

The independent TEST review also killed strict-greater-than cap, blocked-staged-drain and no-resume mutants; final-head recheck and the other six reviews/full CI remain required.

@fcostaoliveira

Copy link
Copy Markdown
Collaborator Author

The interaction review supplied a concrete reason to separate the fixture: #799 adds more transaction assertions at the old insertion point, and its terminal state must not affect a monitor-cap check. In24c3ac6 the backpressure check now has its own fresh scoped two-shard client/listener and a separate top-level test function. The repin test has no configuration or counter changes from this PR. The class helper is also placed away from #799's additions.

The fixed unit passes; removing the cap still fails at the intended budget assertion. The independent integration reviewer confirms the final head merges cleanly with all six pending fixes and preserves #799's transaction assertions; composed runtime validation is in progress. Final-head focused rechecks and CI remain required.

@fcostaoliveira
fcostaoliveira merged commit 9ac1544 into master Oct 23, 2026
143 checks passed
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.

run_stats: add unit-test scaffolding + revert PR #465 workarounds + add #463 regression marker

1 participant