Skip to content

Preventing oversubscription with multithreaded code? #1012

Open
@ivirshup

Description

@ivirshup

This is probably a feature request.

I've been finding that running pytest -n auto can take or even just seem to hang when testing one of my codebases. I believe the culprit is that a number of tests using matrix multiplication or parallelized numba functions are being hit at the same time. Both of these cases default to using the number of cores as the default number of threads – so my CPU becomes heavily oversubscribed.

Would it be possible for pytest-xdist to use something like threadpoolctl to limit the number of threads each worker uses? Ideally it could be similar to how joblib or dask set the number of threads available to each worker to something like hardware_threads // num_workers.

Alternatively, is there a good way I could set this behaviour myself? Ideally without hardcoding the number of threads to use.

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