Repository navigation
[#5904] Disable the Recycler by default - #5968
normanmaurer wants to merge 1 commit into
Conversation
Motivation: The Recycler was introduced as a light-weight object pool, to reduce GC pressure. We use it in various places, like pooling ByteBuf objects (not the actual memory, just the container), write tasks (When you call write(...) from outside the EventLoop) and many more. This usage gave us a lot of trouble in the past and also users a hard time when they ended up with a lot of objects in the Reycler due writing to fast etc. Modifications: Disable the recycler by default so users need to explicit enable it to use it. Result: Recycler is not used anymore by default.
|
@nmittler @Scottmitch @buchgr @ejona86 @mosesn @vkostyukov PTAL ... As discussed in #5904. We did a few internal benchmarks and not noticed any bad impact because of this change. Could you please check and maybe run a benchmark as well ? |
|
Also @trustin @cconroy and @NiteshKant |
|
I can confirm that I saw no performance difference when I disabled the recycler via config. |
|
Thanks for the heads up @normanmaurer! I'm running a benchmark right now. Will report back when I have the results. |
|
I've been running some experiments internally and I can confirm this affects us dramatically: GC times are 10x up. Although, I can see how this doesn't actually affect most of Netty users. Here is why. As you probably know, we're not pooling in Finagle (yet) and turns out we've been relying on recyclers to "pool" our outbound/send buffers (we fall through the first condition because our allocators are not pooled). This makes GC times climb up (I constantly reproduced that on our ping-pong test for Mux). Even though this affect us so much, I personally don't think this should be considered as a blocker. As long as the majority of the Netty community happy - we're happy. Worst case, as a workaround, we can re-enable recyclers back locally. |
|
@vkostyukov gotcha.... actually the plan was to remove it completely at some point. With what you told me that may be not feasible at all. Let me think a bit about it. |
|
AS this has such a big impact let me close this for now. |
|
Going back to this (I thought you might be interested in hearing the update). We've been profiling Finagle's HTTP implementations (Netty 4 vs Netty 3) and figured that N4 is performing slightly worse (spends about ~20% more of CPU time normalized per request) while handling the same amount of traffic. Turns out Recyclers account for about half of that overhead. Disabling them manually, helped us to reduce the gap to ~10% in our tests. We're in the process of running more tests with different Finagle components to see if Recyclers can be disabled globally in Finagle. I will report back when I know more. |
|
That’s really interesting... I would be interested in a profiler snapshot of 3.x and 4.x with recycler and without. Would this be possible ?
… Am 13.12.2017 um 23:02 schrieb Vladimir Kostyukov ***@***.***>:
Going back to this (I thought you might be interested in hearing the update).
We've been profiling Finagle's HTTP implementations (Netty 4 vs Netty 3) and figured that N4 is performing slightly worse (spends about ~20% more of CPU time normalized per requests) while handling the same amount of traffic.
Turns out Recyclers account for about half of that overhead. Disabling them manually, helped us to reduce the gap to ~10% in our tests. We're in the process of running more tests with different Finagle components to see if Recyclers can be disabled globally in Finagle.
I will report back when I know more.
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub, or mute the thread.
|
|
@vkostyukov not sure you saw the comment above :) |
|
@normanmaurer when disabling the recycler we see increased GC pressure in new TLAB from MessageToMessageEncoder creating CodecOutputList, most likely coming from the LengthFieldPrepender in our pipeline. |
|
@johnou yeah this sounds possible. That said we could fix this one easily by use a normal |
|
Hey @normanmaurer! Thanks for your patience (and sorry for me being so slow in responding). I think I might be able to get you those profiles. Our simulation framework isn't yet open-sourced so I guess I have to talk to somebody to make sure it doesn't expose any sensitive information. What format would you prefer? I can do flame-graphs / plain flat texts. |
|
@vkostyukov flame-graphs would be nice |
|
One thing to keep in mind here is that the recycler is doing work in the application that effectively replaces the functionality of GC. GC isn't free, but the JVM has a lot of optimization in the GC implementations. So, while GC pressure might increase without the recycler, overall throughput may still in fact be higher! When I ran tests previously, I found that disabling the recycler had no performance impact but vastly reduced memory footprint. |
|
As I think about this again, it might that Finagle is seeing such a big impact is because it's already quite heavily using thread-locals (though its As you know threads locals are cheap, but not free. They always make it to the top of the CPU profile in our simulations: One of the ideas we explored recently was to reduce the number of times we access thread-locals and turns out, disabling recyclers do the trick. |
|
SO you say disabling recycler did the trick because it removes threadlocal access ina big fashion ? |
|
I haven't checked the CPU profile with recyclers disabled but based on the throughput improvements, I'd guess it helps to some extent. One thing I forgot to mention, it's HTTP/1.1 that benefits the most (in Finagle) as its implementation is 100% in Netty. The rest of the protocols (i.e., ThriftMux) don't really notice recyclers. |
|
Got it... I would be super interested in the profile ;)
… Am 19.12.2017 um 18:28 schrieb Vladimir Kostyukov ***@***.***>:
I haven't checked the CPU profile with recyclers disabled but based on the throughput improvements, I'd guess it helps to some extent. One thing I forgot to mention, it's HTTP/1.1 that benefits the most (in Finagle) as its implementation is 100% in Netty. The rest of the protocols (i.e., ThriftMux) don't really notice recyclers.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
|
Created new issue for our discussion wrt LengthFieldPrepender / MessageToMessageEncoder #7528 |
|
@normanmaurer also seeing high allocation in PooledUnsafeDirectByteBuf when disabling the recycler, maybe I didn't run the application for long enough..? |
|
Well one of these |
|
@normanmaurer I thought they were suppose to be, well, pooled? |
|
@johnou the internal storage is... and the external object (the ByteBuf itself) is in the recycler. |
|
@vkostyukov any update ? |
|
Just wanted to close the loop on this. We re-did our testing just recently and came to a conclusion that disabling recyclers improves the overall throughput of both ThrifMux and HTTP servers (at the cost of extra allocations): Here are some concrete numbers we observed:
We're disabling recyclers in Finagle and are totally onboard if they will be disabled by default (or just removed in a long run) in Netty. |
|
FYI: ByteBufUtil's threadLocalDirectBuffer (non-obviously to me) relies on Recycler. If we disable recycler, at the very least we should add a comment when reading the |
|
+1
… Am 25.06.2018 um 19:41 schrieb Eric Anderson ***@***.***>:
FYI: ByteBufUtil's threadLocalDirectBuffer (non-obviously to me) relies on Recycler. If we disable recycler, at the very least we should add a comment when reading the io.netty.threadLocalDirectBufferSize property that it's probably a bad idea to enable it without also enabling the Recycler.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
|
Is it as simple as removing the recycler completely OR removing certain items that are affecting performance from using the Recycler? Maybe not all objects are suitable for it, e.g. those that are easily created and so would be easier task for the JVM GC to deal with. |


Motivation:
The Recycler was introduced as a light-weight object pool, to reduce GC pressure. We use it in various places, like pooling ByteBuf objects (not the actual memory, just the container), write tasks (When you call write(...) from outside the EventLoop) and many more.
This usage gave us a lot of trouble in the past and also users a hard time when they ended up with a lot of objects in the Reycler due writing to fast etc.
Modifications:
Disable the recycler by default so users need to explicit enable it to use it.
Result:
Recycler is not used anymore by default.