LoadScope scheduler: Sort scopes by number of tests to assign biggest scopes first#778
Conversation
That is exactly what I do in the "more sophisticated" approach I was talking about in the original PR. We sort scopes by previous runtime and then distribute among xdist workers according to this data. But I think it will be hard to get something like this into xdist because it depends a lot on your environment. In an ideal world xdist should provide an official extension mechanism which lets you hook in your own code easily, similar to how pytest itself is extensible. We had to do a huge monkey patch to get this done but the actual custom code is <50 lines. FYI be careful with the CircleCI test splitter, my experience is that it doesn't correctly take timings into account even though it says so. |
nicoddemus
left a comment
There was a problem hiding this comment.
Thanks @cryvate and @joekohlsdorf for the contribution. 👍
I will make a new release once this is merged.
113a197 to
7bd858e
Compare
|
Thanks @nicoddemus! |
…v/pytest-xdist#778, even if at first this appear to be unrelated (we use `loadfile` and not `loadscope`)
…v/pytest-xdist#778, even if at first this appear to be unrelated (we use `loadfile` and not `loadscope`)
…v/pytest-xdist#778, even if at first this appear to be unrelated (we use `loadfile` and not `loadscope`)
…v/pytest-xdist#778, even if at first this appear to be unrelated (we use `loadfile` and not `loadscope`)
Based upon this PR/branch, OP text quoted here:
I have one reservation about this change and backwards compatibility when we have
test_a.pyandtest_b.py:test_b.pyis run before any tests fromtest_a.pyin any runnertest_b.pymight run before any tests fromtest_a.pyin a runner (iftest_b.pycontains more tests)I don't know what the general
pytest(-plugin)'s view andpytest-xdist's view in particular is on backwards compatibility in the face of, essentially, flaky/broken tests.Long term I wonder whether we would want to expose the ordering of this queue somehow: it would be cool when e.g. running in CircleCI (which can seed based on previous running times) to be able to repeat the same within the runners, especially as they could have many cores/parallel runners and so there can be inefficiencies.