Skip to content

Busy-waiting watchdog #672

Open
Open
@belm0

Description

@belm0

It's easy to cause unwanted busy-waiting in tasks, either by mistake (e.g. left out a sleep() call within a periodic loop) or by poor design (e.g. relying too heavily on polling rather than events). The simplest valid Trio program which will use all headroom on the CPU is while True: trio.sleep(0).

This is potentially far more common than the "task never awaits" scenario being addressed in #596.

I'd like to find a heuristic that can detect such problematic code while avoiding false positives.

some metrics which could be employed: median task block time vs. task CPU time over last T seconds, task schedule rate, ranking task schedule rate, cumulative task CPU time over the last T seconds, cumulative CPU time of Trio scheduler over the last T seconds

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions