Repository navigation
hashtable: fix dismissHashtable madvise size - #3533
Merged
Merged
Conversation
Signed-off-by: DaeMyung Kang <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## unstable #3533 +/- ##
============================================
+ Coverage 76.40% 76.45% +0.05%
============================================
Files 159 159
Lines 79851 79851
============================================
+ Hits 61008 61049 +41
+ Misses 18843 18802 -41
🚀 New features to boost your workflow:
|
sarthakaggarwal97
pushed a commit
to sarthakaggarwal97/valkey
that referenced
this pull request
Apr 27, 2026
The bug was in dismissHashtable(), which computes the size passed to zmadvise_dontneed() for the top-level hashtable tables. ht->tables[i] points to a contiguous array of bucket objects, but the code used sizeof(bucket *) instead of sizeof(bucket) when calculating the length. That means it treated the allocation like an array of pointers rather than an array of buckets. As a result, the advised range was much smaller than the actual table allocation. On 64-bit builds, bucket is 64 bytes while bucket * is 8 bytes, so only about one eighth of the table was covered. This does not usually break correctness, but it defeats the purpose of the function: after a fork, we want to tell the kernel that the hashtable pages are no longer needed so we reduce copy-on-write overhead. With the wrong size, most of the table memory was never included in that hint. The fix is to use sizeof(bucket) so the full top-level bucket array is passed to zmadvise_dontneed(). Signed-off-by: DaeMyung Kang <[email protected]>
sarthakaggarwal97
added a commit
to sarthakaggarwal97/valkey
that referenced
this pull request
Apr 27, 2026
…-io#3533, valkey-io#3557, valkey-io#3548, valkey-io#3554, valkey-io#3503) Signed-off-by: Sarthak Aggarwal <[email protected]>
madolson
pushed a commit
that referenced
this pull request
Apr 27, 2026
The bug was in dismissHashtable(), which computes the size passed to zmadvise_dontneed() for the top-level hashtable tables. ht->tables[i] points to a contiguous array of bucket objects, but the code used sizeof(bucket *) instead of sizeof(bucket) when calculating the length. That means it treated the allocation like an array of pointers rather than an array of buckets. As a result, the advised range was much smaller than the actual table allocation. On 64-bit builds, bucket is 64 bytes while bucket * is 8 bytes, so only about one eighth of the table was covered. This does not usually break correctness, but it defeats the purpose of the function: after a fork, we want to tell the kernel that the hashtable pages are no longer needed so we reduce copy-on-write overhead. With the wrong size, most of the table memory was never included in that hint. The fix is to use sizeof(bucket) so the full top-level bucket array is passed to zmadvise_dontneed(). Signed-off-by: DaeMyung Kang <[email protected]>
sarthakaggarwal97
added a commit
to sarthakaggarwal97/valkey
that referenced
this pull request
Apr 28, 2026
…key-io#3359, valkey-io#3533, valkey-io#3557) Signed-off-by: Sarthak Aggarwal <[email protected]>
sarthakaggarwal97
added a commit
that referenced
this pull request
Sep 16, 2026
Move the sorted set B+ tree note (#4359) to Behavior Changes: OBJECT ENCODING now reports btree instead of skiplist, which is a client-visible output change and matters more for upgrade decisions than the speedup. Drop the notes for #3366 and #3791, neither of which is user-facing. #3366 replaces dict with a wrapper around hashtable; scoping the configured hash seed to data hashtables keeps hash-seed doing exactly what valkey.conf documents it to do, and stops the seed leaking into internal tables already populated during startup. #3791 makes the ranged memory-release helper a no-op on non-jemalloc builds to match existing behavior. Add two changes that triage left out: - #3533 fixed an undersized madvise range in dismissHashtable, so only about an eighth of the bucket array was hinted after fork. The fix cuts real copy-on-write overhead during background saves. - #4566 logs the module version on load, which is operator-visible. Signed-off-by: Sarthak Aggarwal <[email protected]> (cherry picked from commit 097567a)
sarthakaggarwal97
added a commit
that referenced
this pull request
Sep 16, 2026
Remove three entries whose changes shipped before 9.2.0, so 9.1 users don't see them advertised as new: - #3533 (dismissHashtable madvise size) was backported to 9.1 and is in the 9.1.0, 9.1.1 and 9.1.2 tags. It was added here by mistake. - #3551 (hashtable iterator invalidate on exhaustion) is likewise in 9.1.0; it just never made the 9.1 notes. - #3586 (valkey-cli --cluster fix slot spreading) is already documented in both the 9.0 and 9.1 release notes and shipped in 9.0.6 and 9.1.0. Fix the #4076 config name: the registered config is priority-preemptive-poll-interval-us, not preemptive-poll-interval-us, so the name as written would be rejected by CONFIG SET. Rewrite the #4005 entry, which described only the internal tagging. The user-facing surface is two new configs, priority-subnets and maxclients-reserved, which together cap normal clients at maxclients minus the reserved count so administrative clients keep guaranteed slots, plus a connected_priority_clients field in INFO clients. Move the sorted set B+ tree note (#4359) back to Performance. Listing it as a behavior change for its OBJECT ENCODING output while #3212 changes hash encoding output from hashtable to listpack in the Performance section was inconsistent; both now sit together. Drop the Redis comparison from the #4629 entry, which no other entry in the 9.0, 9.1 or 9.2 notes makes. Signed-off-by: Sarthak Aggarwal <[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.
The bug was in dismissHashtable(), which computes the size passed to zmadvise_dontneed() for the top-level hashtable
tables.
ht->tables[i] points to a contiguous array of bucket objects, but the code used sizeof(bucket *) instead of
sizeof(bucket) when calculating the length. That means it treated the allocation like an array of pointers rather than an
array of buckets.
As a result, the advised range was much smaller than the actual table allocation. On 64-bit builds, bucket is 64 bytes
while bucket * is 8 bytes, so only about one eighth of the table was covered. This does not usually break correctness,
but it defeats the purpose of the function: after a fork, we want to tell the kernel that the hashtable pages are no
longer needed so we reduce copy-on-write overhead. With the wrong size, most of the table memory was never included in
that hint.
The fix is to use sizeof(bucket) so the full top-level bucket array is passed to zmadvise_dontneed().