Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

speed up tests with pytest-xdist #114

Merged
merged 2 commits into from
Oct 26, 2024

Conversation

EtayLivne
Copy link
Contributor

Hi,

As I've been working on pull request #113, I've noticed that the tests are quite compute intensive and take a while to run.

I've added in pytest-xdist to see if it helps any, and on my 16 core machine it reduces test execution time from 1m46s to 1m, roughly 45% faster.
It's a "breaking change" in the sense that anyone who already has a local env installed will need to install pytest-xdist to run tests.

It's a small change that'll help the repo remain more manageable as it grows, so I thought to suggest it here :)

@SamDuffield
Copy link
Contributor

Agree that the tests can be sped up, so thanks for thinking about this.

I'm not very familiar with pytest-xdist but I'm a tad hesitant to automatically use up parallel resources by default since often developers want to run the tests in the background without interfering with other running threads. Ofc let me know if my caution here is unfounded.

Maybe there is a way to make this optional for the user but not default (but we can use xdist for the github actions runs)?

@EtayLivne
Copy link
Contributor Author

Great point - I was imagining that someone running the test is likely doing it on a personal PC and is unlikely to have background workloads, but it's always good to be conservative with resource demand!

As you suggested, I disabled the automatic multithreading when running tests locally (anyone can still opt in by adding the "-n auto" arg when they invoke the tests), and added automatic multithreading the the github tests action.

@SamDuffield SamDuffield added the enhancement New feature or request (beyond just a new method) label Oct 26, 2024
@SamDuffield
Copy link
Contributor

Great stuff, and we can see the tests action ran successfully here https://github.com/normal-computing/posteriors/actions/runs/11531612977/job/32102755647?pr=114

@SamDuffield SamDuffield merged commit 30cd0e0 into normal-computing:main Oct 26, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request (beyond just a new method)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants