-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
macros: make select!
budget-aware
#7164
base: master
Are you sure you want to change the base?
macros: make select!
budget-aware
#7164
Conversation
Previously the test would hang on the |
// Return `Pending` when the task budget is depleted since budget-aware futures | ||
// are going to yield anyway and other futures will not cooperate. | ||
if !$crate::macros::support::has_budget_remaining() { | ||
cx.waker().wake_by_ref(); | ||
|
||
return ::std::task::Poll::Pending; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this is really the best way to go about it. Does our other coop logic run cx.waker().wake_by_ref()
directly, or do they stash the waker in the array used by yield_now()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
poll_proceed
calls wake_by_ref
directly instead of going through context::defer
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked at poll_proceed,
and it does use wake_by_ref
. However, I don't know if that is intentional or if we forgot to update that code when yield_now()
switched to the defer strategy. My guess is that it is an intentional artifact, and we should update it.
I think the logic (if no budget remaining, then yield) should be wrapped up as a utility that lives in the coop
module, so we keep the logic in one place. Separately, we should determine if coop yielding should use the defer path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is where the defer list was introduced. It feels like coop yielding should use the same path. We can fix this after this PR lands, though. However, it would be nice if all coop code uses a single method that does the actual yielding.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I filed #7185 to fix the coop issue.
Co-authored-by: Alice Ryhl <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At a high level, I think the direction of this PR is good. I left one comment inline.
Resolves #7108.