Git Product home page Git Product logo

Comments (4)

simondaudin avatar simondaudin commented on September 26, 2024 1

Thanks for the information !
It seems, indeed, to be a problematic similar to #479

from jackson-dataformats-binary.

cowtowncoder avatar cowtowncoder commented on September 26, 2024

Thank you for reporting this, @simondaudin -- and especially for providing the reproduction!

Without looking too deep, based on failure and test code, it does seem like a legit bug somewhere and not incorrect usage.
But I hope to add more information when I have time to look into this problem.

from jackson-dataformats-binary.

simondaudin avatar simondaudin commented on September 26, 2024

Hello, thanks for the response.

I actually got curious and went digging a little bit.
It seems due to SmileBufferRecycler being created in the main thread and so, created only once in SmileParserBase ThreadLocal _smileRecyclerRef and then used inside all the parallel thread.
Second problem, in SmileBufferRecycler there is a race condition between the get and the set to null.

I tried two solutions that both worked:

  • wrapped SmileBufferRecycler._seenNamesBuffer in an AtomicReference
  • replacing the SmileParserBase._smileBufferRecycler field by the method with the same name so that it is lazily instantiated by the correct thread when needed

In the first solution, we only have one instance of SmileBufferRecycler shared by all the parallel threads.
I had no further insights about what it was supposed to be in this context, so I was not sure about making a PR.

from jackson-dataformats-binary.

cowtowncoder avatar cowtowncoder commented on September 26, 2024

This may be due to earlier assumptions that parser instances were bound 1-to-1 on threads, and as such buffer recyclers would work without explicit synchronization as long as ThreadLocal was used. This turned out not to be the case with async processing, and changes have been made in jackson-core for recycling of symbol tables, for example.

But I suspect not for SmileBufferRecycler; it predates async Smile parser as well.

So this gives a reasonable idea that adding unfortunate-but-now-necessary locking is probably needed.
src/main/java/com/fasterxml/jackson/core/util/BufferRecycler.java from jackson-core may provide some clues, I forget exact changes that have been made over various versions.

from jackson-dataformats-binary.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.