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

Speed-up ICP-related tests #574

Closed
rhugonnet opened this issue Aug 29, 2024 · 1 comment · Fixed by #530
Closed

Speed-up ICP-related tests #574

rhugonnet opened this issue Aug 29, 2024 · 1 comment · Fixed by #530
Labels
test-suite Issue related to testing

Comments

@rhugonnet
Copy link
Contributor

Related to #455.
Here's an overview of our test lengths that are longer than 10s:

83.76s call     tests/test_doc.py::TestDocs::test_build
49.62s call     tests/test_coreg/test_base.py::TestAffineManipulation::test_apply_matrix__raster_realdata
41.60s call     tests/test_coreg/test_base.py::TestCoregPipeline::test_pipeline_combinations__nobiasvar[ICP-ICP]
26.23s call     tests/test_coreg/test_base.py::TestCoregClass::test_fit_and_apply[ICP]
22.69s call     tests/test_coreg/test_base.py::TestCoregPipeline::test_pipeline_combinations__nobiasvar[DirectionalBias-ICP]
22.17s call     tests/test_coreg/test_base.py::TestCoregPipeline::test_pipeline_combinations__nobiasvar[ICP-DirectionalBias]
21.69s call     tests/test_coreg/test_base.py::TestCoregPipeline::test_pipeline_combinations__nobiasvar[ICP-NuthKaab]
21.44s call     tests/test_coreg/test_base.py::TestCoregPipeline::test_pipeline_combinations__biasvar[coreg2_init_kwargs1-ICP]
21.43s call     tests/test_coreg/test_base.py::TestCoregPipeline::test_pipeline_combinations__nobiasvar[TerrainBias-ICP]
21.11s call     tests/test_coreg/test_base.py::TestCoregPipeline::test_pipeline_combinations__nobiasvar[NuthKaab-ICP]
21.02s call     tests/test_coreg/test_base.py::TestCoregPipeline::test_pipeline_combinations__nobiasvar[ICP-VerticalShift]
20.97s call     tests/test_coreg/test_base.py::TestCoregPipeline::test_pipeline_combinations__nobiasvar[ICP-TerrainBias]
20.65s call     tests/test_coreg/test_base.py::TestCoregPipeline::test_pipeline_combinations__nobiasvar[VerticalShift-ICP]
20.64s call     tests/test_coreg/test_base.py::TestCoregPipeline::test_pipeline_combinations__nobiasvar[ICP-Deramp]
20.60s call     tests/test_coreg/test_base.py::TestCoregPipeline::test_pipeline_combinations__nobiasvar[Deramp-ICP]
20.55s call     tests/test_coreg/test_base.py::TestCoregPipeline::test_pipeline_combinations__biasvar[coreg2_init_kwargs0-ICP]
17.81s call     tests/test_coreg/test_base.py::TestCoregClass::test_subsample[ICP]
14.05s call     tests/test_coreg/test_affine.py::TestAffineCoreg::test_icp_opencv
11.94s call     tests/test_coreg/test_affine.py::TestAffineCoreg::test_gradientdescending

Almost all of them come from using ICP in a pipeline, or on its own.
We'd save 6min (half of test durations), by finding a way to speed up those. I'll look into it.

@rhugonnet rhugonnet added the test-suite Issue related to testing label Aug 29, 2024
@rhugonnet
Copy link
Contributor Author

OK, so it looks like the slowdown comes largely from the apply() part of ICP, which we already optimized as much as we could in #531. It's unavoidable when applying those transformations step-by-step on such large rasters.

So the best way to address this slow issue for tests is simply to reduce the size of the input rasters, which works well by simply adding some cropping in load_examples():

 # Crop to smaller extents for test speed
  res = reference_dem.res
  crop_geom = (reference_dem.bounds.left, reference_dem.bounds.bottom,
               reference_dem.bounds.left + res[0] * 300, reference_dem.bounds.bottom + res[1] * 300)
  reference_dem = reference_dem.crop(crop_geom)
  to_be_aligned_dem = to_be_aligned_dem.crop(crop_geom)

With this quick fix (which I'm adding in #530), we bring the total test duration of xDEM down from 12min to 5min, and in particular running just the test_coreg folder is now about 4x times faster
@adebardo This should save you time in #563 😉

Further optimizations?
The only main optimization we could add now that we covered re-gridding in #531 would be specific to CoregPipeline: an automated way to detect when the next method in the pipeline accepts point directly, we don't need to apply a transformation to the full raster, but only the point subsample which is much faster. See this old issue on this: #79.

Another little optimization would be to avoid running apply to the last step of a pipeline fit (which is unusued), as pointed in this other old issue that is still relevant: #234. I'll address this in #530.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test-suite Issue related to testing
Projects
None yet
1 participant