Skip to content
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

Tests slowed by > 2x following merge of #167 #199

Closed
cisaacstern opened this issue Sep 2, 2021 · 2 comments · Fixed by #198
Closed

Tests slowed by > 2x following merge of #167 #199

cisaacstern opened this issue Sep 2, 2021 · 2 comments · Fixed by #198

Comments

@cisaacstern
Copy link
Member

cisaacstern commented Sep 2, 2021

Checks for #174 took < 15 mins:
Screen Shot 2021-09-02 at 1 49 33 PM

Checks for #167 took > 30 mins:
Screen Shot 2021-09-02 at 1 53 01 PM

Output of pytest --durations=10 --durations-min=1.0:

========================================= slowest 10 durations ==========================================
5.37s teardown tests/test_utils.py::test_calc_subsets
2.74s call     tests/test_recipes.py::test_chunks[prefect-netCDFtoZarr_recipe-target_chunks6-False-error_expectation6-1-subset_inputs1-netcdf_local_file_pattern_sequential_multi_variable-D]
2.67s setup    tests/test_recipes.py::test_recipe_caching_copying[manual-netCDFtoZarr_http_recipe-True-True-netcdf_http_paths0-netcdf_local_paths_sequential-D]
2.33s call     tests/test_recipes.py::test_chunks[prefect-netCDFtoZarr_recipe-target_chunks6-False-error_expectation6-1-subset_inputs0-netcdf_local_file_pattern_sequential_multi_variable-D]
2.28s setup    tests/test_fixtures.py::test_fixture_http_files[netcdf_http_paths1-netcdf_local_paths_sequential_multi_variable-D]
2.28s setup    tests/test_fixtures.py::test_fixture_http_files[netcdf_http_paths2-netcdf_local_paths_sequential_multi_variable-D]
2.25s call     tests/test_recipes.py::test_chunks[prefect-netCDFtoZarr_recipe-target_chunks5-False-error_expectation5-1-subset_inputs0-netcdf_local_file_pattern_sequential_multi_variable-D]
2.25s setup    tests/test_fixtures.py::test_fixture_http_files[netcdf_http_paths0-netcdf_local_paths_sequential_multi_variable-D]
2.23s call     tests/test_recipes.py::test_chunks[prefect-netCDFtoZarr_recipe-target_chunks5-False-error_expectation5-1-subset_inputs1-netcdf_local_file_pattern_sequential_multi_variable-D]
2.17s setup    tests/test_fixtures.py::test_fixture_http_files[netcdf_http_paths2-netcdf_local_paths_sequential-D]

Setup for tests/test_fixtures.py::test_fixture_http_files is obviously time-consuming, but there are only 8 total tests run from test_fixtures.py and they cumulatively take < 30 seconds to run:

$ pytest test_fixtures.py
Results (28.12s):
       8 passed
       8 skipped

The slow tests/test_recipes.py::test_chunks calls are of greater interest, because with current fixturing, that test gets called a lot, as shown by the output of python parametrization_counter.py details plot:
test_counts

@cisaacstern
Copy link
Member Author

30 slowest tests within test_recipes.py:

===================================================== slowest 30 durations =====================================================
5.38s teardown tests/test_recipes.py::test_base_recipe
2.31s setup    tests/test_recipes.py::test_recipe_caching_copying[manual-netCDFtoZarr_http_recipe-True-True-netcdf_http_paths0-netcdf_local_paths_sequential_multi_variable-D]
2.30s setup    tests/test_recipes.py::test_recipe_caching_copying[manual-netCDFtoZarr_http_recipe-True-True-netcdf_http_paths1-netcdf_local_paths_sequential_multi_variable-D]
2.30s setup    tests/test_recipes.py::test_recipe_caching_copying[manual-netCDFtoZarr_http_recipe-True-True-netcdf_http_paths2-netcdf_local_paths_sequential_multi_variable-D]
2.25s setup    tests/test_recipes.py::test_recipe_caching_copying[manual-netCDFtoZarr_http_recipe-True-True-netcdf_http_paths0-netcdf_local_paths_sequential-D]
2.22s setup    tests/test_recipes.py::test_recipe_caching_copying[manual-netCDFtoZarr_http_recipe-True-True-netcdf_http_paths2-netcdf_local_paths_sequential-D]
2.22s setup    tests/test_recipes.py::test_recipe_caching_copying[manual-netCDFtoZarr_http_recipe-True-True-netcdf_http_paths1-netcdf_local_paths_sequential-D]
2.21s call     tests/test_recipes.py::test_chunks[prefect-netCDFtoZarr_recipe-target_chunks5-False-error_expectation5-1-subset_inputs0-netcdf_local_file_pattern_sequential_multi_variable-D]
2.18s call     tests/test_recipes.py::test_chunks[prefect-netCDFtoZarr_recipe-target_chunks6-False-error_expectation6-1-subset_inputs0-netcdf_local_file_pattern_sequential_multi_variable-D]
2.18s setup    tests/test_recipes.py::test_recipe_caching_copying[manual-netCDFtoZarr_http_recipe-True-True-netcdf_http_paths2-netcdf_local_paths_sequential_multi_variable-2D]
2.18s setup    tests/test_recipes.py::test_recipe_caching_copying[manual-netCDFtoZarr_http_recipe-True-True-netcdf_http_paths1-netcdf_local_paths_sequential_multi_variable-2D]
2.18s setup    tests/test_recipes.py::test_recipe_caching_copying[manual-netCDFtoZarr_http_recipe-True-True-netcdf_http_paths0-netcdf_local_paths_sequential_multi_variable-2D]
2.15s call     tests/test_recipes.py::test_chunks[prefect-netCDFtoZarr_recipe-target_chunks5-False-error_expectation5-1-subset_inputs1-netcdf_local_file_pattern_sequential_multi_variable-D]
2.14s setup    tests/test_recipes.py::test_recipe_caching_copying[manual-netCDFtoZarr_http_recipe-True-True-netcdf_http_paths2-netcdf_local_paths_sequential-2D]
2.14s setup    tests/test_recipes.py::test_recipe_caching_copying[manual-netCDFtoZarr_http_recipe-True-True-netcdf_http_paths1-netcdf_local_paths_sequential-2D]
2.14s call     tests/test_recipes.py::test_chunks[prefect-netCDFtoZarr_recipe-target_chunks6-False-error_expectation6-1-subset_inputs1-netcdf_local_file_pattern_sequential_multi_variable-D]
2.11s call     tests/test_recipes.py::test_recipe_caching_copying[prefect-netCDFtoZarr_http_recipe-True-True-netcdf_http_paths0-netcdf_local_paths_sequential_multi_variable-D]
2.06s setup    tests/test_recipes.py::test_recipe_caching_copying[prefect-dask-netCDFtoZarr_http_recipe-False-False-netcdf_http_paths0-netcdf_local_paths_sequential-2D]
2.06s setup    tests/test_recipes.py::test_recipe_caching_copying[prefect-netCDFtoZarr_http_recipe-True-False-netcdf_http_paths2-netcdf_local_paths_sequential_multi_variable-D]
2.06s setup    tests/test_recipes.py::test_recipe_caching_copying[prefect-netCDFtoZarr_http_recipe-False-False-netcdf_http_paths2-netcdf_local_paths_sequential_multi_variable-2D]
2.06s setup    tests/test_recipes.py::test_recipe_caching_copying[dask-netCDFtoZarr_http_recipe-False-True-netcdf_http_paths2-netcdf_local_paths_sequential-2D]
2.05s setup    tests/test_recipes.py::test_recipe_caching_copying[prefect-dask-netCDFtoZarr_http_recipe-False-True-netcdf_http_paths2-netcdf_local_paths_sequential-D]
2.05s setup    tests/test_recipes.py::test_recipe_caching_copying[dask-netCDFtoZarr_http_recipe-True-True-netcdf_http_paths2-netcdf_local_paths_sequential-D]
2.05s setup    tests/test_recipes.py::test_recipe_caching_copying[dask-netCDFtoZarr_http_recipe-True-True-netcdf_http_paths2-netcdf_local_paths_sequential-2D]
2.05s setup    tests/test_recipes.py::test_recipe_caching_copying[python-netCDFtoZarr_http_recipe-True-False-netcdf_http_paths0-netcdf_local_paths_sequential_multi_variable-D]
2.05s setup    tests/test_recipes.py::test_recipe_caching_copying[prefect-netCDFtoZarr_http_recipe-False-True-netcdf_http_paths2-netcdf_local_paths_sequential-2D]
2.05s setup    tests/test_recipes.py::test_recipe_caching_copying[prefect-netCDFtoZarr_http_recipe-False-True-netcdf_http_paths0-netcdf_local_paths_sequential-D]
2.05s setup    tests/test_recipes.py::test_recipe_caching_copying[prefect-netCDFtoZarr_http_recipe-False-False-netcdf_http_paths2-netcdf_local_paths_sequential_multi_variable-D]
2.05s setup    tests/test_recipes.py::test_recipe_caching_copying[prefect-netCDFtoZarr_http_recipe-True-False-netcdf_http_paths1-netcdf_local_paths_sequential_multi_variable-D]
2.05s setup    tests/test_recipes.py::test_recipe_caching_copying[dask-netCDFtoZarr_http_recipe-False-False-netcdf_http_paths2-netcdf_local_paths_sequential-D]

@cisaacstern
Copy link
Member Author

I believe the path forward on this is, for tests that are just about moving files around, to use the sequential file paths only.

For tests/test_storage.py::test_file_opener, here's where we currently stand on timing and test count

In master

$ pytest test_storage.py -k test_file_opener
Results (40.38s):
     384 passed
       3 deselected

And with 3039955

$ pytest test_storage.py -k test_file_opener
Results (21.90s):
     192 passed

Will implement this for file pattern fixtures and test_recipes.py::test_recipe_caching_copying next

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant