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

coop: allow disabling cooperative scheduling #3516

Closed
wants to merge 1 commit into from

Commits on Feb 11, 2021

  1. coop: allow disabling cooperative scheduling

    With deeply nested FuturesUnordered where most leaf futures are ready,
    yields forced by the cooperative scheduling mechanism result in a lot of
    useless polls when Tokio attempts to force a return to the runtime.
    
    Indeed, it takes 32 useless polls to exit a single layer of
    FuturesUnordered, so with e.g. 5 layers, it takes 32^5 polls (it doesn't
    matter how many futures are in the FuturesUnordered instance since it'll
    poll 32 times, even if it's the same future being polled 32 times). This
    has to be done # total futures / 128 times, which can be a prohibitively
    high amount of polling.
    
    In our services, we've seen this result in ~50% of our CPU time being
    spent in `wake_by_ref()` called by `poll_proceed`. Conversely, we've not
    actually seen benefits from using cooperative scheduling, so turning it
    off seems like a natural solution.
    
    This commit adds support for doing this in the runtime builder. It
    targets the 2.x branch since that is the one we're currently using, but
    I'm happy to port this to 1.x.
    krallin committed Feb 11, 2021
    Configuration menu
    Copy the full SHA
    818f943 View commit details
    Browse the repository at this point in the history