Skip to content

ByteBufAllocatorAllocPatternBenchmark: Ensure each index appears exactly once in releaseIndexes#16604

Merged
normanmaurer merged 1 commit into
netty:4.2from
laosijikaichele:4.2-shuffle
Apr 21, 2026
Merged

ByteBufAllocatorAllocPatternBenchmark: Ensure each index appears exactly once in releaseIndexes#16604
normanmaurer merged 1 commit into
netty:4.2from
laosijikaichele:4.2-shuffle

Conversation

@laosijikaichele

@laosijikaichele laosijikaichele commented Apr 5, 2026

Copy link
Copy Markdown
Contributor

Motivation:

In ByteBufAllocatorAllocPatternBenchmark, the original random sampling allowed the same index to be selected multiple times, making live buffer count unpredictable and causing MAX_LIVE_BUFFERS to lose its intended meaning.

Modification:

Use Fisher-Yates shuffle for releaseIndexes.

Result:

Live buffer count is stable at MAX_LIVE_BUFFERS, each index appears exactly once in releaseIndexes.

@franz1981 franz1981 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch! Well done!

@normanmaurer normanmaurer added this to the 4.2.13.Final milestone Apr 21, 2026
@normanmaurer normanmaurer added needs-cherry-pick-4.1 This PR should be cherry-picked to 4.1 once merged. needs-cherry-pick-5.0 This PR should be cherry-picked to 5.0 once merged. labels Apr 21, 2026
@normanmaurer normanmaurer merged commit 61d3c4a into netty:4.2 Apr 21, 2026
18 of 19 checks passed
@netty-project-bot

Copy link
Copy Markdown
Contributor

Auto-port PR for 5.0: #16678

@netty-project-bot

Copy link
Copy Markdown
Contributor

Could not create auto-port PR.
Got conflicts when cherry-picking onto 4.1.

@github-actions github-actions Bot removed the needs-cherry-pick-5.0 This PR should be cherry-picked to 5.0 once merged. label Apr 21, 2026
@chrisvest chrisvest removed the needs-cherry-pick-4.1 This PR should be cherry-picked to 4.1 once merged. label Apr 21, 2026
@chrisvest

Copy link
Copy Markdown
Member

No backport needed. This benchmark does not exist in 4.1.

chrisvest pushed a commit that referenced this pull request Apr 22, 2026
…ex appears exactly once in releaseIndexes (#16678)

Auto-port of #16604 to 5.0
Cherry-picked commit: 61d3c4a

---
Motivation:

In `ByteBufAllocatorAllocPatternBenchmark`, the original random sampling
allowed the same index to be selected multiple times, making live buffer
count unpredictable and causing `MAX_LIVE_BUFFERS` to lose its intended
meaning.

Modification:

Use
[Fisher-Yates](https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle)
shuffle for releaseIndexes.

Result:

Live buffer count is stable at `MAX_LIVE_BUFFERS`, each index appears
exactly once in releaseIndexes.

Co-authored-by: old driver <29225782+laosijikaichele@users.noreply.github.com>
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.

5 participants