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: Performance gap in latency/RSS in several benchmark cases compared with other allocators · Issue #17028 · netty/netty

AdaptivePoolingAllocator: Performance gap in latency/RSS in several benchmark cases compared with other allocators #17028

New issue
Copy link
New issue
Copy link
Open
#17151
Open
AdaptivePoolingAllocator: Performance gap in latency/RSS in several benchmark cases compared with other allocators#17028
#17151
Copy link

Description

@laosijikaichele
laosijikaichele
opened on Jul 1, 2026
Issue body actions

Following a recent benchmark, the AdaptivePoolingAllocator is showing performance gap in latency or RSS in several test cases compared with other allocators, the following benchmark screenshots highlight the affected cases:

Image Image Image Image

More cases on the benchmark results:
https://neoionet.github.io/netty-allocator-benchmark-report/1.1.1/benchmark.html

The env specification:
https://neoionet.github.io/netty-allocator-benchmark-report/1.1.1/specification.html

This has been briefly mentioned with @franz1981 in #16766 (comment).

Activity

  1. franz1981 commented on Jul 1, 2026

    @franz1981
    franz1981
    on Jul 1, 2026
    Contributor
    More actions

    It is regressed @laosijikaichele ?
    Can you verify if is due to the epoch changes please?

  2. laosijikaichele commented on Jul 1, 2026

    @laosijikaichele
    laosijikaichele
    on Jul 1, 2026
    ContributorAuthor
    More actions

    The regression I mentioned is relative to pooled/mimalloc.
    It should not be related to your epoch changes, as you noted earlier.
    I changed the word 'regression' to 'gap', to be more clear.
    @franz1981

    Reacted by Francesco Nigro
  3. laosijikaichele
    changed the title [-]AdaptivePoolingAllocator: Performance regression in latency/RSS in several benchmark cases[/-] [+]AdaptivePoolingAllocator: Performance gap in latency/RSS in several benchmark cases compared wit other allocators[/+] on Jul 1, 2026
  4. laosijikaichele
    changed the title [-]AdaptivePoolingAllocator: Performance gap in latency/RSS in several benchmark cases compared wit other allocators[/-] [+]AdaptivePoolingAllocator: Performance gap in latency/RSS in several benchmark cases compared with other allocators[/+] on Jul 1, 2026
  5. franz1981 commented on Jul 1, 2026

    @franz1981
    franz1981
    on Jul 1, 2026
    Contributor
    More actions

    The RSS impact can cause latency spikes so I would first make sure we have no weird allocations in the hot path.
    Do you have the instructions to run the bench on my side?

  6. laosijikaichele commented on Jul 1, 2026

    @laosijikaichele
    laosijikaichele
    on Jul 1, 2026
    ContributorAuthor
    More actions

    The benchmark code is: benchmark. (Need manually edit the netty-version to 4.2.16.Final-SNAPSHOT).

    I run it on the 16-cores server:
    java -jar benchmark/target/benchmarks.jar -wi 10 -i 10 -t 32.

    For other detailed specification(e.g. size-pattern), please check:
    https://neoionet.github.io/netty-allocator-benchmark-report/1.1.1/specification.html.
    @franz1981

  7. laosijikaichele commented on Jul 1, 2026

    @laosijikaichele
    laosijikaichele
    on Jul 1, 2026
    ContributorAuthor
    More actions

    I just noticed that the platform threads test case use:
    java -jar benchmark/target/benchmarks.jar -wi 10 -i 10 -t 32 -jvmArgs "-Djmh.executor=PLATFORM", which should be -jvmArgsAppend instead of -jvmArgs. So the platform threads case may need to re-run.
    So please only check the event loop results for now. @franz1981

  8. franz1981 commented on Jul 1, 2026

    @franz1981
    franz1981
    on Jul 1, 2026
    Contributor
    More actions

    @laosijikaichele how did you measured RSS? exactly?
    Consider that we have size classes which retain singularly (unshared) in adaptive, while both mimalloc and pooled, won't.

  9. franz1981 commented on Jul 1, 2026

    @franz1981
    franz1981
    on Jul 1, 2026
    Contributor
    More actions

    Here's the full picture on upstream 4.2 (with PR merged), event loop threads:

    Heap allocation:

      ┌──────────────┬─────────┬──────────┬────────┬───────────────────┐
      │   Pattern    │ Buffers │ ADAPTIVE │ POOLED │    Regression?    │
      ├──────────────┼─────────┼──────────┼────────┼───────────────────┤
      │ SOCKET_PROXY │ 4096    │ 91 ns    │ 315 ns │ No (3.5x faster)  │
      ├──────────────┼─────────┼──────────┼────────┼───────────────────┤
      │ SOCKET_PROXY │ 16384   │ 281 ns   │ 386 ns │ No (1.4x faster)  │
      ├──────────────┼─────────┼──────────┼────────┼───────────────────┤
      │ SOCKET_PROXY │ 32768   │ 444 ns   │ 496 ns │ No (1.1x faster)  │
      ├──────────────┼─────────┼──────────┼────────┼───────────────────┤
      │ API_GATEWAY  │ 4096    │ 234 ns   │ 189 ns │ Yes (1.2x slower) │
      ├──────────────┼─────────┼──────────┼────────┼───────────────────┤
      │ API_GATEWAY  │ 16384   │ 987 ns   │ 547 ns │ Yes (1.8x slower) │
      ├──────────────┼─────────┼──────────┼────────┼───────────────────┤
      │ API_GATEWAY  │ 32768   │ 1,215 ns │ 574 ns │ Yes (2.1x slower) │
      └──────────────┴─────────┴──────────┴────────┴───────────────────┘
    

    Direct allocation:

      ┌──────────────┬─────────┬──────────┬────────┬───────────────────┐
      │   Pattern    │ Buffers │ ADAPTIVE │ POOLED │    Regression?    │
      ├──────────────┼─────────┼──────────┼────────┼───────────────────┤
      │ SOCKET_PROXY │ 4096    │ 87 ns    │ 247 ns │ No (2.8x faster)  │
      ├──────────────┼─────────┼──────────┼────────┼───────────────────┤
      │ SOCKET_PROXY │ 16384   │ 313 ns   │ 471 ns │ No (1.5x faster)  │
      ├──────────────┼─────────┼──────────┼────────┼───────────────────┤
      │ SOCKET_PROXY │ 32768   │ 413 ns   │ 502 ns │ No (1.2x faster)  │
      ├──────────────┼─────────┼──────────┼────────┼───────────────────┤
      │ API_GATEWAY  │ 4096    │ 160 ns   │ 311 ns │ No (1.9x faster)  │
      ├──────────────┼─────────┼──────────┼────────┼───────────────────┤
      │ API_GATEWAY  │ 16384   │ 1,259 ns │ 497 ns │ Yes (2.5x slower) │
      ├──────────────┼─────────┼──────────┼────────┼───────────────────┤
      │ API_GATEWAY  │ 32768   │ 2,483 ns │ 594 ns │ Yes (4.2x slower) │
      └──────────────┴─────────┴──────────┴────────┴───────────────────┘
    

    SOCKET_PROXY is clean across the board. API_GATEWAY regresses at 16384+ buffers on both heap and direct.
    The JFR allocation profiling data show the cause:

    • BuddyChunkController.newChunkAllocation accounts for 90.6% of allocation samples. The ConcurrentSkipListChunkCache used by the buddy/large-buffer path evicts chunks when the cache exceeds CHUNK_REUSE_QUEUE, and those evicted buddy chunks (up to 8MB each) become GC garbage.
    • The API_GATEWAY pattern's ~1.6% tail of sizes > 16896 triggers this path.

    @chrisvest

  10. chrisvest commented on Jul 1, 2026

    @chrisvest
    chrisvest
    on Jul 1, 2026
    Member
    More actions

    In other words, it's chunk churn from ConcurrentSkipListChunkCache?

    Reacted by Francesco Nigro
  11. franz1981 commented on Jul 1, 2026

    @franz1981
    franz1981
    on Jul 1, 2026
    Contributor
    More actions

    @chrisvest the easier workaround would be to extend SIZE_CLASSES with 32768 and 65536 - but it doesn't seems right :)

  12. laosijikaichele commented on Jul 2, 2026

    @laosijikaichele
    laosijikaichele
    on Jul 2, 2026
    ContributorAuthor
    More actions

    @laosijikaichele how did you measured RSS? exactly?

    The RSS was measured by netdata, the code: ByteBufAllocatorAllocPatternBenchmark.
    I will re-run the test by reading /proc/self/status, to be more accurate.

  13. laosijikaichele commented on Jul 2, 2026

    @laosijikaichele
    laosijikaichele
    on Jul 2, 2026
    ContributorAuthor
    More actions

    I just noticed that the platform threads test case use: java -jar benchmark/target/benchmarks.jar -wi 10 -i 10 -t 32 -jvmArgs "-Djmh.executor=PLATFORM", which should be -jvmArgsAppend instead of -jvmArgs. So the platform threads case may need to re-run. So please only check the event loop results for now.
    ...
    I will re-run the test by reading /proc/self/status, to be more accurate.

    All benchmark cases have been re-run against the latest code using the correct JVM args:

    • Charts: https://neoionet.github.io/netty-allocator-benchmark-report/latest/benchmark.html
    • Specification: https://neoionet.github.io/netty-allocator-benchmark-report/latest/specification

    @franz1981

  14. franz1981 commented on Jul 2, 2026

    @franz1981
    franz1981
    on Jul 2, 2026
    Contributor
    More actions

    So there are two separate issues:

    1. Event loop + API_GATEWAY RSS: Buddy allocator churn I've mentioned at AdaptivePoolingAllocator: Performance gap in latency/RSS in several benchmark cases compared with other allocators #17028 (comment)
    2. Platform threads latency -> still to investigate
  15. laosijikaichele commented on Jul 2, 2026

    @laosijikaichele
    laosijikaichele
    on Jul 2, 2026
    ContributorAuthor
    More actions

    So there are two separate issues:

    1. Event loop + API_GATEWAY RSS: Buddy allocator churn I've mentioned at AdaptivePoolingAllocator: Performance gap in latency/RSS in several benchmark cases compared with other allocators #17028 (comment)
    2. Platform threads latency -> still to investigate

    Also it seems:
    3. Event loop + heap allocation + API_GATEWAY -> High RSS.
    4. Platform threads + heap allocation -> High RSS and latency.

  16. laosijikaichele commented on Jul 2, 2026

    @laosijikaichele
    laosijikaichele
    on Jul 2, 2026
    ContributorAuthor
    More actions

    The raw benchmark results are available here:
    https://github.com/neoionet/netty-allocator-benchmark-report/tree/774036212279be05edbe93314d4fcdbd70c61a0a/latest/raw

  17. franz1981 commented on Jul 2, 2026

    @franz1981
    franz1981
    on Jul 2, 2026
    Contributor
    More actions

    @laosijikaichele The changes I did has improved the SharedSizeClassedChunkCache a lot, but it seems with 32 cores is severely affected by the MpmcArrayQueue contention due to the frequent offer/poll.
    I am quickly writing a patch so you can try it out 🙏
    I will publish it once the regression due to that part is mitigated - but the one related the buddy allocator I have no solution yet.

    Reacted by old driver
  18. laosijikaichele commented on Jul 2, 2026

    @laosijikaichele
    laosijikaichele
    on Jul 2, 2026
    ContributorAuthor
    More actions

    I am quickly writing a patch so you can try it out

    Take your time — the test servers are currently unavailable, but I'll be happy to run it once they're available.

  19. franz1981 commented on Jul 2, 2026

    @franz1981
    franz1981
    on Jul 2, 2026
    Contributor
    More actions

    Ok so it is a mix of both contention on mpmc array q AND the fact that is bounded with that capacity:
    moving to an unbounded one e.g. the mpmc xadd queue (which is what the event loop case does - it's just a storage at the end) will improve by 3.4-4.5x improvement across the board

    We need to stripe the mpmc unbounded q to have both contention and retention to work right:

      ┌──────────────────────────┬─────────┬──────────┬─────────┬──────────┐
      │          Config          │ SP 4096 │ SP 32768 │ AG 4096 │ AG 32768 │
      ├──────────────────────────┼─────────┼──────────┼─────────┼──────────┤
      │ Bounded MPMC (baseline)  │ 3,120   │ 8,003    │ 4,539   │ 17,386   │
      ├──────────────────────────┼─────────┼──────────┼─────────┼──────────┤
      │ Striped bounded          │ 2,659   │ 8,679    │ 4,222   │ 18,467   │
      ├──────────────────────────┼─────────┼──────────┼─────────┼──────────┤
      │ Unbounded xadd (single)  │ 912     │ 1,941    │ 1,152   │ 3,854    │
      ├──────────────────────────┼─────────┼──────────┼─────────┼──────────┤
      │ Striped + unbounded xadd │ 512     │ 1,088    │ 789     │ 1,978    │
      ├──────────────────────────┼─────────┼──────────┼─────────┼──────────┤
      │ POOLED                   │ 228     │ 505      │ 372     │ 538      │
      └──────────────────────────┴─────────┴──────────┴─────────┴──────────┘
    
    

    SP and AG are the 2 types of tests, performed with heap buffers.

    Striped + unbounded seems decent (using log(2, num_cores) stripes) but there's till something off i.e. super high contention on the Magazine stamped lock

  20. laosijikaichele commented on Jul 2, 2026

    @laosijikaichele
    laosijikaichele
    on Jul 2, 2026
    ContributorAuthor
    More actions

    i.e. super high contention on the Magazine stamped lock

    Since the lock may be under high contention, we might need to add paddings around Magazine class, to reduce possible false sharing?

  21. franz1981 commented on Jul 2, 2026

    @franz1981
    franz1981
    on Jul 2, 2026
    Contributor
    More actions

    tried, doesn't matter. The problem is that it won't expand it seems..
    Indeed...

      ┌───────────────────────────────┬─────────┬──────────┐
      │            Config             │ SP 4096 │ SP 32768 │
      ├───────────────────────────────┼─────────┼──────────┤
      │ Striped xadd, 1 initial mag   │ 646     │ 1,210    │
      ├───────────────────────────────┼─────────┼──────────┤
      │ Striped xadd, 64 initial mags │ 250     │ 772      │
      ├───────────────────────────────┼─────────┼──────────┤
      │ POOLED                        │ 342     │ 442      │
      └───────────────────────────────┴─────────┴──────────┘
    
    

    So we need:

    1. reduce the contention on the shared mpmc with a better unbounded queue and striping them; or reduce the sharing, too
    2. find a better way to expand (maybe more aggresively)
    3. fix the buddy allocator
    Reacted by old driver
  22. franz1981 commented on Jul 2, 2026

    @franz1981
    franz1981
    on Jul 2, 2026
    Contributor
    More actions

    @laosijikaichele I haven't looked at the platform threads path for Mimalloc by a while - it is still using some stamped lock or other mechanisms to spred contention?

  23. laosijikaichele commented on Jul 2, 2026

    @laosijikaichele
    laosijikaichele
    on Jul 2, 2026
    ContributorAuthor
    More actions

    @laosijikaichele I haven't looked at the platform threads path for Mimalloc by a while - it is still using some stamped lock or other mechanisms to spred contention?

    Mimalloc use stamped lock too, but with a light weight expand mechanism by a heapsScanLength field:

    https://github.com/neoionet/netty-allocator/blob/c03b8235aa556a5a90ec2d0dca54e5be05387c98/mimalloc/src/main/java/io/github/neoionet/netty/mimalloc/MiMallocByteBufAllocator.java#L2090-L2116

    Ok so it doesn't actually expand the array but how much of such array is used, I see

    Reacted by Francesco Nigro
  24. franz1981 commented on Jul 2, 2026

    @franz1981
    franz1981
    on Jul 2, 2026
    Contributor
    More actions

    @laosijikaichele

    Ok so it doesn't actually expand the array but how much of such array is used, I see

    And it doesn't free while "widening" the usage of it , which is key @chrisvest

  25. laosijikaichele commented on Jul 2, 2026

    @laosijikaichele
    laosijikaichele
    on Jul 2, 2026
    ContributorAuthor
    More actions

    @laosijikaichele
    Ok so it doesn't actually expand the array but how much of such array is used, I see
    And it doesn't free while "widening" the usage of it

    yes

  26. franz1981 commented on Jul 3, 2026

    @franz1981
    franz1981
    on Jul 3, 2026
    Contributor
    More actions

    #17047 if you want to give it a shot 🙏 once the machine(s) are available.
    Important point, starting with INITAL MAGAZINE = 32 clearly improve things, but we should still be in much better position now.

    Reacted by old driver
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.