-
Notifications
You must be signed in to change notification settings - Fork 234
--dist=load runs at most half your tests at once #12
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
Comments
A minimum of 1 pending item per node is needed due to the way setupstate scope caching works Currently its not clear how to properly change that in a backward compatible way |
Can you point me to the caching system you're referring to and/or what goes wrong with this minimum at 1 instead of 2? I may be interested to devote some time to trying to find a solution. |
Actually I think sending a single test item works without a problem, IIRC I have tested this in the past because I faced the same use case, where we had a few slow tests. What @RonnyPfannschmidt is mentioning is actually on the slave side, where each slave will always have at least one test "on queue", until it receives more tests from the master node or a |
I see, this makes sense. In my own tests changing the minimum to 1 (in the line I quoted in my original comment) works fine and gets all tests running simultaneously. I was unsure whether there might be some edge-case feature I'm not using that would be broken by this. |
I think changing the minimum chunk size to @hpk42 @RonnyPfannschmidt @flub, you remember why that minimum is set to |
I see the problem: if I change this minimum to 1 and run with fewer processes than tests, py.test hangs and no tests are ever run. Looking into why. |
Figured this out. It does interact with the slave code @nicoddemus linked, because if we choose a So, a better solution than the current minimum of 2 would be to explicitly handle the case where the number of tests <2x the number of nodes and always distribute all tests in that case. Here's an example of how, which works in my tests:
|
@sah thanks for looking into this. I think you can simplify it though by checking if there are no # how many items per node do we have about?
items_per_node = len(self.collection) // len(self.node2pending)
# take a fraction of tests for initial distribution
- node_chunksize = max(items_per_node // 4, 2)
+ node_chunksize = max(items_per_node // 4, 1)
# and initialize each node with a chunk of tests
for node in self.nodes:
self._send_tests(node, node_chunksize)
+ # initial distribution sent all tests, start node shutdown
+ if not self.pending:
+ for node in self.nodes:
+ node.shutdown() I haven't had time to test this though, it might have some side effects with other parts of the code. I will try to take a deeper look at this tomorrow, but feel free to test this in the meantime if possible. |
I tried something like this. The problem is that because the code picks a quarter of tests for initial distribution and rounds down, it can end up distributing 1 test to every node, but with some tests left over in pending. Then Here's another shot at simplifying (works in my tests):
|
Oh I see, thanks. 😄 Would you mind opening a PR with that? If possible with tests too. |
Tests kicked up a couple cases I needed to handle, so the final change is a little different from the above. I think the test coverage of the behavior is pretty good now. |
Because of this line, which distributes a minimum of two tests to each node: https://github.com/pytest-dev/pytest-xdist/blob/master/xdist/dsession.py#L369
This came as a surprise to me, because this fact is undocumented, and py.test output doesn't make clear that this is happening. For users running slower tests, such as Selenium functional tests, full parallelization is often desirable. Could the minimum be changed to 1, or made configurable?
The text was updated successfully, but these errors were encountered: