python-trio / python-trio/trio

Busy-waiting watchdog

Open
#672 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

debugging user happiness
Dominant language
Python
Stars
7.3k
Forks
431
Avg merge
2d 17h
Merged PRs (30d)
6

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no file, test, or entry point. Start by reviewing the task-never-awaits scenario in #596 and assess the listed metrics, such as task block time versus CPU time and schedule rate; done means a heuristic can identify problematic busy-waiting while avoiding false positives.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.