Skip to content

Performance improvements#1

Open
yaredwb wants to merge 11 commits intocgodoyle:mainfrom
yaredwb:clean-performance-improvements
Open

Performance improvements#1
yaredwb wants to merge 11 commits intocgodoyle:mainfrom
yaredwb:clean-performance-improvements

Conversation

@yaredwb
Copy link

@yaredwb yaredwb commented Dec 5, 2025

Summary
This PR contains significant performance improvements for the landslide retrogression algorithm:

  • Algorithm optimization: Refactored the retrogression algorithm for improved efficiency
  • Parallelization: Added parallel processing support with adaptive strategies for better performance on multi-core systems

The PR also contains some additional folders which can be deleted later before merging with the main branch. The additional folders are:

  • data/: Added test/sample data files
  • scripts/: Added scripts for performance comparison and testing
  • output/: Contains comparison results (can be deleted before merging with main)

Important Note
For now, it is better to accept this pull request in a new branch until you get a full sense of the changes and their impact. Instead of merging to main, you can pull this into a new branch by running:

git fetch https://github.com/yaredwb/losneomrade.git clean-performance-improvements:clean-performance-improvements
git push origin clean-performance-improvements

Then you can close this PR.

Core Improvements:
- Terrain Criteria: Implemented chunked slope calculation (utils.compute_slope_chunked) to resolve memory explosion issues with large point datasets.
- Retrogression Analysis:
  - Implemented BFS optimization in landslide_retrogression for improved serial performance.
  - Added run_retrogression_parallel_grouped to handle interacting landslides correctly during parallel processing.
  - Added run_retrogression_parallel_adaptive to automatically select the best strategy (speed vs. accuracy).
  - Fixed buffer size issues in parallel cropping to ensure full landslide propagation.

Refactoring & Docs:
- Grouped parallel functions in retrogression.py and updated docstrings.
- Consolidated performance findings into docs/PERFORMANCE_FINDINGS.md with neutral tone.
- Removed obsolete documentation and READMEs.

Verification:
- Added scripts/run_and_compare_retrogression.py for verification.
- Verified changes showing 0.0% difference from baseline.
… comparison script

- Separated landslide_retrogression into landslide_retrogression_original and landslide_retrogression_optimized in src/losneomrade/retrogression.py.
- Added scripts/compare_serial_performance.py to benchmark serial execution performance and accuracy.
- Added plotly dependency to pyproject.toml.
- Updated docs/RETROGRESSION_ALGORITHM_DETAILS.md to explain numerical precision differences causing minor area discrepancies.
- Added scripts/compare_serial_vs_parallel_adaptive.py to benchmark Serial Optimized vs Parallel Adaptive (Speed) modes.
- Fixed NameError in src/losneomrade/retrogression.py by correcting the function call in _process_group.
- Updated docs/PERFORMANCE_FINDINGS.md to explain area differences in Parallel Speed mode due to aggressive cropping and reflected recent code changes.
- Updated docs/RETROGRESSION_ALGORITHM_DETAILS.md to explain numerical precision differences causing minor area discrepancies.
… data

- Deleted `generate_parallel_figures_v2.py` which contained functions for generating parallel figures related to retrogression analysis.
- Removed `plot_benchmark_data.py` which was responsible for visualizing benchmark data from DEM and stream files.
- Eliminated `plot_performance_metrics.py` that plotted performance metrics from CSV files comparing original and optimized methods.
- Deleted `run_and_compare_retrogression.py`, a script that executed retrogression analysis and compared results between serial and adaptive methods.
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 this pull request may close these issues.

1 participant