Repository navigation
perf: reuse dense sorted-set pages during point mutations - #356
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
WalkthroughPoint writes to grouped sorted sets can retain qualifying probed pages during work admission. If the optional reservation fails, the code clears those pages and retries through the ordinary budget path. End-to-end tests cover planner reads, reservation failures, index consistency, and recovery. ChangesSorted-Set Probe Retention
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Refactor Merge Risk: ⚪ Minimal · up to
|
Context
Dense Sorted Set pages can be read and decoded twice by a single-member ZADD, ZINCRBY or ZREM. The optional probe cache compares its 64 KiB retention limit with admitted decoder scratch, so an ordinary 8 KiB page containing many short members is discarded before mutation planning reuses it.
Behavior before and after
Point mutations retain up to two ordinary ordered pages through planning, avoiding the repeated source/destination read. Memory pressure drops this optional retention and retries the ordinary path. Full scratch accounting and command behavior are preserved.
Implementation
Design decisions and alternatives
Reuse is command-local. Batch operations, externally supplied probes and oversized pages retain their existing policy. This introduces no shared cache or mutex.
Documentation and comments
Ownership, bounds and fallback behavior are documented beside the implementation. No architecture claim or durable format changes.
Test plan
Ran against the unmodified implementation with the new tests: both dense-page regressions failed at the expected injected second plan read. With this change:
build-test/lavik_grouped_ordered_write_e2e_test build-test/lavik \ --gtest_filter='GroupedSortedSetWriteE2e.*-GroupedSortedSetWriteE2e.AggregateAbove512MiBRemainsBoundedAndRecovers'30 tests passed, including all three new regressions, dual-index consistency and clean restart checks. GCC 13 Release/SPDK build, clang-format 23.1.1 and
git diff --checkpassed.One cross-check against base
9c68079, using the same persistent dataset: 8,192 ZSets, 32,768 members of 32 B per key, 80 connections, 90-second warmup and 60-second measurement per point.All requests succeeded; command counts and the checkpoint/state chain reconcile. CPU occupancy was approximately unchanged. The paired workload improvement came from ZREM; ZADD mean latency increased from 1.628 to 1.733 ms. These are one-run observations in fixed base→candidate order on an evolving dataset.
Risk assessment
Optional retention increases the live scratch of point edits. The page/count bounds and admission fallback constrain it; corruption checks and full memory charges remain in place. Runtime probe-hit and device-I/O reductions were not separately measured.
Rollback plan
Revert this commit; no migration or data-format change is required.
Reviewer guide
Start with the point-write retention and
reserve_worklogic inzset.cpp, then the three dense-page regressions inzset_write_e2e_test.cpp.Follow-up work
Reduce redundant ordered-page validation and remove whole-page sorting/decoding for eligible single-member insertions in a follow-up branch.
Summary by CodeRabbit