Backport: Optimize RDB load performance and fix cluster mode resizing on replica side (#1199)#1328
Merged
zuiderkwast merged 1 commit intovalkey-io:8.0from Apr 15, 2025
Merged
Conversation
…a side (valkey-io#1199) This PR addresses two issues: 1. Performance Degradation Fix - Resolves a significant performance issue during RDB load on replica nodes. - The problem was causing replicas to rehash multiple times during the load process. Local testing demonstrated up to 50% degradation in BGSAVE time. - The problem occurs when the replica tries to expand pre-created slot dictionaries. This operation fails quietly, resulting in undetected performance issues. - This fix aims to optimize the RDB load process and restore expected performance levels. 2. Bug fix when reading `RDB_OPCODE_RESIZEDB` in Valkey 8.0 cluster mode- - Use the shard's master slots count when processing this opcode, as `clusterNodeCoversSlot` is not initialized for the currently syncing replica. - Previously, this problem went unnoticed because `RDB_OPCODE_RESIZEDB` had no practical impact (due to 1). These improvements will enhance overall system performance and ensure smoother upgrades to Valkey 8.0 in the future. Testing: - Conducted local tests to verify the performance improvement during RDB load. - Verified that ignoring `RDB_OPCODE_RESIZEDB` does not negatively impact functionality in the current version. Signed-off-by: naglera <[email protected]> Co-authored-by: Binbin <[email protected]> (cherry picked from commit c5012cc) Signed-off-by: naglera <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 8.0 #1328 +/- ##
==========================================
- Coverage 70.66% 70.62% -0.04%
==========================================
Files 114 114
Lines 61681 62951 +1270
==========================================
+ Hits 43585 44458 +873
- Misses 18096 18493 +397
🚀 New features to boost your workflow:
|
xbasel
approved these changes
Nov 21, 2024
zuiderkwast
approved these changes
Apr 15, 2025
enjoy-binbin
added a commit
to enjoy-binbin/valkey
that referenced
this pull request
Aug 11, 2025
…e the hashtable
If we want to expand kvstoreHashtableExpand, we need to make sure the
hashtable exists. Currently, when processing RDB slot-info, our expand
has no effect because the hashtable does not exist (we initialize it only
when we need it).
```
if (server.cluster_enabled) {
/* In cluster mode we resize individual slot specific dictionaries based on the number of keys that
* slot holds. */
kvstoreHashtableExpand(db->keys, slot_id, slot_size);
kvstoreHashtableExpand(db->expires, slot_id, expires_slot_size);
should_expand_db = 0;
}
```
We also update kvstoreExpand to use the kvstoreHashtableExpand to make
sure there is only one code path. Also see valkey-io#1328 for more details.
Signed-off-by: Binbin <[email protected]>
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.
This PR addresses two issues:
RDB_OPCODE_RESIZEDBin Valkey 8.0 cluster mode-clusterNodeCoversSlotis not initialized for the currently syncing replica.RDB_OPCODE_RESIZEDBhad no practical impact (due to 1).These improvements will enhance overall system performance and ensure smoother upgrades to Valkey 8.0 in the future.
Testing:
RDB_OPCODE_RESIZEDBdoes not negatively impact functionality in the current version.(cherry picked from commit c5012cc)