-
Notifications
You must be signed in to change notification settings - Fork 605
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
Iteration policy API for eager polling loops #1961
Commits on Nov 23, 2019
-
Starting work on adding busy loop guards to stream combinators.
Configuration menu - View commit details
-
Copy full SHA for 7e76c90 - Browse repository at this point
Copy the full SHA 7e76c90View commit details -
Require a token for breaking out of poll_loop!
An unlabeled break expression inside the loop body given to poll_loop! breaks out of the loop in the expansion with the effect of yielding to the task. Make the users conscious of this by requiring the break expression to carry a token value of type $crate::task::ToYield.
Configuration menu - View commit details
-
Copy full SHA for 455fbf6 - Browse repository at this point
Copy the full SHA 455fbf6View commit details -
Configuration menu - View commit details
-
Copy full SHA for b24c62b - Browse repository at this point
Copy the full SHA b24c62bView commit details -
Configuration menu - View commit details
-
Copy full SHA for df4d079 - Browse repository at this point
Copy the full SHA df4d079View commit details -
futures-util: Ground work for poll loop guards
Import the poll_loop! macro from futures-core. Define a constant with some uneducated guess value on a good default for yielding after this number of iterations, which should keep the overhead low in good cases, but not block the outer poll for too many iterations.
Configuration menu - View commit details
-
Copy full SHA for ae5303f - Browse repository at this point
Copy the full SHA ae5303fView commit details -
Configuration menu - View commit details
-
Copy full SHA for 3c0ee91 - Browse repository at this point
Copy the full SHA 3c0ee91View commit details -
Configuration menu - View commit details
-
Copy full SHA for c7a6ddd - Browse repository at this point
Copy the full SHA c7a6dddView commit details -
Busy loop guard for stream::Flatten
Not normally expected to occur, but a busy stream of empty streams can theoretically saturate this loop.
Configuration menu - View commit details
-
Copy full SHA for 60c80a5 - Browse repository at this point
Copy the full SHA 60c80a5View commit details -
Configuration menu - View commit details
-
Copy full SHA for b14a1f5 - Browse repository at this point
Copy the full SHA b14a1f5View commit details -
Configuration menu - View commit details
-
Copy full SHA for 7dd521e - Browse repository at this point
Copy the full SHA 7dd521eView commit details -
Configuration menu - View commit details
-
Copy full SHA for a01ef0e - Browse repository at this point
Copy the full SHA a01ef0eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 3aea69c - Browse repository at this point
Copy the full SHA 3aea69cView commit details -
Configuration menu - View commit details
-
Copy full SHA for 78ed967 - Browse repository at this point
Copy the full SHA 78ed967View commit details -
Configuration menu - View commit details
-
Copy full SHA for 46ff20b - Browse repository at this point
Copy the full SHA 46ff20bView commit details -
Configuration menu - View commit details
-
Copy full SHA for 58c0791 - Browse repository at this point
Copy the full SHA 58c0791View commit details -
Configuration menu - View commit details
-
Copy full SHA for ac0ee30 - Browse repository at this point
Copy the full SHA ac0ee30View commit details -
Configuration menu - View commit details
-
Copy full SHA for ff1b4b7 - Browse repository at this point
Copy the full SHA ff1b4b7View commit details -
Busy loop guards for stream::{Filter, FilterMap}
These can busy loop if the filter future consistenly filters out items.
Configuration menu - View commit details
-
Copy full SHA for 81de5f5 - Browse repository at this point
Copy the full SHA 81de5f5View commit details -
Configuration menu - View commit details
-
Copy full SHA for ae22dc0 - Browse repository at this point
Copy the full SHA ae22dc0View commit details -
Configuration menu - View commit details
-
Copy full SHA for 36382a9 - Browse repository at this point
Copy the full SHA 36382a9View commit details -
Configuration menu - View commit details
-
Copy full SHA for 60660e1 - Browse repository at this point
Copy the full SHA 60660e1View commit details -
Configuration menu - View commit details
-
Copy full SHA for 69868ed - Browse repository at this point
Copy the full SHA 69868edView commit details -
Configuration menu - View commit details
-
Copy full SHA for e6f3d6c - Browse repository at this point
Copy the full SHA e6f3d6cView commit details -
Configuration menu - View commit details
-
Copy full SHA for 808ef7a - Browse repository at this point
Copy the full SHA 808ef7aView commit details -
Configuration menu - View commit details
-
Copy full SHA for 3107730 - Browse repository at this point
Copy the full SHA 3107730View commit details -
Optimize poll_loop! using NonNullU32
Use NonNullU32 for the limits on the number of iterations to give the optimizer information that the first iteration will always be taken, allowing to unroll it or move the loop exit check to the end. To make poll_loop! macro work with a NonNullU32 argument, apply an Into<u32> conversion to it. The iteration range is now strictly in u32, while previously the integer type was inferred from the macro's argument.
Configuration menu - View commit details
-
Copy full SHA for 1f1c55b - Browse repository at this point
Copy the full SHA 1f1c55bView commit details -
Configuration menu - View commit details
-
Copy full SHA for 7432b5c - Browse repository at this point
Copy the full SHA 7432b5cView commit details -
Configuration menu - View commit details
-
Copy full SHA for c07e93e - Browse repository at this point
Copy the full SHA c07e93eView commit details -
Method yield_after_every to tune iteration guards
Add combinator method .yield_after_every(n) to stream and future combinator types that have been provided with iteration guards. This gives the user means to fine tune the yielding behavior.
Configuration menu - View commit details
-
Copy full SHA for 4c7da04 - Browse repository at this point
Copy the full SHA 4c7da04View commit details -
iteration::Policy trait for poll_loop!
Future-proofing the poll_loop! macro by defining a Policy trait that is provided by poll guard implementations: Limit with the maximum count, and Unlimited that does not do any checks.
Configuration menu - View commit details
-
Copy full SHA for 65262fd - Browse repository at this point
Copy the full SHA 65262fdView commit details -
Rotate the check in poll_loop!, remove ToYield
Perform the yield check at the end of an iteration. Document the check-skipping effect of `continue` and the new semantics of `break`: this can now be used to return arbitrary values from the poll_loop! expression. This is less semantically weird than `break ToYield`, and `continue` gets back its usual meaning of continuing iteration unconditionally.
Configuration menu - View commit details
-
Copy full SHA for fefd6e5 - Browse repository at this point
Copy the full SHA fefd6e5View commit details -
Rework the loop guard protocol
iteration::Policy gets methods to observe how the loop has ended. LoopGuard, a RAII helper, is used by poll_loop! to catch early returns. The uses of poll_loop! in futures-util needed to be changed to split borrows out of Pin<&mut Self>, allowing the guard to borrow the iteration checker while other state objects are used and modified by the loop body. Notably, this makes the code of the loops more readable.
Configuration menu - View commit details
-
Copy full SHA for 4271013 - Browse repository at this point
Copy the full SHA 4271013View commit details -
Configuration menu - View commit details
-
Copy full SHA for 3da7d7d - Browse repository at this point
Copy the full SHA 3da7d7dView commit details -
Add optional customization of a possibly nested path to the iteration policy checker field.
Configuration menu - View commit details
-
Copy full SHA for e6f3a06 - Browse repository at this point
Copy the full SHA e6f3a06View commit details -
Configuration menu - View commit details
-
Copy full SHA for f6d6670 - Browse repository at this point
Copy the full SHA f6d6670View commit details -
Configuration menu - View commit details
-
Copy full SHA for 967de9b - Browse repository at this point
Copy the full SHA 967de9bView commit details -
Configuration menu - View commit details
-
Copy full SHA for d7a4339 - Browse repository at this point
Copy the full SHA d7a4339View commit details -
Change default iteration limit to a power of two
The default limit is nearly arbitrary, aiming to keep the yielding overhead in low single digit percentages while not starving other pollables for too many iterations. Making it a power of two does not make much difference, except that it may produce more efficient allocation patterns in hypothetical cases e.g. when a future accumulates a collection from polled items, then yields, which causes draining of the collection by some other pollable.
Configuration menu - View commit details
-
Copy full SHA for 1fc8a23 - Browse repository at this point
Copy the full SHA 1fc8a23View commit details -
Configuration menu - View commit details
-
Copy full SHA for ea8ecb0 - Browse repository at this point
Copy the full SHA ea8ecb0View commit details -
Simplify iteration::Policy and erase LoopGuard
It's not a good idea to let impls run arbitrary code in the RAII destructor which may be invoked in an unwind. Also, separation between yield_check and when_yielded is not really necessary. Erase when_* methods on Policy and allow the yield_check method to modify the receiver so that adaptive and instrumentation impls are still supported. With this, LoopGuard is not needed in poll_loop! and is gone.
Configuration menu - View commit details
-
Copy full SHA for 3ffb24a - Browse repository at this point
Copy the full SHA 3ffb24aView commit details -
Improve naming in iteration API
Renamed: Policy -> LoopPolicy, for more instant legibility in docs Policy::begin -> LoopPolicy::enter, clearer meaning
Configuration menu - View commit details
-
Copy full SHA for d129010 - Browse repository at this point
Copy the full SHA d129010View commit details -
Configuration menu - View commit details
-
Copy full SHA for 9749923 - Browse repository at this point
Copy the full SHA 9749923View commit details -
Configuration menu - View commit details
-
Copy full SHA for db4b867 - Browse repository at this point
Copy the full SHA db4b867View commit details -
futures-util: More descriptive yield_after macros
Make the meta parameter names describe what each doc string refers to.
Configuration menu - View commit details
-
Copy full SHA for 7f24550 - Browse repository at this point
Copy the full SHA 7f24550View commit details