python-trio / python-trio/trio
Busy-waiting watchdog
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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