Repository navigation
perf(storage): avoid duplicate member reads in ZRANK - #447
Merged
Merged
Conversation
Pass the completed member lookup from partial-read lock planning into rank projection, including confirmed misses. The member S hold protects that result through ordered-group waits; compute the final rank using the common directory captured after acquiring those groups. Skip the redundant member-page read, scan and temporary input map. Add a physical-I/O regression for ZRANK and ZREVRANK hits and misses. Validation: Debug build; 20 focused unit tests; 7 grouped zset E2E tests; formatting and git diff --check.
|
Caution Review failedThe pull request is closed.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
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.
Context
#435 made ZRANK and ZREVRANK read the member score during group-lock planning, then load and scan the same member leaf again during rank projection.
Behavior before and after
Reuse the completed lookup, including a confirmed miss, while retaining the member-group S lock. Rank still uses the common directory captured after acquiring the ordered-group holds, so concurrent changes to unrelated prefix counts remain consistent.
Implementation
Pass the protected lookup into the existing executor and skip the redundant member read, scan and temporary input map. Add a cold-read regression covering forward/reverse ranks, hits and misses.
Design decisions and alternatives
Reuse only the score or absence protected by the member hold. Whole-key fallback performs a fresh lookup after releasing the partial locks.
Documentation and comments
Documented the borrowed lookup's lifetime and protection, and why rank uses the final directory. The existing architecture invariants remain accurate; no architecture or format changes are needed.
Test plan
Exact validation commands
Risk assessment
The reused lookup must remain protected through ordered-lock waits and projection. The caller owns its storage and member hold until the awaited executor finishes; existing concurrent-read regressions cover the common-directory boundary.
Rollback plan
Revert this commit; no data migration is required.
Reviewer guide
Review the lookup handoff in
TryConcurrentSortedSetPageRead, its use inExecuteGroupedSortedSetLocked, andRanksReadEachRequiredPayloadOnce.Follow-up work
Rerun the original ZSET throughput comparisons to quantify the recovered performance.