You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* geotiff: parallelize strip writer and add optional libdeflate backend (#1800)
The deflate strip-write path was 3.7x slower than rioxarray/GDAL because
`_write_stripped` ran zlib.compress serially while the tile writer
already parallelized via a thread pool. Three changes:
1. Mirror `_write_tiled`'s ThreadPoolExecutor pattern in
`_write_stripped`. Strip preparation is hoisted into a new
`_prepare_strip` helper so the same code drives both the serial and
parallel paths. A 2048x2048 deflate strip write drops from 405 ms to
70 ms (5.8x speedup, beats rioxarray's 102 ms).
2. Replace the tile writer's `n_tiles <= 4` sequential cutoff with a
bytes-based threshold (`_PARALLEL_MIN_BYTES = 4 MiB`). Pre-fix,
`tile_size=1024` on a 2048x2048 image produced n_tiles=4 and forced
the slow path; now those writes parallelize too.
3. Route `deflate_compress` through the optional `libdeflate` package
when installed (1.5-2x faster than stdlib zlib at the same level;
GDAL >= 3.7 already uses it). Output is wire-compatible -- decoded
streams round-trip through `zlib.decompress` unchanged. Compressors
are cached per thread via `threading.local`.
* geotiff: harden thread-local cache test against pool scheduling (#1800)
PR #1801's review flagged that
`test_libdeflate_compressor_cache_is_thread_local` could pass with a
single observed cache id: `ThreadPoolExecutor(max_workers=2).map(...)`
is free to run both submissions on the same worker if the first
returns quickly. Force both tasks to occupy a worker at the same time
with a `threading.Barrier`, record `threading.get_ident()` so the
assertion fails loudly if only one thread actually ran, and use the
executor as a context manager so the pool is shut down on assertion
failure.
0 commit comments