GeezerVison is showing github.com — AdaptivePoolingAllocator: logic in method `shouldReleaseSuboptimalChunkSuze(...)` differs from the doc · Issue #15010 · netty/netty
AdaptivePoolingAllocator: logic in method shouldReleaseSuboptimalChunkSuze(...) differs from the doc #15010
Description
According from the docs and #14781 description, the probability of a chunk being released depends on how many MIN_CHUNK_SIZE units the chunk deviate from the preferred chunk size, the more it deviated, the more probability it will be released.
But the actual logic in shouldReleaseSuboptimalChunkSuze(...) is doing the opposite:
|
private static boolean shouldReleaseSuboptimalChunkSuze(int givenSize, int preferredSize) { |
|
int givenChunks = givenSize / MIN_CHUNK_SIZE; |
|
int preferredChunks = preferredSize / MIN_CHUNK_SIZE; |
|
int deviation = Math.abs(givenChunks - preferredChunks); |
|
|
|
// Retire chunks with a 0.5% probability per unit of MIN_CHUNK_SIZE deviation from preference. |
|
return deviation != 0 && |
|
ThreadLocalRandom.current().nextDouble() * 200.0 > deviation; |
|
} |
Which means the actual code is doing: The more the chunk deviated, the LESS probability it will be released, if I read the code correctly.
Activity
franz1981 commented on Apr 8, 2025
It should be probably
return deviation != 0 &&
ThreadLocalRandom.current().nextDouble() < deviation * 0.005;
Or just the same as what's now but with <
chrisvest commented on Apr 8, 2025
Yeah, I think you're right. I made PRs for 4.1 and 4.2.
laosijikaichele commented on Apr 9, 2025
ContributorAuthor
More actions
Another point, based on the description from #14781:
so chunks that are off by 2.6 MiB or more are guaranteed to be released.
But the actual code is doing: chunks that are off by more than 25 MiB are guaranteed to be released.
So which threshold value we indeed want to use? 2.5 MiB or 25 MiB?
chrisvest commented on Apr 14, 2025
Yeah, looks like I got the math wrong there. Let's adjust it down, because the 25 MiB limit feels too big.
Metadata
Metadata
Development
No branches or pull requestsIssue actions