Skip to content

Auto-port 5.0: Add epoch-based chunk cache purge with ring buffer for thread-local reuse - #16918

Merged
chrisvest merged 1 commit into
5.0from
auto-port-pr-16766-to-5.0
Jun 5, 2026
Merged

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

Conversation

@netty-project-bot

Copy link
Copy Markdown
Contributor

Auto-port of #16766 to 5.0
Cherry-picked commit: ee2cb98


Motivation:

The bounded ConcurrentQueueChunkCache causes chunk malloc/free churn on low-core containers (CHUNK_REUSE_QUEUE=4 on 2 cores). Dead chunks fill the queue, pollChunk cannot find reusable ones, and new chunks are malloc'd while old ones overflow and get deallocated.

Modification:

Replace with unbounded size-classed caches and epoch-based idle chunk eviction. Thread-local cache uses an in-place ring buffer partitioned into [notEmpty | empty] zones for O(1) scanForCapacity. Shared cache uses a fixed MPMC queue sized to max(128, CHUNK_REUSE_QUEUE * 2).

Purge scan runs periodically (every 16/128 polls), ages fully-free chunks via purgeEpoch, and evicts past threshold while retaining at least CHUNK_REUSE_QUEUE chunks to match the baseline warm-cache behavior at idle.

Result:

Eliminates chunk churn on low-core machines. No regression on all-cores production path.

…euse (#16766)

Motivation:

The bounded ConcurrentQueueChunkCache causes chunk malloc/free churn on
low-core containers (CHUNK_REUSE_QUEUE=4 on 2 cores). Dead chunks fill
the queue, pollChunk cannot find reusable ones, and new chunks are
malloc'd while old ones overflow and get deallocated.

Modification:

Replace with unbounded size-classed caches and epoch-based idle chunk
eviction. Thread-local cache uses an in-place ring buffer partitioned
into [notEmpty | empty] zones for O(1) scanForCapacity. Shared cache
uses a fixed MPMC queue sized to max(128, CHUNK_REUSE_QUEUE * 2).

Purge scan runs periodically (every 16/128 polls), ages fully-free
chunks via purgeEpoch, and evicts past threshold while retaining at
least CHUNK_REUSE_QUEUE chunks to match the baseline warm-cache behavior
at idle.

Result:

Eliminates chunk churn on low-core machines. No regression on all-cores
production path.

(cherry picked from commit ee2cb98)
@chrisvest chrisvest added this to the 5.0.0.Final milestone Jun 5, 2026
@chrisvest
chrisvest merged commit 3c7e564 into 5.0 Jun 5, 2026
12 of 13 checks passed
@chrisvest
chrisvest deleted the auto-port-pr-16766-to-5.0 branch June 5, 2026 17:30
@normanmaurer normanmaurer mentioned this pull request Sep 22, 2026
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