-
-
Notifications
You must be signed in to change notification settings - Fork 797
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
why BufferRecycler uses atomic ops on its buffers? #920
Comments
Reading #479 that contains some background about it |
I see that the mentioned issue above perfectly answer my question and I can close this issue, although in my experience, hot path @cowtowncoder |
Right, the short answer is that non-blocking/async use cases would be problematic; more than one |
I don't understand this; if no concurrent access happen because they interleave correctly based on external as-sequential order, no atomic ops should be needed - I'm not a natural english speaker so maybe I've misunderstood your comment too. I'll read again the referenced issue to better understand, thanks! |
Ok. So, the problem is that effectively access to Put another way: life-cycles of individual parsers/generators overlap, and they do not stay thread-bound in non-blocking use scenarios. And because of this, access to buffers within |
I think that if the owner of the What could happen with such approach is that, while the In a future the thread-local concurrent queue of |
I see @cowtowncoder that I've been way to verbose to describe the idea, let me know if I have to rewrite it in a more concise way or if something isn't clear (my fault) |
@franz1981 I think that I do not actually see all that much benefit in trying to solve the way buffer recycling currently works -- locking has overhead but I would not consider it a major problem. But rather I think that the bigger problem is coming issue with I think your last paragraph is nicely in line with what I think of future, fwtw; yes, the direction would be towards more centralized recycling (per-factory, but one pool, not using ThreadLocal). Still, how to change in place for Jackson 2.x is non-trivial, and this is not at the top of my priority list either (it's high just not top). |
I though that having a simpler lifecycle (unshared, but own exclusively per-
Yep, I can come up with something related this, but myself got few things on my place recently, although I can work on this in background.
Don't worry I perfectly understand/relate to this :)
if I can apply this change in the right way this would unblock the rest (not in a release eh, I mean in fork to start with) |
@franz1981 yes, if you want to go ahead, propose something that'd be a good way to go. So the idea would be for a single parser/generator to own |
Has been inactive for a while; in the meantime pluggable Will close this issue; may be re-opened/re-filed if further progress is expected. |
According to
jackson-core/src/main/java/com/fasterxml/jackson/core/util/BufferRecycler.java
Line 133 in 31d4d85
jackson-core/src/main/java/com/fasterxml/jackson/core/util/BufferRecycler.java
Line 159 in 31d4d85
BufferRecycler
, that IIUC is supposed to be thread-confined (and obtained via thread local allocation/recycling), can avoid using atomic instructions (that are quite costy in the hot path, especially if supposely single-threaded).I see that the reason is due to the
releaseXYZBuffer(int ix, ...)
that can (maybe) perform release from whatever thread...is it correct? Or there are other reasons?I'm preparing a patch, to get used with the codebase, in case :)
The text was updated successfully, but these errors were encountered: