Repository navigation
perf(storage): release worker store state during grouped String and Stream preparation - #340
Merged
thweetkomputer merged 2 commits intoOct 15, 2026
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 39 minutes. View limit details
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. Comment |
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
Grouped String segment operations and typed Stream writes hold the worker's store-state mutex while reading pages and preparing private changes. A cold page read or a large range/trim can therefore delay unrelated keys on that worker even though per-key intent already serializes conflicting commands.
Behavior before and after
Existing grouped String SETRANGE/APPEND/SETBIT and typed Stream mutations now release store state during page reads and private planning. GETRANGE/GETBIT also read their immutable grouped view outside store state. Unrelated keys can proceed while the target key remains serialized, including under retained EXEC/Lua intents. Large synchronous preparation yields cooperatively; ordinary single-page String edits and small Stream appends do not gain a yield per page.
Implementation
0f7b4c0730d515422531528ecacb65457afdd939from perf(net): add opt-in buffered stream reads bycorf#15.Design decisions and alternatives
This uses the existing unlocked preparation model for Hash/Set/List/Sorted Set instead of adding a new lock. It shortens the store-state critical section without weakening same-key or transaction ordering. Encoding/publication and small compact-demotion work may still require store state; this is not a claim that every String/Stream operation is lock-free.
Documentation and comments
Updated the storage, grouped collection and Stream architecture claims to include these preparation paths. Nearby comments explain retained ownership, no-op validation, reservation lifetime and cooperative work budgets.
Test plan
The 43-case local validation below used GCC 13 Debug on ARM64 and Bycorf
8caaf75cb131b591922af51a19861f92e2ffc893through a local source override:All 43 selected cases passed without skips: 10 String, 12 new Stream concurrency/semantics/failure, and 21 existing Stream cases. Coverage includes single-worker unrelated-key progress with same-key serialization, EXEC/Lua, TTL/WATCH/no-ops, failed preparation, recovery with three workers, a Stream above 512 MiB, and nine String/Stream crash windows. The isolated EXEC test was also rerun after adding missing array-reply decoding to the test client.
The final Bycorf pin is upstream merge commit
0f7b4c0730d515422531528ecacb65457afdd939. Its source tree is identical to tested PR headc4ec8208a15279e9484a07f74bdec51cfe8e6b5f(both tree IDs ared2a27871d788aeaf6ff8f089ce650d5bf66e1976;git diffis empty). That runtime passed all five local checks and all eight upstream CI test configurations plus formatting. This PR CI is rerunning to validate the final integration.The unrelated large Stream RDB roundtrip was excluded from this targeted run. The full compatibility suite and original performance workload have not been run here.
Risk assessment
The main risks are retaining borrowed index state across suspension, releasing memory admission before publication, or changing no-op/error behavior. The implementation owns retained metadata and plans, validates after reacquisition, and tests same-key serialization alongside unrelated-key progress, TTL/WATCH, EXEC/Lua, preparation failure and recovery.
Rollback plan
Revert this PR. No storage migration is required.
Reviewer guide
Start with String's segment preparation and the typed Stream dispatch in compact_api.cpp, then review Stream plan admission transfer and the deterministic concurrency/failure tests. This PR is based on main after #338 and is independent of #339, so the lock change can be benchmarked separately.
Follow-up work
Rerun the original 80-connection large-value benchmark, especially SETRANGE and XADD with exact MAXLEN trimming. Functional concurrency checks demonstrate removal of the lock obstruction; they do not establish an end-to-end throughput or p99.9 improvement.