Skip to content

yield_now not yielding since MAX_TASKS_PER_TICK in LocalSet is hardcoded #5209

@arielb1

Description

@arielb1

Version

Tokio 1.21.2

Platform

Linux 5.15.0-53-generic #59-Ubuntu SMP Mon Oct 17 18:53:30 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Description

The MAX_TICKS_PER_TASK parameter in LocalSet is hardcoded to be 61.

This means that if, while a task is waiting for IO, there is a task in a LocalSet that is performing

loop {
    expensive_computation();
    tokio::task::yield_now().await;
}

The expensive_computation will run up to 61 times before IO is polled, which will cause high tail latencies.

cc @carllerche

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-tokioArea: The main tokio crateC-bugCategory: This is a bug.M-taskModule: tokio/task

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions