-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
TST: Skip tests that use a large amount of memory by default #31007
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
base: main
Are you sure you want to change the base?
Conversation
8b5ae9d to
a3edc5c
Compare
|
Hmm, looking at |
|
I propose to delete The test tries to confirm that visible == False returns early. It does so by creating large data, that should produce a noticable delay when being processed. |
a3edc5c to
548930e
Compare
|
Okay, I removed that test and reduced the memory usage for |
60e2f0c to
7c98478
Compare
|
So it turns out that |
7c98478 to
fddba89
Compare
doc/devel/testing.rst
Outdated
| Some tests may use a large amount of memory (>0.5GiB); to enable those tests, set the | ||
| environment variable ``MPL_TEST_HIGH_MEMORY``. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to generalize to "expensive tests"? This could include runtime as well as memory.
The 14 slowest tests together take 120s.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure we have too many that take long; I guess just the sphinx docs one, maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
============================= slowest 25 durations =============================
10.91s call lib/matplotlib/tests/test_sphinxext.py::test_tinypages
10.24s call lib/matplotlib/tests/test_determinism.py::test_determinism_check[mhip-ps-True]
9.48s call lib/matplotlib/tests/test_determinism.py::test_determinism_check[mhip-pdf-False]
9.25s call lib/matplotlib/tests/test_determinism.py::test_determinism_check[mhip-ps-False]
9.02s call lib/matplotlib/tests/test_determinism.py::test_determinism_check[mhip-svg-False]
9.01s call lib/matplotlib/tests/test_determinism.py::test_determinism_check[mhip-svg-True]
8.51s call lib/matplotlib/tests/test_determinism.py::test_determinism_check[p-svg-False]
8.50s call lib/matplotlib/tests/test_determinism.py::test_determinism_check[i-pdf-False]
8.50s call lib/matplotlib/tests/test_determinism.py::test_determinism_check[h-pdf-False]
8.49s call lib/matplotlib/tests/test_determinism.py::test_determinism_check[m-pdf-False]
8.34s call lib/matplotlib/tests/test_determinism.py::test_determinism_check[-pdf-False]
7.84s call lib/matplotlib/tests/test_sphinxext.py::test_srcset_version
5.32s call lib/matplotlib/tests/test_matplotlib.py::test_importable_with__OO
4.74s call lib/matplotlib/tests/test_backend_pgf.py::test_minus_signs_with_tex[lualatex-pdf]
4.58s call lib/matplotlib/tests/test_subplots.py::test_shared
4.36s call lib/matplotlib/tests/test_streamplot.py::test_integration_options[png]
4.20s call lib/matplotlib/tests/test_sphinxext.py::test_plot_html_show_source_link
4.09s call lib/matplotlib/tests/test_backends_interactive.py::test_interactive_backend[toolbar2-MPLBACKEND=gtk4agg-BACKEND_DEPS=cairo,gi]
3.77s call lib/matplotlib/tests/test_backends_interactive.py::test_interactive_timers[MPLBACKEND=gtk4agg-BACKEND_DEPS=cairo,gi]
3.74s call lib/matplotlib/tests/test_axes.py::test_axes_clear_reference_cycle
3.74s call lib/matplotlib/tests/test_backends_interactive.py::test_interactive_timers[MPLBACKEND=gtk4cairo-BACKEND_DEPS=cairo,gi]
3.59s call lib/matplotlib/tests/test_backends_interactive.py::test_interactive_timers[MPLBACKEND=qtagg-QT_API=PySide6-BACKEND_DEPS=PySide6]
3.59s call lib/matplotlib/tests/test_backends_interactive.py::test_interactive_timers[MPLBACKEND=gtk3agg-BACKEND_DEPS=cairo,gi]
3.56s call lib/matplotlib/tests/test_backends_interactive.py::test_interactive_timers[MPLBACKEND=qtcairo-QT_API=PySide6-BACKEND_DEPS=PySide6,cairocffi]
3.54s call lib/matplotlib/tests/test_backends_interactive.py::test_interactive_timers[MPLBACKEND=wxagg-BACKEND_DEPS=wx]
The determinism ones are also quite significant
By cutting the grid by one-tenth in each dimension, this cuts memory usage from 1.0GiB to 65.2MiB. I temporarily added an assert in `_ImageBase._make_image` to confirm that the interpolation stage did correctly switch to 'rgba' as well.
This test tries to check for slowdowns, which is inherently flaky (as noted by the comment), and we don't check `set_visible` for other artists.
According to memray, these tests use fairly large amounts of memory: - lib/matplotlib/tests/test_simplification.py::test_throw_rendering_complexity_exceeded: 2.2GiB - lib/matplotlib/tests/test_agg.py::test_chunksize_fails: 2.0GiB - lib/matplotlib/tests/test_image.py::test_large_image[png-col-16777216-2\\*\\*24 rows-upper]: 1.0GiB - lib/matplotlib/tests/test_image.py::test_large_image[png-col-16777216-2\\*\\*24 rows-lower]: 1.0GiB - lib/matplotlib/tests/test_image.py::test_large_image[png-row-8388608-2\\*\\*23 columns-lower]: 537.8MiB - lib/matplotlib/tests/test_image.py::test_large_image[png-row-8388608-2\\*\\*23 columns-upper]: 537.8MiB The next closest tests use just 216MiB, then 145.5MiB, etc. and then the majority under 100MiB. If you're unlucky, with 4-way xdist you might use upwards of 6GiB RAM if you get all these on separate processes. The above tests are all fairly low-level checks for Agg renderer limits that are not likely to change often, so skip them by default unless on CI.
fddba89 to
a499ce9
Compare
timhoffm
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technical correct. Is there a specific reason to implement this via a fixture? I would have intuitively expected a mark or skipif decorator. It's a bit unconventional to use a fixture for test selection, they are typically rather for context.
PR summary
According to memray, these tests use fairly large amounts of memory:
lib/matplotlib/tests/test_image.py::test_downsample_interpolation_stage[png]: 1.0GiBlib/matplotlib/tests/test_lines.py::test_invisible_Line_rendering: 822.0MiBThe next closest tests use just 216MiB, then 145.5MiB, etc. and then the majority under 100MiB.
If you're unlucky, with 4-way xdist you might use upwards of 6GiB RAM if you get all these on separate processes.
The above tests are all fairly low-level checks for Agg renderer limits that are not likely to change often, so skip them by default unless on CI.
PR checklist