Repository navigation
Change default of io.netty.allocator.useCacheForAllThreads to false - #12109
Conversation
|
I think this is a good one...We should ensure we explicit call this out in the release notes tho! |
franz1981
left a comment
There was a problem hiding this comment.
I'm the one proposing this to @chrisvest , hence +1 by me
|
This is breaking change for 4.1 branch, isn't It? |
|
It's a non-functional change, so I don't consider it breaking. Downstream libraries and frameworks should allow resource hubs, such as allocators, to be passed in, but it's beyond our control if they do this. And those that shade Netty control their own fate either way. For the time being, it seems like the current default has caused trouble, so we're trying this change. |
It does flip the default (existed for 5 years) - so considerable portion of buffers allocated by
This may be non-representative - few complained (they may use another constructor), but thousands rely on current default. This change would affect downstream libraries regardless shading - as library accepting allocator in API cant force end user not to use this new (proposed) default, and new default affects performance in negative way. |
It's not how it works: It means that allocation won't use thread-local allocation buffers, but can fall into many other shared layers of pools (the jemalloc 3 doc explain it quite well). |
I think we should announce this change in release notes upon release. |
yep... thats why I added the label |
|
@chrisvest can you rebase and resolve the conflicts please. |
…etty#8991) Motivation: We currently use a thread local cache for all threads which often is suprising to users as it may result in a lot of memory usage if they allocate buffers from outside the EventLoop in different threads. We should better not do this by default to keep suprises to a minimum. Users that need the performance and know what they are doing can still change this. Modifications: Change io.netty.allocator.useCacheForAllThreads to false by default Result: Related to netty#8536.
8e3f500 to
cbac543
Compare
|
@normanmaurer Rebased |
|
@mostroverkhov thanks for bringing up your concerns but I still think this is a worthwhile change (even for 4.1). Like said by @franz1981 the pooling will still work it will just remove the "thread local caches" for the "other threads" by default. |
|
For documenting the change of behaviour for this: it would also seem to affect the EventLoop thread as well (as opposed to just 'other threads') for anyone supplying a ThreadFactory when creating the EventLoopGroup if it is not creating a FastThreadLocalThread specifically. (Originally mentioned elsewhere by @franz1981) |
…utor by default Motivation: #12109 changed the default of using the thread local cache for buffers only for FastThreadLocalThread. While this is good it also means that it would affect everyone that use a custom ThreadFactory when construct the EventLoop / EventExecutor Modifications: Make use of ThreadExecutorMap to check if the Thread is used by any EventExecutor and if so also enable the cache. Result: Fixes #12109 (comment)
…utor by default (#12158) Motivation: #12109 changed the default of using the thread local cache for buffers only for FastThreadLocalThread. While this is good it also means that it would affect everyone that use a custom ThreadFactory when construct the EventLoop / EventExecutor Modifications: Make use of ThreadExecutorMap to check if the Thread is used by any EventExecutor and if so also enable the cache. Result: Fixes #12109 (comment)
…utor by default (#12158) Motivation: #12109 changed the default of using the thread local cache for buffers only for FastThreadLocalThread. While this is good it also means that it would affect everyone that use a custom ThreadFactory when construct the EventLoop / EventExecutor Modifications: Make use of ThreadExecutorMap to check if the Thread is used by any EventExecutor and if so also enable the cache. Result: Fixes #12109 (comment)
### What changes were proposed in this pull request? This pr aims to upgrade netty to 4.1.75 and this pr add the explicit dependency on `netty-tcnative-classes` because the dependency on `netty-tcnative-classes` is changed to `Optional` in [netty](netty/netty#12146). ### Why are the changes needed? The release notes as follows: - https://netty.io/news/2022/03/10/4-1-75-Final.html There are 2 import changes in this version and both of these changes are to reduce memory-overhead: - [Reduce the default PooledByteBufAllocator chunk size from 16 MiB to 4 MiB](netty/netty#12108) - [Change default of io.netty.allocator.useCacheForAllThreads to false](netty/netty#12109) ### Does this PR introduce _any_ user-facing change? Yes, all changes are caused by the change of Netty. If the user wants to maintain the same behavior as the previous version, the user needs to make the following configuration: - add `-Dio.netty.allocator.useCacheForAllThreads=true` to enable `useCacheForAllThreads ` - add `-Dio.netty.allocator.maxOrder=11` to keep the chunk size of `PooledByteBufAllocator` to 16m ### How was this patch tested? Pass GA Closes #35835 from LuciferYang/upgrade-netty-4175. Authored-by: yangjie01 <[email protected]> Signed-off-by: Sean Owen <[email protected]>
…etty#8991) (netty#12109) Motivation: We currently use a thread local cache for all threads which often is suprising to users as it may result in a lot of memory usage if they allocate buffers from outside the EventLoop in different threads. We should better not do this by default to keep suprises to a minimum. Users that need the performance and know what they are doing can still change this. Modifications: Change io.netty.allocator.useCacheForAllThreads to false by default Result: Related to netty#8536. Co-authored-by: Norman Maurer <[email protected]>
…utor by default (netty#12158) Motivation: netty#12109 changed the default of using the thread local cache for buffers only for FastThreadLocalThread. While this is good it also means that it would affect everyone that use a custom ThreadFactory when construct the EventLoop / EventExecutor Modifications: Make use of ThreadExecutorMap to check if the Thread is used by any EventExecutor and if so also enable the cache. Result: Fixes netty#12109 (comment)
…etty#8991) (netty#12109) Motivation: We currently use a thread local cache for all threads which often is suprising to users as it may result in a lot of memory usage if they allocate buffers from outside the EventLoop in different threads. We should better not do this by default to keep suprises to a minimum. Users that need the performance and know what they are doing can still change this. Modifications: Change io.netty.allocator.useCacheForAllThreads to false by default Result: Related to netty#8536. Co-authored-by: Norman Maurer <[email protected]>
…utor by default (netty#12158) Motivation: netty#12109 changed the default of using the thread local cache for buffers only for FastThreadLocalThread. While this is good it also means that it would affect everyone that use a custom ThreadFactory when construct the EventLoop / EventExecutor Modifications: Make use of ThreadExecutorMap to check if the Thread is used by any EventExecutor and if so also enable the cache. Result: Fixes netty#12109 (comment)
This is a back port of #8991
Motivation:
We currently use a thread local cache for all threads which often is suprising to users as it may result in a lot of memory usage if they allocate buffers from outside the EventLoop in different threads. We should better not do this by default to keep suprises to a minimum. Users that need the performance and know what they are doing can still change this.
Modifications:
Change io.netty.allocator.useCacheForAllThreads to false by default
Result:
Related to #8536.
This should also mitigate (but not solve) #12067