Engage parallel tile decode for default tile_size=256#1557
Merged
Conversation
The gate in `_read_tiles` used a strict ``tile_pixels > 64 * 1024`` comparison. At the default tile_size=256 that product is exactly 64*1024, so the strict inequality fell short by one pixel and the sequential path ran for the most common configuration. Switching to ``>=`` lands the default tile size on the parallel path. For 1024x1024 deflate-compressed reads at the default tile size this is a ~3.5x speedup; at 4096x4096 it is ~5.3x.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes the parallel tile decode dispatch threshold in the GeoTIFF CPU reader so the default tile_size=256 (exactly 64 * 1024 pixels) uses the parallel decode path, addressing issue #1551 and improving decode performance for common tiled GeoTIFFs.
Changes:
- Change
_read_tilesparallel-dispatch threshold fromtile_pixels > 64 * 1024totile_pixels >= 64 * 1024. - Add regression tests asserting parallel dispatch engages at
tile_size=256, and remains sequential below threshold or when only a single tile job exists. - Expand the inline comment in
_read_tilesto document the inclusive boundary and the rationale (issue #1551).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
xrspatial/geotiff/_reader.py |
Adjusts the parallel decode gating condition to include the default 256×256 tile size and documents the rationale. |
xrspatial/geotiff/tests/test_parallel_decode_default_tile_1551.py |
Adds regression coverage verifying dispatch behavior at the threshold boundary and for sequential-only cases. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
Fixes #1551. Changes
tile_pixels > 64 * 1024totile_pixels >= 64 * 1024in_read_tiles, so the defaulttile_size=256(256 * 256 = 65536 = exactly 64 * 1024) lands on the parallel decode path instead of falling one pixel short.Found during a 2026-05-09 efficiency audit pass over the geotiff module.
Benchmark
1024x1024 raster at default
tile_size=256(16 tiles), DEFLATE-compressed:>)>=)Larger grids scale further: 4.3x at 2048x2048, 5.3x at 4096x4096.
Test plan
test_parallel_decode_default_tile_1551.pywith three cases:test_features.py::TestPaletteare unrelated and reproduce on main)monkeypatch.setattronconcurrent.futures.ThreadPoolExecutorwith no shared state, so pytest-xdist runs are safe