Skip to content
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

Add task::consume_budget util for cooperative scheduling #4498

Merged
merged 2 commits into from May 30, 2022

Commits on May 30, 2022

  1. task: add consume_budget for cooperative scheduling

    For cpu-only computations that do not use any Tokio resources,
    budgeting does not really kick in in order to yield and prevent
    other tasks from starvation. The new mechanism - consume_budget,
    performs a budget check, consumes a unit of it, and yields only
    if the task exceeded the budget. That allows cpu-intenstive
    computations to define points in the program which indicate that
    some significant work was performed. It will yield only if the budget
    is gone, which is a much better alternative to unconditional yielding,
    which is a potentially heavy operation.
    psarna committed May 30, 2022
    Copy the full SHA
    4edffb1 View commit details
    Browse the repository at this point in the history
  2. tests: add a test case for task::consume_budget

    The test case ensures that the task::consume_budget utility
    actually burns budget and makes the task yield once the whole
    budget is gone.
    psarna committed May 30, 2022
    Copy the full SHA
    945c75f View commit details
    Browse the repository at this point in the history