Skip to content

Auto-port 5.0: Fix buddy cache evicting chunks with live buffers - #17159

Merged
chrisvest merged 1 commit into
5.0from
auto-port-pr-17154-to-5.0
Jul 28, 2026
Merged

chrisvest merged 1 commit into
5.0from
auto-port-pr-17154-to-5.0

Conversation

@netty-project-bot

Copy link
Copy Markdown
Contributor

Auto-port of #17154 to 5.0
Cherry-picked commit: 34bfcc7


Motivation:

The shared ConcurrentSkipListChunkCache eviction policy picked the chunk with the lowest refCnt when the cache exceeded CHUNK_REUSE_QUEUE. Since chunks enter the cache with refCnt = 1 + N (N live buffers), evicting them creates zombie chunks: out of the cache, backing buffer still alive until all N buffers release. This caused 16 GB RSS on the AG benchmark.

Modification:

Only evict chunks where refCnt == 1 (no live buffers — just the base construction reference). If no idle chunk exists, let the cache grow past the cap. markToDeallocate on an idle chunk decrements refCnt to 0, triggering deallocate which frees the backing buffer cleanly.

Result:

Less memory churn under allocation pressure still allowing it to shrink on subsequence cache requests

Motivation:

The shared ConcurrentSkipListChunkCache eviction policy picked the chunk
with the lowest refCnt when the cache exceeded CHUNK_REUSE_QUEUE. Since
chunks enter the cache with refCnt = 1 + N (N live buffers), evicting
them creates zombie chunks: out of the cache, backing buffer still alive
until all N buffers release. This caused 16 GB RSS on the AG benchmark.

Modification:

Only evict chunks where refCnt == 1 (no live buffers — just the base
construction reference). If no idle chunk exists, let the cache grow
past the cap. markToDeallocate on an idle chunk decrements refCnt to 0,
triggering deallocate which frees the backing buffer cleanly.

Result:

Less memory churn under allocation pressure still allowing it to shrink
on subsequence cache requests

(cherry picked from commit 34bfcc7)
@testlens-app

testlens-app Bot commented Jul 28, 2026

Copy link
Copy Markdown

✅ All tests passed ✅

🏷️ Commit: 5ca0bf1
▶️ Tests: 38721 executed
⚪️ Checks: 12/12 completed


Learn more about TestLens at testlens.app.

@chrisvest chrisvest added this to the 5.0.0.Final milestone Jul 28, 2026
@chrisvest
chrisvest merged commit 40585ec into 5.0 Jul 28, 2026
13 checks passed
@chrisvest
chrisvest deleted the auto-port-pr-17154-to-5.0 branch July 28, 2026 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants