AdaptivePoolingAllocator: assign a more explicit value to BuddyChunk.freeListCapacity#16334
Merged
Merged
Conversation
Member
|
The |
Member
|
In other words, the existing code should be correct. |
chrisvest
requested changes
Feb 23, 2026
chrisvest
left a comment
Member
There was a problem hiding this comment.
Actually the difference is just 1, and as you say the queue will call MathUtil.safeFindNextPositivePowerOfTwo to bump it by one.
We can remove the tree variable entirely and inline capFactor. That would be a better cleanup to do.
chrisvest
approved these changes
Feb 25, 2026
Contributor
|
Could not create auto-port PR. |
chrisvest
pushed a commit
to chrisvest/netty
that referenced
this pull request
Feb 25, 2026
…freeListCapacity (netty#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)
Member
|
Backport PR for 4.1: #16368 |
netty-project-bot
pushed a commit
that referenced
this pull request
Feb 25, 2026
…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)
Contributor
|
Auto-port PR for 5.0: #16369 |
chrisvest
added a commit
that referenced
this pull request
Feb 26, 2026
… to BuddyChunk.freeListCapacity (#16369) 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. Co-authored-by: old driver <29225782+laosijikaichele@users.noreply.github.com> Co-authored-by: Chris Vest <christianvest_hansen@apple.com>
chrisvest
added a commit
that referenced
this pull request
Feb 26, 2026
…freeListCapacity (#16334) (#16368) 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) Co-authored-by: old driver <29225782+laosijikaichele@users.noreply.github.com>
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.
Motivation:
Currently, the value of
BuddyChunk.freeListCapacityis less than the real max size of thefreeList.freeList.drain(freeListCapacity, this)can not drain all the elements at once.MpscIntQueue.create(freeListCapacity, -1), we rely onMpscIntQueueimplicitly callingMathUtil.safeFindNextPositivePowerOfTwo(freeListCapacity)to set the proper max size. This makes the code less explicit.freeListCapacityshould be equal to the value ofcapFactor, if I understand correctly.freeListCapacity = capFactoreliminates a bit-shift operation.Modification:
Use
freeListCapacity = capFactor;instead offreeListCapacity = tree >> 1;.Result:
More clean code.