Repository navigation
feat(miss-tracking): hit/miss ratio columns and miss-rate warnings for arbitrary/monitor commands - #398
Merged
Conversation
…s for arbitrary/monitor commands - Extend print_hits_sec_column / print_missess_sec_column to emit per-command Hits/sec and Misses/sec rows in the text stats table when running with --command or --monitor-input (previously those columns were silently suppressed). - Fix MONITOR_RANDOM stats-only slots: populate spec and miss_tracking_enabled at creation time (resolve_command_meta returns early for empty argv), so runtime hit/miss accounting fires correctly for __monitor_line@__ mode. - Fix JSON Totals Hits/sec: in arbitrary-command runs the Totals row now sums m_arbitrary_misses instead of the always-zero GET-cmd counters. - Fix aggregate_average() to accumulate and average m_arbitrary_misses so --run-count > 1 AVERAGE reports show correct Hits/sec. - Fix --miss-rate-threshold=0 sentinel collision: initialise to -1.0 and check < 0 in config_init_defaults; add endptr == optarg and std::isfinite validation. - Add --miss-rate-threshold=PERCENTAGE CLI option (default 1%): emits a per-run warning to stderr when any command type exceeds the threshold. - Add startup warning when --monitor-input is given without --command. - Gate Command meta startup log behind --debug to reduce normal-run noise. - Add reply_shape_name() inline helper in command_meta.h. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
… non-zero aggregate_average() accumulated m_arbitrary_misses counts but never set m_start_time / m_end_time on the AVERAGE run_stats object. ts_diff then returned 0, the test_duration_usec > 0 guard failed in print_hits_sec_column and print_json, and Hits/sec / Misses/sec displayed as 0.0 in every AVERAGE report for arbitrary-command mode. Fix: accumulate the per-run duration inside the loop and stamp a synthetic m_end_time equal to the average run duration so rate calculations are correct. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
fcostaoliveira
added a commit
that referenced
this pull request
May 28, 2026
Reverts commits 6ef3821 and 0010c1f that were pushed directly to master instead of going through the pull-request workflow. The same changes land via PR #398 (filipecosta90:feat/miss-tracking). Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…s-rate threshold Adds tests/test_miss_rate_tracking.py covering: - Hits/sec and Misses/sec columns present in text output for --command GET - JSON Gets.Hits/sec is non-zero with preloaded keys - JSON Totals.Hits/sec is non-zero and consistent with per-type rows - __monitor_line@__ (MONITOR_RANDOM) Hits/sec is non-negative in JSON - --run-count > 1 AVERAGE report carries non-zero Hits/sec - --miss-rate-threshold warning fires when miss rate exceeds threshold - --miss-rate-threshold=0 fires for any miss - --miss-rate-threshold suppressed when all keys exist (100% hit rate) - --monitor-input without --command emits a startup warning - --miss-rate-threshold rejects empty string, NaN, and out-of-range values All 12 tests pass locally against OSS standalone. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 0c4af20. Configure here.
Code review (7 reviewers) surfaced two dead tests and several correctness items:
Tests (were passing vacuously):
- test_run_count_average_hits_sec_nonzero queried the wrong JSON key
("AVERAGE RESULTS" vs the real "AGGREGATED AVERAGE RESULTS (N runs)"), so it
always hit the graceful-skip and never exercised the aggregate_average fix.
Now locates the section dynamically and asserts Hits/sec and Misses/sec > 0.
- test_monitor_random_hits_sec_nonzero asserted only >= 0 (always true) despite
its name; now asserts > 0 for both Gets and Totals so a dead MONITOR_RANDOM
path would fail the test.
- test_hits_misses_columns_in_text_output now parses the Gets row numerically
and asserts text-vs-JSON Hits/sec / Misses/sec parity.
run_stats.cpp:
- print_hits_sec_column / print_missess_sec_column per-line loops now iterate
m_ar_commands.size() (same bound as the other columns) and guard
m_arbitrary_misses access, so the table can't misalign if the vectors diverge.
- aggregate_average now accumulates and averages per-key buckets too, so the
AGGREGATED AVERAGE report's "Per-Key Misses" JSON section is populated like
the BEST/WORST runs.
- print_json Totals skips the MONITOR_RANDOM placeholder slot to mirror the
text/aggregated Totals path exactly.
memtier_benchmark.cpp:
- --miss-rate-threshold help text now documents that 0 warns on any miss.
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
… counts Cursor Bugbot (Medium) flagged that dividing the unsigned m_arbitrary_misses counts by the run count uses integer division, truncating toward zero. For short or low-request runs this skews AVERAGE Hits/sec / Misses/sec and can zero out a small miss count, silently suppressing the miss-rate warning. Fix: keep the SUMMED counts and set the synthetic duration to the SUMMED run duration instead of the per-run average. The rate the print paths compute, count / ts_diff(start, end), is then the exact time-weighted average Σhits / Σduration — mathematically equal to dividing both by N but with no truncation. Per-key buckets are likewise left summed (the JSON "Per-Key Misses" section reports cumulative Total Hits/Misses across runs). (Bugbot also re-raised the High "AVERAGE shows zero Hits/sec" item; that is a false positive — the synthetic-duration block is present and the run-count integration test asserts AVERAGE Hits/sec > 0.) Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Collaborator
Author
|
Addressed the latest Cursor Bugbot review (commit d111e0f):
|
paulorsousa
approved these changes
May 28, 2026
This was referenced Oct 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Hits/secandMisses/seccolumns now appear for--commandand--monitor-inputmodes. Previously suppressed for arbitrary commands.spec/miss_tracking_enablednow populated at creation time (directcommand_meta::lookup()) so runtimeupdate_arbitrary_op_misses()fires correctly for__monitor_line@__mode.Totalsrow now sumsm_arbitrary_missesinstead of the always-zero GET-cmd counters, making JSON and text-table Totals consistent.aggregate_average()for--run-count > 1— accumulate and averagem_arbitrary_missesacross runs so AVERAGE reports show correct Hits/sec / Misses/sec.--miss-rate-threshold=PERCENTAGE(default 1%) — warns to stderr after each run when any command type's miss rate exceeds the threshold. Zero is a valid value; NaN and empty strings are rejected.--monitor-inputwithout--command— warns that the monitor file will be ignored.Command meta:startup log gated behind--debug.reply_shape_name()helper added tocommand_meta.h.Test plan
--command "GET __key__"→Hits/secandMisses/secappear in text table--command "__monitor_line@__"→ Hits/sec non-zero for GET-shaped commandsTotals.Hits/secmatches text table Totals row--run-count 3→ AVERAGE Hits/sec is plausible--miss-rate-threshold=0→ warnings fire for any miss--monitor-input filewithout--command→ startup warning emitted--debug --command "GET __key__"→Command meta: GETappears--miss-rate-threshold=nan/--miss-rate-threshold=are rejected🤖 Generated with Claude Code
Note
Low Risk
Changes are limited to benchmark stats aggregation, CLI options, and stderr warnings; no auth, persistence, or server protocol changes.
Overview
This PR improves hit/miss reporting for
--commandand--monitor-inputworkloads and adds configurable miss-rate warnings.Reporting: Text tables now show Hits/sec and Misses/sec for arbitrary commands (not only classic SET/GET). JSON Totals hit/miss rates are derived from
m_arbitrary_missesso they match the text table. With--run-count > 1,aggregate_average()sums arbitrary hit/miss counts and uses a summed duration so AVERAGE rows show correct rates (and per-key miss JSON stays populated).Monitor mode: Stats-only slots created for
__monitor_line@__/MONITOR_RANDOMgetcommand_meta::lookup()andmiss_tracking_enabledfrom reply shape so monitor-driven GETs actually accrue hits/misses.CLI: New
--miss-rate-threshold=PERCENTAGE(default 1%,0warns on any miss; invalid/empty/NaN/out-of-range rejected). Stderr warnings when a command type (or GET totals) exceeds the threshold. Warning if--monitor-inputis set without--command.--debuglogs resolvedreply_shape/ miss tracking per command type;reply_shape_name()added incommand_meta.h.Tests: New
tests/test_miss_rate_tracking.pycovers columns, JSON totals, monitor random, multi-run average, threshold warnings, and CLI validation.Reviewed by Cursor Bugbot for commit d111e0f. Bugbot is set up for automated code reviews on this repo. Configure here.