Repository navigation
Deflake COPY Preserves TTLs test under libc malloc - #4785
Conversation
The test compared MEMORY USAGE of the source hash and its COPY for exact equality. COPY builds the new object from fresh allocations while the source was grown with realloc, so with libc malloc (used by the sanitizer builds) the usable size of the allocations can differ by one 16-byte chunk in either direction, for both listpack and hashtable encodings. Assert that the encoding is preserved and that memory stays within 16 bytes, matching what the RESTORE variant of the same test already does. Fixes valkey-io#4149 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017SS5jg1cBwVxVEMzNn6J7e Signed-off-by: Roy Chen <[email protected]>
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Important Review skippedReview was skipped as selected files did not have any reviewable changes. ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe COPY TTL-preservation test now checks that the copied hash retains the source encoding. It replaces exact memory-usage equality with a comparison that allows a difference of up to 16 bytes. ChangesCOPY TTL test
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~5 minutes Severity of issue fixed: Low Suggested reviewers: Merge Risk: ⚪ Minimal · up to This test-only change addresses the reported allocator-related failure and preserves the other COPY assertions. No merge-blocking risk remains. Architecture SummaryArchitecture risk: 🔵 Low · up to The change affects 1 system. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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 |
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017SS5jg1cBwVxVEMzNn6J7e Signed-off-by: Roy Chen <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## unstable #4785 +/- ##
============================================
- Coverage 80.61% 80.61% -0.01%
============================================
Files 194 194
Lines 101189 101189
============================================
- Hits 81571 81570 -1
- Misses 19618 19619 +1 🚀 New features to boost your workflow:
|
rainsupreme
left a comment
There was a problem hiding this comment.
LGTM. Confirmed on a MALLOC=libc build: in a 20000-iteration loop of this test body, the old exact check failed 18 times (the copy was 16 bytes larger or smaller) and the new check did not fail.
One fix to the description before merge, since it becomes the commit message: the copy and source differ not because one was realloc'd, but because glibc's usable size depends on free-list state (a leftover under its 32-byte minimum chunk is handed out with the allocation).
| # With libc malloc, MEMORY USAGE of the copy can differ by an allocator chunk. | ||
| assert_equal [r OBJECT ENCODING myhash{t}] [r OBJECT ENCODING nwhash{t}] | ||
| set mem_src [r MEMORY USAGE myhash{t}] | ||
| assert_range [r MEMORY USAGE nwhash{t}] [expr {$mem_src - 16}] [expr {$mem_src + 16}] |
There was a problem hiding this comment.
nit: Is one 16-byte step the worst case for both encodings? In listpack there is one realloc'd buffer, but if hashtable encoding has several grown allocations the steps add up and +/-16 can still flake. The chances are super low though.
The test asserted exact MEMORY USAGE equality between a hash and its COPY. With libc malloc (used by the sanitizer builds), the copy's fresh allocations and the source's realloc'd ones can report usable sizes 16 bytes apart. The CI failure was 288 vs 304. The test now asserts that the encoding is preserved and that memory is within +/-16 bytes, matching the RESTORE variant of the neighbouring test. Test-only change, no behavior impact. Reproduced on a MALLOC=libc build: about 0.2% of 4000 iterations differed by +/-16 bytes, across both encodings. This PR is co-authored with Claude Opus 5.5. Fixes #4149. --------- Signed-off-by: Roy Chen <[email protected]> Backport-Source-PR: 4785
The test asserted exact MEMORY USAGE equality between a hash and its COPY. With libc malloc (used by the sanitizer builds), the copy's fresh allocations and the source's realloc'd ones can report usable sizes 16 bytes apart. The CI failure was 288 vs 304. The test now asserts that the encoding is preserved and that memory is within +/-16 bytes, matching the RESTORE variant of the neighbouring test. Test-only change, no behavior impact. Reproduced on a MALLOC=libc build: about 0.2% of 4000 iterations differed by +/-16 bytes, across both encodings. This PR is co-authored with Claude Opus 5.5. Fixes #4149. --------- Signed-off-by: Roy Chen <[email protected]> (cherry picked from commit caf5f2b)
The test asserted exact MEMORY USAGE equality between a hash and its COPY. With libc malloc (used by the sanitizer builds), the copy's fresh allocations and the source's realloc'd ones can report usable sizes 16 bytes apart. The CI failure was 288 vs 304. The test now asserts that the encoding is preserved and that memory is within +/-16 bytes, matching the RESTORE variant of the neighbouring test. Test-only change, no behavior impact. Reproduced on a MALLOC=libc build: about 0.2% of 4000 iterations differed by +/-16 bytes, across both encodings. This PR is co-authored with Claude Opus 5.5. Fixes #4149. --------- Signed-off-by: Roy Chen <[email protected]> Backport-Source-PR: 4785
The test asserted exact MEMORY USAGE equality between a hash and its COPY. With libc malloc (used by the sanitizer builds), the copy's fresh allocations and the source's realloc'd ones can report usable sizes 16 bytes apart. The CI failure was 288 vs 304. The test now asserts that the encoding is preserved and that memory is within +/-16 bytes, matching the RESTORE variant of the neighbouring test. Test-only change, no behavior impact. Reproduced on a MALLOC=libc build: about 0.2% of 4000 iterations differed by +/-16 bytes, across both encodings. This PR is co-authored with Claude Opus 5.5. Fixes #4149. --------- Signed-off-by: Roy Chen <[email protected]> (cherry picked from commit caf5f2b)
The test asserted exact MEMORY USAGE equality between a hash and its COPY. With libc malloc (used by the sanitizer builds), the copy's fresh allocations and the source's realloc'd ones can report usable sizes 16 bytes apart. The CI failure was 288 vs 304. The test now asserts that the encoding is preserved and that memory is within +/-16 bytes, matching the RESTORE variant of the neighbouring test. Test-only change, no behavior impact. Reproduced on a MALLOC=libc build: about 0.2% of 4000 iterations differed by +/-16 bytes, across both encodings. This PR is co-authored with Claude Opus 5.5. Fixes #4149. --------- Signed-off-by: Roy Chen <[email protected]> (cherry picked from commit caf5f2b)
The test asserted exact MEMORY USAGE equality between a hash and its COPY. With libc malloc (used by the sanitizer builds), the copy's fresh allocations and the source's realloc'd ones can report usable sizes 16 bytes apart. The CI failure was 288 vs 304. The test now asserts that the encoding is preserved and that memory is within +/-16 bytes, matching the RESTORE variant of the neighbouring test. Test-only change, no behavior impact. Reproduced on a MALLOC=libc build: about 0.2% of 4000 iterations differed by +/-16 bytes, across both encodings. This PR is co-authored with Claude Opus 5.5. Fixes #4149. --------- Signed-off-by: Roy Chen <[email protected]> Backport-Source-PR: 4785
The test asserted exact MEMORY USAGE equality between a hash and its COPY. With libc malloc (used by the sanitizer builds), the copy's fresh allocations and the source's realloc'd ones can report usable sizes 16 bytes apart. The CI failure was 288 vs 304. The test now asserts that the encoding is preserved and that memory is within +/-16 bytes, matching the RESTORE variant of the neighbouring test. Test-only change, no behavior impact. Reproduced on a MALLOC=libc build: about 0.2% of 4000 iterations differed by +/-16 bytes, across both encodings. This PR is co-authored with Claude Opus 5.5. Fixes #4149. --------- Signed-off-by: Roy Chen <[email protected]> Backport-Source-PR: 4785 Signed-off-by: valkeyrie-ops[bot] <284117741+valkeyrie-ops[bot]@users.noreply.github.com>
Fixes #4149.
The test asserted exact
MEMORY USAGEequality between a hash and itsCOPY. With libc malloc (used by the sanitizer builds), the copy's fresh allocations and the source's realloc'd ones can report usable sizes 16 bytes apart. The CI failure was288vs304.This matches the
RESTOREvariant of the neighbouring test: it asserts that the encoding is preserved and that memory is within ±16 bytes. It's a test-only change.Reproduced on a
MALLOC=libcbuild: about 0.2% of 4000 iterations differed by ±16 bytes, across both encodings.unit/hashexpirepasses on jemalloc and libc builds.This PR is co-authored with Claude Opus 5.5.