-
-
Notifications
You must be signed in to change notification settings - Fork 795
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
use the sharedLockFreePool as default pool instead of allocating a new one #1250
Conversation
No, I don't think global singleton is a good choice; it tends to be risky conceptually. Users can configure to do that, but should be (IMO) opt-in and not default. |
@cowtowncoder users are just going to create one JsonFactory and use that to create all their mappers. That would have the same effect of sharing the recycler pool across many threads. Why not make it the default? It will take everyone time to rewrite their code. People switching up to Jackson 2.17 are not expecting to have to rewrite their code - many of them don't even know what a Jackson JsonFactory is. They just create JsonMapper/ObjectMappers directly. |
@mariofusco can you change the Quarkus code to create a singleton JsonFactory and to use that to create all Jackson mappers? I would still like to see this merged but Quarkus can be changed while we decide on what to do with Jackson. |
No... Do not use But that is already what Quarkus does isn't it. No one is creating per-call JsonFactory or ObjectMapper instances, unless they want to get abysmally bad performance. |
I don't get this assumption that everyone is creating throw-away |
One further thought: the access really should not be called by framework code: if default choice is desired, that's what So why is Quarkus calling it? |
Yes. And that should work just fine -- if you create |
The point is lots of users create mappers over and over. This was already slower than reusing mappers but now we've made this much slower than reusing mappers. |
@pjfanning I have little sympathy for cases where |
@mariofusco based on the discussion so far, it seems best if you look at Quarkus and see if you can reuse ObjectMappers instead of creating lots of them. There is more to be gained by reusing mappers than just reusing the Buffer Recycler. There are Deserialization and Serialization caches among other things stored at the ObjectMapper level and you don't benefit from these if you throw away the mapper instances. |
I filed #1256 for actually going back to |
Realized I hadn't actually replied to this:
My concern is not with users fully controlling things, but rather different components sharing global pool. Jackson tries very hard to be compartmentalized so that use by one component/library/framework should be well isolated from that of others. I agree that for single user it makes sense to effectively share a single pool; I am just worried about cases where different usage collides. I do realize that it is very difficult to really reason about all or even major usage across existing user base, and so discussion tends to be quite theoretical. Finally: one thing I may also be open to, wrt 2.18, is static global setting to override the global default. Maybe it'd be possible to specify lambda to use for overriding default pool implementation returned -- and as usual, with strong warnings that being global singleton setting, it is not to be changed by frameworks and libraries, but only by whoever deploys full applications. |
At the moment jackson allocates a new pool every time the default pool is asked. I believe it would be more correct to always reuse the shared one also because the (useless?) creation of a new one is not only causing this issue in quarkus, but even worse is very likely the main cause of the performance problem reported here.