Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AdaptivePoolingAllocator EventLoop Magazine's affinity #14047

Merged
merged 3 commits into from May 14, 2024

Conversation

franz1981
Copy link
Contributor

Motivation:

AdaptivePoolingAllocator uses some shared Magazines hoping thread's id distribution to improve contended behaviour, but event loops threads can just uses their own Magazine(s) and save 2 atomic operations (write lock/unlock) in the hot path, further improving performance.

Modification:

Implements dedicated event loop Magazines

Result:

Better allocation performance for event loop threads

@franz1981
Copy link
Contributor Author

franz1981 commented May 10, 2024

This is trying hard to make close right(ish) - that's why it doesn't allow to just use FastThreadLocalThreads, but I can relax this a bit, accepting FastThreadLocalThreads which cleanup their FastThreadLocal, too: but clearly it means that closing the allocator won't do anything to the Magazines held in threadLocalMagazine.

Additionally, in Netty 5 i see no usedMemory counters: which will likely make this allocator to still perform better than the existing one in Netty 4.1.

Another pain point of the Netty 5 version is that allowing close means that users can really have fun creating many allocators, and per instance FastThreadLocal are a problem, because there's a giant array to back all the entries which will keep on being atomically increased as new instances are created....

Motivation:

AdaptivePoolingAllocator uses some shared Magazines hoping thread's id
distribution to improve contended behaviour, but event loops threads can
just uses their own Magazine(s) and save 2 atomic operations (write
lock/unlock) in the hot path, further improving performance.

Modification:

Implements dedicated event loop Magazines

Result:

Better allocation performance for event loop threads
@franz1981 franz1981 force-pushed the main_event_executor_magazines branch from bca0a9d to 344bf9b Compare May 10, 2024 21:09
@franz1981
Copy link
Contributor Author

I think I forgot to close the magazine on ThreadLocal::onRemove

@franz1981
Copy link
Contributor Author

Done @normanmaurer let's see what the CI think

@chrisvest chrisvest merged commit c77c02e into netty:main May 14, 2024
15 checks passed
@franz1981 franz1981 deleted the main_event_executor_magazines branch May 16, 2024 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants