GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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

New issue
Copy link
New issue
Copy link
Closed
#15015
Closed
AdaptivePoolingAllocator: logic in method shouldReleaseSuboptimalChunkSuze(...) differs from the doc#15010
#15015
Copy link

Description

@laosijikaichele
laosijikaichele
opened on Apr 8, 2025
Issue body actions

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:

netty/buffer/src/main/java/io/netty/buffer/AdaptivePoolingAllocator.java

Lines 931 to 939 in 620794f

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

  1. franz1981 commented on Apr 8, 2025

    @franz1981
    franz1981
    on Apr 8, 2025
    Contributor
    More actions

    It should be probably

    return deviation != 0 &&
                ThreadLocalRandom.current().nextDouble() < deviation * 0.005;

    Or just the same as what's now but with <

    Reacted by old driver
  2. chrisvest
    added 2 commits that reference this issue on Apr 8, 2025

    Correct computation for suboptimal chunk retirement probability

    6c11a77

    Correct computation for suboptimal chunk retirement probability

    a85a4fa
  3. chrisvest commented on Apr 8, 2025

    @chrisvest
    chrisvest
    on Apr 8, 2025
    Member
    More actions

    Yeah, I think you're right. I made PRs for 4.1 and 4.2.

    Reacted by old driver
  4. laosijikaichele commented on Apr 9, 2025

    @laosijikaichele
    laosijikaichele
    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?

  5. chrisvest commented on Apr 14, 2025

    @chrisvest
    chrisvest
    on Apr 14, 2025
    Member
    More actions

    Yeah, looks like I got the math wrong there. Let's adjust it down, because the 25 MiB limit feels too big.

    Reacted by old driver
  6. normanmaurer
    closed this as completedin #15015on Apr 15, 2025
  7. normanmaurer
    added 2 commits that reference this issue on Apr 15, 2025

    Correct computation for suboptimal chunk retirement probability (#15015)

    8a55fd9

    Correct computation for suboptimal chunk retirement probability (#15014)

    bdfa701
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.