GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||
GeezerVison is showing github.com — Remove reference counting from size classed chunks by franz1981 · Pull Request #16306 · netty/netty Conversation
Contributor
Motivation: SizeClassedChunk performs 2 atomic ops (retain/release) per allocation cycle on the hot path. Modification: Replace ref counting with a segment-count state machine that only needs atomics on the cold deallocation path. Result: No more per-allocation atomic operations for SizeClassedChunk.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
Author
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
|
There was an error while loading. Please reload this page.
|
FYI @laosijikaichele this should deliver quite a decent boost 🗡️ @chrisvest sadly I have left the ref cnt to still be allocated per chunk, due to other optimizations, but it shouldn't be used |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
This is ready to go @normanmaurer in term of perf numbers I have already performed tests a lot for other prs on this, and the numbers were showing 1.5X or 2.X better perf for the thread local allocations |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
0eefff6 to
842abd9
Compare
|
@laosijikaichele I will check if using your perf test on mimalloc, but sadly we don't have the same HW so I will likely get some different numbers 😢 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@franz1981 great work, no worries about the hardware, we can mainly compare the number change on |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
e5751d6 to
21f7420
Compare
|
PTAL @normanmaurer I have simplified the capacity method to make it inlineable, but TBH it's the logic there which concern me, since mpsc::size is not "trivial" (is a loop!) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@laosijikaichele I was wrong, it seems to improve, on my x86 by a mere ~7-8% atm, maybe you will have better luck with aarch64? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
When i see things like these my heart is bleeding 😢 0.10% 0x00007f1ddc2103cb: jg 0x00007f1ddc21118c ;*if_icmpgt {reexecute=0 rethrow=0 return_oop=0} ; - io.netty.buffer.AdaptivePoolingAllocator::allocate@7 (line 260) 0x00007f1ddc2103d1: lea 0x1f(%rdx),%r8d 4.09% 0x00007f1ddc2103d5: sar $0x5,%r8d ;*ishr {reexecute=0 rethrow=0 return_oop=0} ; - io.netty.buffer.AdaptivePoolingAllocator::sizeIndexOf@5 (line 282) ; - io.netty.buffer.AdaptivePoolingAllocator::sizeClassIndexOf@1 (line 286) ; - io.netty.buffer.AdaptivePoolingAllocator::allocate@11 (line 261) I know that is a data dep but, c'mon...on Intel this the lea is faster... |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
dfb6661 to
674ce6b
Compare
|
@laosijikaichele i would be curious how the numbers now look vs mimalloc to understand the gap left (assuming proper sized chunk q 😢) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
One nit but overall this looks good.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
674ce6b to
81de40e
Compare
There was an error while loading. Please reload this page.
|
Results on my machine and thread local one Not wow, but not terrible. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
d0afc55 to
d921c93
Compare
|
And the other hidden performance benefit is that we now have scalable allocate/release from different threads - because it will scale as much as the underlying mpsc queue, while before it was "limited" by the shared "chunk" ref cnt. It's a pathological case, but still, worth mentioning. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
PTAL @normanmaurer if you're happy with the first numbers at #16306 (comment) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Motivation: SizeClassedChunk performs 2 atomic ops (retain/release) per allocation cycle on the hot path. Modification: Replace ref counting with a segment-count state machine that only needs atomics on the cold deallocation path. Result: No more per-allocation atomic operations for SizeClassedChunk.
…tivePoolingAllocator
… and capacity checks
6c181fb to
dec518f
Compare
|
PTAL @normanmaurer |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@chrisvest done bud ! Let's see if the CI is happy ;) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
CI is green @normanmaurer @chrisvest so, ready to go? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Very nice. Thanks! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Could not create auto-port PR. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Motivation: SizeClassedChunk performs 2 atomic ops (retain/release) per allocation cycle on the hot path. Modification: Replace ref counting with a segment-count state machine that only needs atomics on the cold deallocation path. Result: No more per-allocation atomic operations for SizeClassedChunk. (cherry picked from commit de25e7a)
|
Auto-port PR for 5.0: #16378 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Motivation: SizeClassedChunk performs 2 atomic ops (retain/release) per allocation cycle on the hot path. Modification: Replace ref counting with a segment-count state machine that only needs atomics on the cold deallocation path. Result: No more per-allocation atomic operations for SizeClassedChunk. (cherry picked from commit de25e7a)
|
Port PR for 4.1: #16379 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Motivation: SizeClassedChunk performs 2 atomic ops (retain/release) per allocation cycle on the hot path. Modification: Replace ref counting with a segment-count state machine that only needs atomics on the cold deallocation path. Result: No more per-allocation atomic operations for SizeClassedChunk. (cherry picked from commit de25e7a) Co-authored-by: Francesco Nigro <[email protected]>
…6378) Auto-port of #16306 to 5.0 Cherry-picked commit: de25e7a --- Motivation: SizeClassedChunk performs 2 atomic ops (retain/release) per allocation cycle on the hot path. Modification: Replace ref counting with a segment-count state machine that only needs atomics on the cold deallocation path. Result: No more per-allocation atomic operations for SizeClassedChunk. Co-authored-by: Francesco Nigro <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.