Giter Club home page Giter Club logo

Comments (2)

nitsanw avatar nitsanw commented on June 12, 2024 1

I think we can fix the spin loop to read the updated pIndex in the loop so it can recover, or we can take the current size policy and extend it.

<rambling> I'm a little uncomfortable with the recovery logic violating the monotonically increasing property of the indexes. It's a nice property to have, but I can also see the argument that the parity bit is not REALLY an advance in this usecase, we could have used the sign bit for the same purpose and that would have violated monotonic progress just as much.</rambling>

Proposed solution, we follow the size current behaviour here:

size = (cIndex - pIndex)/2 -> queue in transition is empty

=> isEmpty = (cIndex - pIndex)/2 == 0 (make it match size, but without all the funky mitigations)

=> poll/peek loop needs to change:
            long pIndex = lvProducerIndex();
            if (index - pIndex)/2 == 0) return null;
            // poll() == null iff queue is empty, null element is not strong enough indicator, so we must
            // check the producer index. If the queue is indeed not empty we spin until element is
            // visible.
            do
            {
                e = lvRefElement(buffer, offset);
            }
            while (e == null);

from jctools.

franz1981 avatar franz1981 commented on June 12, 2024

Agree: I like the proposed solution and I was thinking about re-reading pIndex every X spin for element as well (very happy we reached the same exact conclusions), although I believe that adding a chunk could be a slow operation (if the allocation is outside a tlab, for example) and being able to promptly return back to the user application code (with a null poll) can help similarly to relaxedPoll to give the application code the chance to do something different (if any).
In short +100 for the proposed solution

from jctools.

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.