Dismiss dict bucket arrays in fork child to reduce CoW#14979
Merged
ShooterIT merged 3 commits intoredis:unstablefrom Apr 15, 2026
Merged
Dismiss dict bucket arrays in fork child to reduce CoW#14979ShooterIT merged 3 commits intoredis:unstablefrom
ShooterIT merged 3 commits intoredis:unstablefrom
Conversation
🤖 Augment PR SummarySummary: Reduces fork-time CoW during RDB saves and AOF rewrites by extending the fork-child “dismiss” mechanism to also drop dict bucket arrays.
🤖 Was this summary useful? React with 👍 or 👎 |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
Reviewed by Cursor Bugbot for commit eaa4c3e. Configure here.
Member
Author
|
in cluster mode, benchmark uses the following command, all keys will be changed during benchmarking before now this PR can reduce about 700 MB CoW memory. |
tezc
reviewed
Apr 13, 2026
tezc
approved these changes
Apr 14, 2026
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.

During RDB saving and AOF rewriting, the fork child already dismisses
(madvise(MADV_DONTNEED)) individual key-value objects after serializing them.
However, the hash table bucket arrays of each dict were never dismissed,
leaving large contiguous allocations subject to CoW when the parent modifies them.
This PR extends the dismiss mechanism to cover dict bucket arrays, reducing CoW
memory overhead.
child never accesses expires directly, after embeding expire time in the
key object.
to the next slot during RDB saving or AOF rewriting.
fully serialized during RDB saving or AOF rewriting.
Note
Medium Risk
Changes fork-child memory dismissal behavior during RDB save and AOF rewrite to proactively madvise dict bucket arrays and to skip dismissing small serialized objects; mistakes here could impact snapshot/rewrite stability or CoW memory characteristics under load.
Overview
Reduces fork-time copy-on-write memory overhead by extending the child-process dismiss mechanism to include dict hash table bucket arrays, not just individual key/value objects.
During RDB saves and AOF rewrites, the child now dismisses key-space bucket arrays per-slot in cluster mode (as iteration moves to a new slot) and per-DB in standalone mode (after a DB is fully serialized). It also dismisses
expireskvstore bucket arrays up-front for RDB/AOF children since they’re not read during serialization.Additionally,
dismissObject()calls during RDB/AOF serialization are now gated to only run for large serialized payloads (dump_size > server.page_size/2), and the integration test suite is expanded to cover both AOF rewrite paths (with/without RDB preamble) plus new standalone multi-DB and cluster slot bucket dismissal scenarios.Reviewed by Cursor Bugbot for commit a2a37ad. Bugbot is set up for automated code reviews on this repo. Configure here.