Repository navigation
feat: add a CAS read-modify-write workload to ocachecli bench and the benchmark CI - #260
Conversation
… benchmark CI
Adds an OpCAS workload op ("cas=N" in a custom mix): one guarded
read-modify-write per op — GetWithVersion, then PutIfVersion against the
version just read — which is the write-coordination pattern conditional
operations exist for (issue #254). Losing the race (a VersionMismatchError) is
the expected outcome under contention, so it is counted as a mismatch and
reported as its own rate, never folded into Errors. Results gain
CASAttempts/CASWins/CASMismatches and a "CAS Outcomes" section.
CAS keys live in their own namespace, preloaded with put-if-absent, so a key is
never both plain-written and CAS-guarded (an unsupported mix); plain keys are
only preloaded when the mix uses read/update. Streaming variants apply on the
same threshold as the plain ops. Works unchanged in simple and cluster mode.
Two tests pin the accounting invariants against an in-process gRPC server:
every attempt is a win or a mismatch, a lost race is never an error, and the
server applied exactly one version bump per reported win; a single worker
never mismatches.
The single-node and 3-node cluster benchmarks each gain a contended CAS step
(16 workers over 200 keys, 100 B) and a mixed read=70,cas=30 step at 100 KB
(raw-file tier, so CAS wins spill and reclaim under compaction). Live smoke on
a real server: 4000 contended attempts, 7.3% mismatch rate, 0 errors.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YCoN4Him5ZY4hZovVp37ra
Signed-off-by: Ovais Tariq <[email protected]>
Greptile SummaryThe latest changes address both previous review findings:
Confidence Score: 5/5The PR appears safe to merge; both previous findings are resolved and no new actionable issue was introduced by the follow-up changes. Preload accounting now consistently uses the actual number of attempted puts, and CAS result classification is centralized in the metrics layer as required. The previous threads were manually resolved after the corresponding fixes, and no blocking failure remains. Important Files Changed
Reviews (3): Last reviewed commit: "fix(bench): size preload accounting by p..." | Re-trigger Greptile |
The contended CAS step deliberately runs 16 workers over 200 keys to produce a measurable mismatch rate, but that conflates CAS cost with 2x the concurrency and a 5x narrower keyspace than the plain 100-byte baselines use. Add a step at the plain defaults (8 workers, 1000 keys, 100 B) so the only variable is the op itself, isolating what one guarded read-modify-write costs over its two constituent RPCs — and letting the contended run be read purely as the contention signal. Placed before the contended step in both workflows. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01YCoN4Him5ZY4hZovVp37ra Signed-off-by: Ovais Tariq <[email protected]>
…fication In a mixed plain/CAS workload each key index does one preload put per enabled namespace, but the preload summary and the 10% failure threshold divided by cfg.NumKeys, so a run with errors could report "Preloaded 1999/1000 keys" and errors across both namespaces could abort a run that was within tolerance per namespace. Size both by the number of puts actually attempted. Move the win/mismatch/error classification of a conditional-write result into the metrics layer (ClassifyCASResult, with a CASOutcome type); the worker and the preload now only count what it returns, and the lost-race rule — a VersionMismatchError is a mismatch with no error — is stated in one place. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01YCoN4Him5ZY4hZovVp37ra Signed-off-by: Ovais Tariq <[email protected]>
|
Addressed both findings in 67ec315: preload accounting is now sized by puts attempted (NumKeys per enabled namespace) for both the summary and the failure threshold, and CAS win/mismatch/error classification is centralized in the metrics layer ( |
|
🎉 This PR is included in version 1.12.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Preload writes went one at a time: preloadKeys waited for each Put or PutStream before issuing the next, so the configured concurrency never applied to the load phase. One deterministic producer now generates keys and values in the original order (the RNG state after preload is unchanged), a worker pool sized by the configured concurrency performs the puts, and one collector owns the accounting, the 10% failure threshold, and the spinner. The job queue is bounded so values are released as their put completes. Rebased onto main after #260: the pool carries both the plain and the CAS preload namespaces and keeps the puts-based accounting; the tests were ported onto the CAS-aware test server. The PR's commits were squashed by the rebase. Signed-off-by: Perfloop Agent <[email protected]> Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01YCoN4Him5ZY4hZovVp37ra
Preload writes went one at a time: preloadKeys waited for each Put or PutStream before issuing the next, so the configured concurrency never applied to the load phase. One deterministic producer now generates keys and values in the original order (the RNG state after preload is unchanged), a worker pool sized by the configured concurrency performs the puts, and one collector owns the accounting, the 10% failure threshold, and the spinner. The job queue is bounded so values are released as their put completes. Rebased onto main after #260: the pool carries both the plain and the CAS preload namespaces and keeps the puts-based accounting; the tests were ported onto the CAS-aware test server. The PR's commits were squashed by the rebase. Signed-off-by: Perfloop Agent <[email protected]>
Closes out PR5 of the #254 plan: CAS benchmarks, as a workload op in
ocachecli benchthat slots into the existing single-node and 3-node cluster benchmark workflows.The workload
cas=Nin a custom mix (e.g.cas=100,read=70,cas=30). Each op is one guarded read-modify-write —GetWithVersion, thenPutIfVersionagainst the version just read — the write-coordination pattern CAS exists for.Attempts / Wins / Mismatches / Mismatch Ratein a new "CAS Outcomes" section, andErrorsstays real errors only.updatekeys, keeping the benchmark inside supported semantics (mixing plain writes and CAS on one key is unsupported). Plain keys are preloaded only if the mix uses them.--mode simpleand--mode cluster.CI
Both remaining benchmark workflows gain three steps:
cas=100— the mismatch rate is the contention signal. In cluster mode this also exercises CAS forwarding and the no-retry rule for conditional writes.Verification
make vet,test-client, and both builds clean; workflow YAML parses.🤖 Generated with Claude Code
https://claude.ai/code/session_01YCoN4Him5ZY4hZovVp37ra
Note
Low Risk
Changes are limited to the benchmark CLI, CI workflow steps, and docs—no server or production client behavior changes.
Overview
Adds
cas=Ntoocachecli benchcustom workloads so benchmarks can run guarded read-modify-writes (GetWithVersion→PutIfVersion). Lost races are tracked as mismatches (with win/attempt counts and mismatch rate in output), not inErrors, viaClassifyCASResultand a dedicatedcas-key namespace preloaded with put-if-absent so CAS keys never share plain read/update keys.Single-node and 3-node cluster GitHub benchmark workflows each gain three steps: uncontended 100 B CAS baseline, contended 100 B CAS (narrow keyspace), and mixed
read=70,cas=30at 100 KB (raw-file tier). Docs and the--workloadflag help text describe the new mix; tests assert CAS accounting on an in-process gRPC mock.Reviewed by Cursor Bugbot for commit 67ec315. Bugbot is set up for automated code reviews on this repo. Configure here.