Performance: major runtime optimizations for parallel simulation, spatial joins, raster covariates, and result aggregation PR Description#100
Open
hambrecht wants to merge 6 commits into
Conversation
- add cov.surface support to Detectability and make.detectability - apply raster covariates in calculate.scale.param - validate cov.surface in simulation checks - add raster covariate test coverage - update related simulation/covariate paths used by tests
Update Detectability plot validation so covariates supplied via cov.surface are treated as valid even when absent from population covariates. Add raster-specific plotting path that reads surface values and uses raster quantiles to generate representative detection curves, enabling mixed covariate plotting (for example size + canopy) without false missing-covariate errors.
- initialize worker state once per cluster - dispatch only repetition indices to workers - replace static scheduling with parLapplyLB for better core utilization - remove repeated heavy argument passing in parallel loop
- replace per-transect st_intersection loops with one st_join - compute line/point distances in vectorized st_distance calls - remove iterative reduce/rbind assembly path for possible detections
- cache raster handles/value vectors in a process-local runtime cache - avoid re-reading raster files and full value vectors every repetition - keep cache lookup keyed by file path (or raster footprint for in-memory surfaces)
…objects - add extract/apply helpers for compact per-repetition result slices - return rep-level payloads from single.sim.loop - aggregate serial/parallel outputs without full-object round-trips - keep backward-compatible accumulator path for legacy result shapes - fix in-memory raster cache key generation for SpatRaster extents
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces four major performance changes to the simulation pipeline, each isolated in its own commit.
The goal is to reduce wall-clock time, improve CPU utilization, and lower memory/serialization overhead for large runs.
What Changed
run.simulation.Rcalc.perp.dists.Rcalc.rad.dists.Rcalculate.scale.param.Rsingle.sim.loop.Raccumulate.PP.results.Rrun.simulation.RExpected Runtime Impact
Validation
test-check_RasterCovariate.RCommit Structure