GithubHelp home page GithubHelp logo

Comments (2)

Matthias247 avatar Matthias247 commented on September 26, 2024 1

The behavior is now changed in master for all primitives that are part of the sync module

from futures-intrusive.

Matthias247 avatar Matthias247 commented on September 26, 2024

It's pretty easy to improve:

Before:

matthias@Matthiass-MBP  ~/Code/rust/futures-intrusive (test *)
$cargo run --example abc --release
    Finished release [optimized] target(s) in 0.09s
     Running `target/release/examples/abc`
Elapsed: 3361ms

After:

matthias@Matthiass-MBP  ~/Code/rust/futures-intrusive (test *)
$cargo run --example abc --release
   Compiling futures-intrusive v0.2.2 (/Users/matthias/Code/rust/futures-intrusive)
    Finished release [optimized] target(s) in 2.85s
     Running `target/release/examples/abc`
Elapsed: 138ms

Most wait lists in the library currently use a single linked list, which requires an O(n) iteration for some operations, but only requires to store a single pointer which minimizes the size of Futures. With the typical amount of tasks that interact with a wait list (which might be well below 100) that is not really an issue. But with your high numbers it certainly gets excessive slow.

Changing to a double linked list (which is a single line code change - since the list is already implemented) fixes the issue - at the cost of storing an additional pointer per Future. For Semaphore I'm definitely convinced that this seems to be the better tradeoff, since people would use it like you to let a big number of tasks wait on it, so let's make the change. For other things like Channels I'm still undecided.

It seems to be designed to wake the last waiter. But why it is still required even when !is_fair?

The idea here certainly was that the cost difference between waking the last or the first waiter isn't that high. And that waking the oldest waiter at least retains some amount of fairness.

from futures-intrusive.

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.