Repository navigation
Support HSCAN, SSCAN and ZSCAN cursor iteration - #539
Conversation
|
🤖 Automated first-pass review — a human maintainer's review is still required before merge. Thanks for this — read the description first and then went through the diff, a few questions below. On the generated-argument pinning: I think the new semantics are clearly the right ones (a walk that re-rolls its own On the initial-stats label: keeping Nitpicking: One note rather than a question: the new The new test file looks genuinely thorough — binary/empty/quoted keys, caps, reconnects, transactions, nonzero cursors, and a MONITOR wire-level oracle instead of just trusting the counters. No new CLI flag is added here, so the usage/man/README trio is the right surface and it's all updated. The implementation reads sound to me; I'd want the compatibility question answered before this merges, and a sentence either way on the label question. (would file this as a comment, not a formal block) |
|
Addressed the first review in dc2480a:
The two mode checks remain in the generated-argument branches of the shared arbitrary writer; only iteration mode copies argument bytes. This avoids a second arbitrary-command implementation. No performance improvement is claimed for those checks. All 28 new/existing SCAN tests pass after these changes. The full optimized standalone suite passed 339/339 before this small refactor and is being repeated on the new head. The earlier slow instrumented timing failures do not reproduce in the optimized full run. 5a823f7 separately repairs the three unrelated CI build failures while retaining all matrix cells: Bullseye's missing security packages use a signed immutable snapshot; the macOS OpenSSL 1.0.2 job builds libevent against that same SSL installation. Bullseye Docker build/unit tests and a locally built OpenSSL 1.0.2/libevent stack both pass; macOS remains a remote CI gate. |
|
Addressing the second review:
The requested non-scan performance comparison initially suggested a SET pipeline-1 slowdown in three short, busy-host pairs. Nine longer alternating baseline/current pairs after local suites finished did not reproduce it: median throughput +0.73%, median CPU/op -0.76%, with mixed signs between pairs and varying CPU frequency. No persistent regression was detected; this is not a claim that the branches are literally free. I kept the shared argument writer rather than duplicating it or introducing template specialization without measured benefit. A pre-existing cluster TLS statistical-test failure is still being investigated before final CI approval. |
|
Addressed the latest review:
The cluster TLS failure has been diagnosed and fixed in its own test-only commit: the old pooled Zipfian correlation bound failed on unmodified master 3/8 times and on the feature binary 2/8 times under constrained scheduling, despite identical HSET samples. The replacement verifies per-command key patterns and exact MONITOR/Redis/JSON counts. All 32 transport/topology cases and six constrained baseline/current reruns pass. Swapped-pattern and frozen-key mutations fail as intended. Independent implementation, build, and test reviews approve the result. Final-head CI remains the gate before merge, along with the repository's required maintainer review. |
|
Addressed the latest review:
No C++ changes were needed in this round. The expanded scan tests are being run across the same ten local variants, followed by the complete remote matrix and bot checks. |
91afc14 to
9793a3e
Compare
9793a3e to
9427ffa
Compare
|
The independent validation repairs are now split into #540. Both PRs target master because the existing workflow branch filters require that target; #540 is the prerequisite and should merge first. Its changes can then be removed from this diff by rebasing if necessary. The feature rebase preserves the entire validated Git tree exactly. On the remaining design questions:
Latest local validation is complete: 300/300 focused tests across ten variants; full plaintext and TLS each 286 passed/55 expected skips; full cluster 162 passed/179 expected skips; zero failures. Added executable C++ coverage is 37/37. All three agents approve the code and tests. Full remote checks are running on both reviewable PRs. |
9427ffa to
7e47c75
Compare
|
The feature is rebased onto the reviewed prerequisite update (now #540/e95fb1a). Compared with the previous feature head, only the prerequisite CI/test guard files changed; all scan C++ and integration tests are byte-identical. On the latest questions:
The optional CLI fuzz, MONITOR fuzz, differential, and soak gates are now enabled in addition to the full platform matrix. All three agents approve the implementation and tests; maintainer review remains required. |
7e47c75 to
ca3c99f
Compare
|
Settled the two requested points with another independent source/evidence review:
The next page similarly sends The remaining choices were weighed explicitly in the previous reply: uniform initial-bucket labels, retaining one shared emitter, and failing capture on a socket timeout because redis-py disconnects. A member bool retains the branch; selecting separate emitters introduces another dispatch/code path, with no demonstrated benefit in the measured results. The short socket timeout bounds a stalled post-benchmark drain; the absolute deadline separately bounds continuous traffic. The helper fault tests prove that missing markers, continuous frames, and failed benchmarks cannot hang or mutate the shared pool. That evidence is worth retaining after adding this capture oracle. The two SCAN regressions share its exact raw-argument capture helper and remain in this file to avoid a cross-module helper refactor; every sanitizer matrix explicitly runs both scan files. All three agents approve the current implementation. The post-prerequisite rebase still needs the usual fresh review/gates; no bypass is proposed. |
9dcd656 to
eb2164a
Compare
|
Addressed the final hot-loop request in eb2164a: the immutable scan flag is read once into a local Fresh local validation: 300/300 focused tests across all ten variants, 38/38 added executable C++ lines covered, 2/2 unit tests and formatting passed. All four full local topology/transport suites are rerunning on the matching optimized V5 binary. The performance measurements in the description are now explicitly identified as pre-hoist measurements. The latest resize and MONITOR-timeout suggestions were evaluated in the preceding replies: release-mode one-command validation plus fixed scan dispatch bound actual accesses; retrying a redis-py timeout would continue after disconnection and lose capture continuity. No change to those deliberate choices. The prerequisite rebase and maintainer approval remain required before merge. |
|
The latest review raises the same compatibility decision already weighed in the earlier reply: we considered preserving regeneration for keyspace SCAN, and chose the documented bug fix because changing MATCH mid-walk changes the query being iterated. Gating only the collection key would preserve that inconsistency. The explicit README note and isolated old-master-failing regression are deliberate; final maintainer review should evaluate that behavior choice. We do not claim it is wire-compatible with the old generated-MATCH behavior. The prerequisite split/rebase requirement is unchanged: #540 must land first, then this feature receives a fresh post-rebase review and gates. The final intended feature diff is the nine feature files. The shared-builder tradeoff has also been evaluated: the final code hoists the immutable configuration read; a dedicated builder would duplicate argument-generation/transaction/error handling. We have not claimed zero overhead, and the measured comparison is being refreshed for the final hoist after local full suites free the host. The new No further code change is justified by this review round. Final-head focused validation is 300/300 with 38/38 added executable C++ lines covered; the full local and remote suites are still running. |
|
Final validation is complete on
Final-source arbitrary-command performance versus master
Both uncertainty intervals include zero, with observed run spreads of 4.68–7.37%. The negative central estimates are retained: no demonstrated regression at this resolution, but neither zero overhead nor exclusion of a small regression is established. CPU affinity was fixed and other local agent workloads stopped; shared-host clock/scheduling variation still limits attribution. Raw pairs and provenance are retained locally. Both PR worktrees are clean and all owned Redis processes have been stopped. #540 is also green (119 successful checks, six intentional conditional skips). The remaining gate is the repository's required maintainer approval: merge #540 first, then refresh this PR against master and require the applicable review/checks before merging. |
eb2164a to
45043d4
Compare
|
Addressed the concrete documentation points from the latest review: the description now names For the design questions:
#540 is now merged and removed from this diff. All three independent agents verified the exact rebase and reaffirmed approval. Fresh CI is running on the final comment correction; no runtime source or test threshold changed. |
|
The final review's requested invariant comments are now explicit in eddf238: cursor assignment notes that the later separate formatting pass classifies The label question is answered in the previous reply: cross-command consistency is intentional, and I added release-note wording to the PR description for the generated-MATCH behavior change. This repository has no checked-in release-notes/changelog file; the README documents the change for users, and the PR wording is ready to carry into the next release notes. For MONITOR timing, the drain begins only after the benchmark exits and the ECHO marker is acknowledged by Redis, so the observed command stream is already produced. The one-second socket timeout bounds a missing read; the separate absolute deadline also bounds continuous unwanted traffic. Both local TSan plaintext/TLS cells passed, as did the earlier complete final-source CI TSan cells. Fresh cells are running again. We retain the harness fault test because its deadline/cleanup behavior is necessary for trustworthy integration results; dependency-induced failures should be visible when redis-py changes. No runtime source or test threshold was changed in this review round. The previous hot-path question is now explicitly accepted in the bot's review, and neither bot has an unresolved inline finding. |
|
Both remaining design questions are now explicit in the PR description as well as the earlier replies:
The cache-bound nit was answered in the prior design reply, and eddf238's setup comment now states that the copied commands have matching indices. We retain the small defensive release-build bound and diagnostic assertions. No further runtime change is warranted. All three independent agents approve eddf238; final-head CI is still running, with no failures currently. Merge will wait for its completion. |
…ration (#574) * test-suites: add three ZSCAN full-walk specs using memtier cursor iteration The existing ZSCAN specs re-issue cursor 0 on every call, so they only ever measure the first page of a ZSCAN. memtier_benchmark now follows the cursor returned by ZSCAN (--scan-incremental-iteration, redis/memtier_benchmark#539), so add full-traversal companions for the three shapes that matter: - 1key-zset-200K-elements-zscan-count-10-incremental-iteration (200K members, default COUNT: ~20,000 cursor round-trips per walk) - 1key-zset-200K-elements-zscan-count-1000-incremental-iteration (200K members, COUNT 1000: ~200 reply-construction-dominated pages per walk) - 1key-zset-1K-elements-zscan-incremental-iteration (1,000 members with non-integral scores: every emitted score takes the non-integer formatting path) Datasets, key names and encodings are the same as the first-page siblings so the two numbers can be read side by side. Each client keeps its own cursor, walks until the server returns 0 and starts over; memtier reports the initial "ZSCAN 0" requests and the "ZSCAN <cursor>" continuations separately and the exported Totals covers both. --pipeline 1 is required by the iteration mode. The existing first-page specs are left untouched. * test-suites: 1K ZSCAN full-walk spec — accurate dataset label, bare command like its sibling dataset_name/description no longer inherit the sibling's stale "1key-sorted-set-32B-size" / "redis set data structures" label; the client command drops the explicit COUNT 10 so it matches memtier_benchmark-1key-zset-1K-elements-zscan exactly (COUNT 10 is the server default, as the description states). * test-suites: one label for the zset:1000 dataset across its three specs The two existing specs that load the identical zset:1000 payload (1K-elements-zscan, 1K-elements-zrange-all-elements) take the same accurate dataset_name/dataset_description as the new full-walk spec, so the runner's unique-dataset accounting and the profiling label see one dataset. Metadata only; commands, preloads and encodings are unchanged.
--scan-incremental-iterationnow follows cursors for HSCAN, SSCAN, and ZSCAN, using the key before the cursor and retaining each client's generated arguments throughout a walk. Generated keys advance when the walk completes or reaches its continuation cap, including with transactions and planned reconnects. The existing one-command, pipeline-1, standalone restrictions remain.The independent CI/oracle repairs landed in #540. This PR is rebased onto master
2552312and contains only the nine feature-related files. The rebase preserved the complete previously validatedeb2164atree. Subsequent changes only correct a Python test comment and clarify C++ formatting/cache invariants; executable Python and C++ are unchanged.Continuation commands copy parsed arguments and replace only the cursor, preserving quoted, empty, and binary keys/MATCH patterns. This fixes quoted MATCH continuations for existing SCAN workloads. Keeping generated MATCH arguments fixed also fixes inconsistent query semantics: a cursor walk must retain its query filter. Previously those arguments were regenerated on continuations. We considered an opt-out and preserving regeneration only for keyspace SCAN, but chose to make the existing opt-in cursor-walk mode retain one query throughout the walk. The old changing-filter load profile is not retained; a fixed request budget can therefore cover fewer distinct generated patterns. README explicitly documents that behavior change, and
test_scan_generated_match_stays_fixed_per_walkfails on the old master and passes here.All four commands use the same stable initial-statistics bucket,
<COMMAND> 0, even for a supplied nonzero cursor; the supplied cursor is still sent on the wire. Existing SCAN consumers retain compatibility; the three new commands adopt that convention for cross-command consistency. README and the man page explain this convention. Copied metadata remains valid because cursor replacement does not change key positions; continuation accounting still uses the separate stats-only entry. Cache allocation covers both argument forms in release builds, with assertions for diagnostics.Release-note wording: HSCAN, SSCAN and ZSCAN now support
--scan-incremental-iteration; existing SCAN walks preserve quoted arguments and keep generated MATCH arguments fixed until the walk ends. This changes generated-pattern coverage per request budget for existing users of that opt-in flag.Closes #536. Closes #537. Closes #538.
Validation:
The final source reads the immutable scan flag once before the argument loop. Nine alternating baseline/final pairs per arbitrary GET and SET workload (pipeline 1, 10 measured seconds per run, fixed client/server CPU affinity, otherwise quiet host) gave median throughput changes of -0.84% / -0.24%. Paired medians were -1.16% / -0.17%, with descriptive 95% bootstrap intervals [-2.58%, +2.75%] / [-1.04%, +2.87%]. Run spreads were 4.68–7.37%; both intervals include zero. These results retain the negative central estimates, establish no demonstrated regression at this resolution, and do not establish zero overhead or rule out a small regression. Shared-host scheduling and CPU-frequency variation limit causal attribution.
All applicable CI and both review bots passed on final head
eddf238: 130 successful checks, no failures or pending checks, and one intentional package-publishing skip. This includes CLI/MONITOR fuzz, differential testing, and all seven soak scenarios including the 30-minute memory soak. All three independent agents approve the final commit.