-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
pytest 5.3.3 much slower than 5.3.2 #6494
Comments
Related to #6492 (pytest-django). |
Thanks @frederic-peters! I'm closing this as duplicate of #6492 then, seems they are the same problem. |
@frederic-peters please subscribe to #6492 to track the progress of this problem; we're still trying to figure out if the problem is in pytest or pytest-django. |
@frederic-peters that change shouldn't impact I'm assuming the list you found was the one produced by I'm guessing you're doing some parameterization because the only fixture you're requesting is the When you have parameterized fixtures, only the fixtures that execute after the parameterized fixture will actually be affected by it (unless parameterization happens at the function scope level). However, fixtures can have a non-deterministic place in this linearized order if they don't request other fixtures or other fixtures don't request them. It's basically a set of rules where each fixture says "I have to come after these fixtures". But without a fixture requesting other fixtures, or other fixtures requesting it, there's nothing tying it to a place in that linearized order. Because of this, I'm guessing that, while the linearized order didn't technically change, pytest's awareness of what needs to be torn down when has been fixed, so now some of your fixtures are tearing down and being rebuilt where they weren't previously. In other words, if you ran For a fix, I would leverage this linearization logic to figure out where exactly you want to insert your parameterization and then have fixtures request what's necessary to position your paremeterized fixture exactly where you want. |
Actually the setup-plan output has the same length, with just a little bit of ordering difference. However I switched my local tests from sqlite to postgresql to have detailed database logs and noticed the database was now being created and dropped for each test, while it was previously being reused (even without using --reuse-db from pytest-django). Running a subset of tests (19 individual tests using the database):
So yeah probably pytest was not previously tearing down the database properly, while it now is. |
@frederic-peters Can you provide a diff of the setup-plans? |
@blueyed I am not using transactional_db at all. diff of setup-plans, 5.3.2 vs 5.3.3 (curiously it had more differences yesterday, but probably I got confused between versions as I ran many checks, this one is double checked): @@ -1,5 +1,5 @@
============================= test session starts ==============================
-platform linux -- Python 3.7.2rc1, pytest-5.3.2, py-1.8.0, pluggy-0.13.0 -- /home/fred/src/eo/venv3/bin/python3
+platform linux -- Python 3.7.2rc1, pytest-5.3.3, py-1.8.0, pluggy-0.13.0 -- /home/fred/src/eo/venv3/bin/python3
cachedir: .pytest_cache
django: settings: combo.settings (from env)
rootdir: /home/fred/src/eo/combo
@@ -52,13 +52,13 @@
TEARDOWN F _dj_autoclear_mailbox
TEARDOWN C _django_setup_unittest
tests/test_calendar.py::test_cell_rendering[anonymous]
-SETUP S django_db_use_migrations
-SETUP S django_db_keepdb
SETUP S django_db_createdb
-SETUP S django_db_modify_db_settings_tox_suffix
SETUP S django_db_modify_db_settings_xdist_suffix
+SETUP S django_db_modify_db_settings_tox_suffix
SETUP S django_db_modify_db_settings_parallel_suffix (fixtures used: django_db_modify_db_settings_tox_suffix, django_db_modify_db_settings_xdist_suffix)
SETUP S django_db_modify_db_settings (fixtures used: django_db_modify_db_settings_parallel_suffix)
+SETUP S django_db_use_migrations
+SETUP S django_db_keepdb
SETUP S django_db_setup (fixtures used: django_db_blocker, django_db_createdb, django_db_keepdb, django_db_modify_db_settings, django_db_use_migrations, django_test_environment)
SETUP C _django_setup_unittest (fixtures used: django_db_blocker)
SETUP F _dj_autoclear_mailbox
@@ -6888,16 +6888,16 @@
TEARDOWN F _dj_autoclear_mailbox
TEARDOWN C _django_setup_unittest
TEARDOWN S django_db_setup
-TEARDOWN S django_db_blocker
-TEARDOWN S django_test_environment
-TEARDOWN S _fail_for_invalid_template_variable
+TEARDOWN S django_db_keepdb
+TEARDOWN S django_db_use_migrations
TEARDOWN S django_db_modify_db_settings
TEARDOWN S django_db_modify_db_settings_parallel_suffix
-TEARDOWN S django_db_modify_db_settings_xdist_suffix
TEARDOWN S django_db_modify_db_settings_tox_suffix
+TEARDOWN S django_db_modify_db_settings_xdist_suffix
TEARDOWN S django_db_createdb
-TEARDOWN S django_db_keepdb
-TEARDOWN S django_db_use_migrations
+TEARDOWN S django_db_blocker
+TEARDOWN S django_test_environment
+TEARDOWN S _fail_for_invalid_template_variable
Hope it helps, |
Hi,
An internal CI job started getting aborted due to timeouts, the only change in installed modules version was pytest. I reproduced the issue locally (a 10× slowdown) and bisected it to
I also switched back to master to revert that single commit and that was also ok.
Looking at the change, code was previously running with self.argnames == ['request'], after the change it is now computing its list of fixtures as {'_django_clear_site_cache', 'django_db_blocker', 'django_test_environment', '_fail_for_invalid_template_variable', '_dj_autoclear_mailbox', 'request', '_django_setup_unittest'} and this obviously make the tests slower.
plugins: django-3.8.0, localserver-0.5.0, freezegun-0.3.0.post1, django-webtest-1.9.7
The text was updated successfully, but these errors were encountered: