Batch elevation tile downloads to avoid stalling on large bboxes#1060
Open
TonyD365 wants to merge 3 commits into
Open
Batch elevation tile downloads to avoid stalling on large bboxes#1060TonyD365 wants to merge 3 commits into
TonyD365 wants to merge 3 commits into
Conversation
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.
Problem
When generating a large bbox in a USGS 3DEP-covered area, the elevation
step (
[3/7] Fetching elevation) can stall for a very long time in aflood of retries.
For example, a Greater Toronto Area bbox at 1 m resolution enumerates
6231 fixed-grid tiles (67 × 93 at level r1). The current downloader
fires all of them through a single
par_iter()at a fixed concurrency(
MAX_CONCURRENT_DOWNLOADS = 4). The sustained pressure trips ratelimiting on the USGS ArcGIS ImageServer, and the run fills the console
with:
Change
This PR paces the tile downloads in
fetch_fixed_tile_grid(
src/elevation/providers/fixed_tile.rs): tiles are downloaded inbatches with a short pause between batches, giving strict upstreams
(USGS ArcGIS) room to breathe instead of being hammered continuously.
Three new
FixedTileProviderassociated constants make this tunableper-provider (and a no-op when disabled):
DOWNLOAD_BATCH_SIZE(default 256;0disables batching)BATCH_PAUSE_MS(default 1000)The pause is applied only between batches — never before the first
or after the last — and only when batching is enabled.
Why this is safe
Batching changes only when requests are issued, not what is
fetched:
fetch_tile_raster(the
cache_path.exists()check infetch_or_cache), so a re-runwith a warm cache is unaffected.
(TileKey, Result)pairs collected is identical to theprevious single-pass
par_iter()— same keys, same Ok/Err values —so the downstream
tile_cachebuild, AWS Terrarium fallback, andbilinear sampling are untouched.
Testing
cargo build/cargo testpass locally.fixed_tileunit tests(
covering_tiles_matches_expected_rectangle,level_selection_follows_cell_size, etc.) still pass.progresses in batches (
downloading tile batch N/M (...)) instead ofstalling.
Notes / open questions
very large 1 m bboxes the elevation step is still lengthy; a
follow-up could add a per-request tile budget that steps down to a
coarser resolution level when the covering-tile count is excessive.
Happy to split that into a separate PR if useful.
DOWNLOAD_BATCH_SIZE/BATCH_PAUSE_MSdefaults are conservative;open to tuning them based on what the maintainers consider polite to
the upstream services.