Open
Description
I've noticed the use of index()
in this code block causes a significant performance issue when a node has a large number of tests. This can be improved by precomputing a mapping from node ID to index using a dictionary and look it up in the loop.
eg.
index_map = {nodeid: i for i, nodeid in enumerate(worker_collection)}
nodeids_indexes = [
index_map[nodeid]
for nodeid, completed in work_unit.items()
if not completed
]
To reproduce the issue, you can run pytest -n 2 --dist=loadscope
with the following test code:
import pytest
@pytest.mark.parametrize("i", range(100000))
def test_something(i):
pass
Metadata
Metadata
Assignees
Labels
No labels