-
Notifications
You must be signed in to change notification settings - Fork 35
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
Document fairness properties #45
Comments
I think this is a great idea because there are a few ways we could define fairness and I think it's worth declaring which one we mean and plan to uphold. Here are a few questions I think would be good to answer: How do we measure fairness?Here are some possibilities:
I think 3 is probably not what we want. For example, if you do Option 2 is probably not great either, since we may not always be running in an environment that has a clock. (Although I think basically any device that can run Rust code will have some way of tracking time.) Also, futures are probably IO bound, rather than CPU bound, so balancing execution time probably doesn't really matter since futures will spend very little time running compared to time spent waiting on IO. Option 1 is the easiest to implement, but it may not be fair if the futures themselves are unbalanced in how much work each call to What assumptions do we make about the behavior of futures?Since we're doing cooperative multitasking and can't preempt futures, the behavior of the system depends a lot on the futures themselves. I'd suggest we assume a future that does something like when polled executes for a small, random amount of time, then returns How do we deal with futures that are
|
Would you be open to having non-fair variants of combinators? For use-cases where ordering is important, it'd be great to have biased/prioritized versions (analogous to |
In our case I don't think it matters as much as with the macro variants. Because we reuse futures and streams, and employ perfect wakers in just about every instance, the difference between "fair" and "unfair" waking is really small. We are of course biased towards being fair; but if you want to preserve ordering in a stream which is being processed concurrently, I don't think new operations specifically to do away with fairness are going to be of much benefit for your use. |
Traits such as
race
andmerge
produce a single output from multiple inputs. These traits provide fairness properties which should be documented at the trait implementation level, but also on theRace
andMerge
traits themselves.The text was updated successfully, but these errors were encountered: