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 #17028Activityfranz1981 commented on Jul 1, 2026 It is regressed @laosijikaichele ?
Can you verify if is due to the epoch changes please? laosijikaichele commented 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 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, 2026changed 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, 2026franz1981 commented on Jul 1, 2026 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? laosijikaichele commented on Jul 1, 2026 ContributorAuthor More actions laosijikaichele commented 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 franz1981 commented on Jul 1, 2026 @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. franz1981 commented on Jul 1, 2026 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 chrisvest commented on Jul 1, 2026 In other words, it's chunk churn from ConcurrentSkipListChunkCache? Reacted by Francesco Nigro franz1981 commented on Jul 1, 2026 @chrisvest the easier workaround would be to extend SIZE_CLASSES with 32768 and 65536 - but it doesn't seems right :) laosijikaichele commented on Jul 2, 2026 ContributorAuthor More actions laosijikaichele commented 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:
@franz1981 franz1981 commented on Jul 2, 2026 laosijikaichele commented on Jul 2, 2026 ContributorAuthor More actions laosijikaichele commented on Jul 2, 2026 ContributorAuthor More actions franz1981 commented on Jul 2, 2026 @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. laosijikaichele commented 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. franz1981 commented on Jul 2, 2026 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
laosijikaichele commented 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? franz1981 commented on Jul 2, 2026 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:
- reduce the contention on the shared mpmc with a better unbounded queue and striping them; or reduce the sharing, too
- find a better way to expand (maybe more aggresively)
- fix the buddy allocator
franz1981 commented on Jul 2, 2026 @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? laosijikaichele commented on Jul 2, 2026 ContributorAuthor More actions Reacted by Francesco Nigro franz1981 commented on Jul 2, 2026 @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 laosijikaichele commented 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 franz1981 commented on Jul 3, 2026 #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.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|