Skip to content

Auto-port 5.0: AdaptivePoolingAllocator: assign a more explicit value to BuddyChunk.freeListCapacity#16369

Merged
chrisvest merged 1 commit into
5.0from
auto-port-pr-16334-to-5.0
Feb 26, 2026
Merged

Auto-port 5.0: AdaptivePoolingAllocator: assign a more explicit value to BuddyChunk.freeListCapacity#16369
chrisvest merged 1 commit into
5.0from
auto-port-pr-16334-to-5.0

Conversation

@netty-project-bot

Copy link
Copy Markdown
Contributor

Auto-port of #16334 to 5.0
Cherry-picked commit: b7ec449


Motivation:

Currently, the value of BuddyChunk.freeListCapacity is less than the real max size of the freeList.

  1. It may lead to the freeList.drain(freeListCapacity, this) can not drain all the elements at once.
  2. When calling MpscIntQueue.create(freeListCapacity, -1), we rely on MpscIntQueue implicitly calling MathUtil.safeFindNextPositivePowerOfTwo(freeListCapacity) to set the proper max size. This makes the code less explicit.
  3. Semantically, freeListCapacity should be equal to the value of capFactor, if I understand correctly.
  4. In addition, use freeListCapacity = capFactor eliminates a bit-shift operation.

Modification:

Use freeListCapacity = capFactor; instead of freeListCapacity = tree >> 1;.

Result:

More clean code.

…freeListCapacity (#16334)

Motivation:

Currently, the value of `BuddyChunk.freeListCapacity` is less than the
real max size of the `freeList`.
1. It may lead to the `freeList.drain(freeListCapacity, this)` can not
drain all the elements at once.
2. When calling `MpscIntQueue.create(freeListCapacity, -1)`, we rely on
`MpscIntQueue` implicitly calling
`MathUtil.safeFindNextPositivePowerOfTwo(freeListCapacity)` to set the
proper max size. This makes the code less explicit.
3. Semantically, `freeListCapacity` should be equal to the value of
`capFactor`, if I understand correctly.
4. In addition, use `freeListCapacity = capFactor` eliminates a
bit-shift operation.

Modification:

Use `freeListCapacity = capFactor;` instead of `freeListCapacity = tree
>> 1;`.

Result:

More clean code.

---------

Co-authored-by: lao <none>
Co-authored-by: Chris Vest <christianvest_hansen@apple.com>
(cherry picked from commit b7ec449)
@chrisvest chrisvest added this to the 5.0.0.Final milestone Feb 25, 2026
@chrisvest chrisvest enabled auto-merge (squash) February 25, 2026 23:05
@chrisvest chrisvest merged commit 20764fa into 5.0 Feb 26, 2026
13 checks passed
@chrisvest chrisvest deleted the auto-port-pr-16334-to-5.0 branch February 26, 2026 03:22
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