-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
pytest really slow with python3 on windows #6153
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
Hard to tell, you could try profiling it: https://docs.python.org/3/library/profile.html |
I took a look the old unittests logs coming from Jenkins. It looks like there's the same issue in python27, but it's way more moderated. There it's really hard to see it. So I was wrong: the problem comes out with both python27 and python37 and it probably started from a certain pytest version. Here it is the cProfile output after running unittests on Windows with python3.7.5 and pytest 5.2.
|
Looks suspicious, since there have been changes in that area. |
I'm not sure about that call. I just run pytest disabling cacheprovider plugin with the command:
and this is what I got back from the report (700 seconds less):
|
I also traced the same execution in linux to check if I'm having so many access to the storage memory, but it looks ok:
|
Try with |
Since it only happens after a while it might be related to many entries in the directory, and/or disk filling up? |
I'll give you the next results when I'm back to the workstation. time.sleep is used inside unittests and it's ok |
I explain better how tests are made: unittests are built in 2 different suites. There's one suite written in plain unittest (core library) and a second suite written in pytest, testing my own pytest plugins using pytester. Indeed, my application is a customization of pytest with 17 plugins. The total amount of tests is the following:
I noticed that pytest starts to slow down when switching from plain core library unittests to the pytest plugins tests. So I run suites splitted in 2 different sessions and, in this way, pytest stops into a correct amount of time. All suites run wiith -s option:
The unittest suite:
The pytest plugins suite:
|
Please git-bisect it, which would really be useful to know. |
No, -s is taking the same amount of time as before. I'm running the tests on a laptop now, because my workstation is in another place. When you speak about "git-bisect", you mean to try different pytest versions until I find the one causing the problem, right? |
I downloaded the 5.2.2 source code and tried to run pytest on your unittests.
Well...this is the result:
It looks like it's generally a python problem on windows operating system. Are you testing pytest on windows? Because it looks like the problem is affecting also your unittesting suite. |
Yes, you can start with tags/releases, but in general you would install pytest editable, and then (after verifying that the current commit, e.g. the |
|
Anyway, when pytest starts to slow down, logging messages coming from logging library, as well as the stacktrace at the end of pytest execution, start to slow down, like if there's something in the terminal plugin trying to access data or to write/read somewhere. |
I tried to perform some tests in order to understand what is the problem related with pytest execution. The following list try to focus on potential problems:
So my setup is the following:
All pytest profiling sessions have been executed on pytest unittesting suite, but I didn't see any huge difference between versions in terms of profiling. In all profiling sessions, it looks like pytest is causing lots of calls inside the pytest 3.2.0
pytest 3.9.1
pytest 5.2.2
|
Sorry If I complain about this close, but the bug is not fixed and I still have a difference of 30 minutes (!) between linux pytest executions and windows pytest execution when using python3. |
@acerv it seems that tonight there has been a mishap and way more issues than intended where closed, we are currently looking trough them and reopen them as necessary |
@RonnyPfannschmidt Thanks for your help. I actually found what was the problem related with the tests. Moving from python2 to python3, there is a substantial difference on how multi threading has to be used, in order to avoid issues. According with my implementation, a particular thread was reading from a process stdout without exit, even if I called "join" and also killed the process manually. This was causing some sort of a "slowliness" in all pytest tests, which were printing messages coming from logging module really really slow. I'm not able to reproduce this bug at the moment, because I'm not at work, but I guess it's, first of all, my fault. Thanks for your support anyway and for your great job with pytest. |
@acerv thanks for the follow-up, please post a note when you took a look at the exact issue so we can have this as documentation for others that may face comparable issues |
Thanks @acerv - it sounds like this has been fixed or at least tracked down, so I'm closing the issue. |
Hello everyone,
my application has 320 tests, half created with unittest suite and half created with pytest.
Now I'm currently porting everything to python 3.7.5, so I started to test the application on python3.
The current setup is the following:
python 2.7: pytest 4.6.6
python 3.7: pytest 5.2.1
When it comes to linux, there's no substantial difference between python2.7 and python3.7: unittests complete in 8 minutes.
But when it comes to Windows, I'm having a HUGE difference between the two versions: python2.7 takes 8 minutes to complete unittests, but python3.7 takes exactly 30 minutes.
The point is that, on Windows with python3.7, the first 40% of tests take a normal amount of time, but then it starts to slow down and even really fast tests take forever.
Do you know what it could be?
Thanks,
Andrea
The text was updated successfully, but these errors were encountered: