pytest-dev / pytest-dev/pytest-xdist
LoadScopeScheduling._pending_of slow for many tests
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.9k
- Forks
- 287
- Avg merge
- 9h 30m
- Merged PRs (30d)
- 2
Description
As each test is marked complete _pending_of is called at least once. _pending_of then iterates over a dictionary that contains a True/False for every assigned test. This has n^2 performance in the number of tests, which can really have an effect when you have a few thousand tests.
2 simple fixes come to mind:
- Keep a dictionary of {node : pending_count} and increment/decrement as necessary. Then _pending_of is just a lookup instead of an iteration.
- Delete finished nodeids and scopes from self.assigned_work to make the iteration faster.
Thoughts? Option 1 seems preferable to me, as then you're still keeping track of finished tests.
Contributor guide
No contributing guide indexed for this repository
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
Start by locating LoadScopeScheduling._pending_of and tracing how self.assigned_work is populated and updated as tests complete. Compare the proposed pending-count and finished-node removal approaches, then run the scheduler's existing test suite if available. Done means _pending_of no longer iterates over every assigned test while finished-test tracking remains correct.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- performance, testing-qa
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100