-
Notifications
You must be signed in to change notification settings - Fork 632
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
Best practices for combinators with their own task pools (a la FuturesUnordered) #2053
Comments
I think the most appealing solution to this is for |
Yes, if there was some sort of global mechanism for setting budget and decrementing / resetting where appropriate, I could see |
One other option as briefly mentioned in #2047 (comment) is to make |
This is something I've been experimenting with for the last week in a project called unicycle. The architecture is described in more detail in the README, but briefly: It maintains two bitsets (active and alternate) and child tasks store wakeup interest in the active bitset. Once polled it swaps these bitsets and uses the alternate to determine what to poll while draining it. Once it is empty, it forcibly yields and starts over again. This guarantees that each child task is only polled at most once per cycle. And child tasks which aggressively signal interest in waking up are not given any special preference. What I've been able to determine so far:
With Jon's help I've been comparing it to |
The benchmarks detailed here with links make heavy use of |
We already do much work per iteration (e.g., due to FuturesUnordered). See also rust-lang/futures-rs#2053.
See #2047. When a combinator keeps its own task pool rather than deferring directly to the parent executor, cooperatively yielding (
cx.waker.wake_by_ref(); return Poll::Pending
) works "less well" because the task pool will remain active and thus be polled again. #2049 introduced a mitigation for this by limiting the number of times aFuturesUnordered
is polled, but it'd be good to develop general guidance for these types of combinators, and perhaps a more principled solution forFuturesUnordered
.cc @jonhoo @carllerche
The text was updated successfully, but these errors were encountered: