diff options
author | Jon Gjengset <jon@thesquareplanet.com> | 2020-05-21 17:07:23 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-21 17:07:23 -0400 |
commit | 9f63911adc5b809fd3df7cfbb736897a86895e0c (patch) | |
tree | e5fe08b297c137a475bd7531d61d46c14cf7636f /.github | |
parent | 1e54a35325fa371d61c428ead5879a6bb1b0ddf6 (diff) |
coop: Undo budget decrement on Pending (#2549)
This patch updates the coop logic so that the budget is only decremented
if a future makes progress (that is, if it returns `Ready`). This is
realized by restoring the budget to its former value after
`poll_proceed` _unless_ the caller indicates that it made progress.
The thinking here is that we always want tasks to make progress when we
poll them. With the way things were, if a task polled 128 resources that
could make no progress, and just returned `Pending`, then a 129th
resource that _could_ make progress would not be polled. Worse yet, this
could manifest as a deadlock, if the first 128 resources were all
_waiting_ for the 129th resource, since it would _never_ be polled.
The downside of this change is that `Pending` resources now do not take
up any part of the budget, even though they _do_ take up time on the
executor. If a task is particularly aggressive (or unoptimized), and
polls a large number of resources that cannot make progress whenever it
is polled, then coop will allow it to run potentially much longer before
yielding than it could before. The impact of this should be relatively
contained though, because tasks that behaved in this way in the past
probably ignored `Pending` _anyway_, so whether a resource returned
`Pending` due to coop or due to lack of progress may not make a
difference to it.
Diffstat (limited to '.github')
0 files changed, 0 insertions, 0 deletions