feat: Add parallel block reads for improved COG performance#845
feat: Add parallel block reads for improved COG performance#845YajJackson wants to merge 1 commit into
Conversation
Add max_workers parameter to read() and part() functions to enable parallel reading of internal COG blocks. When a read window spans multiple internal blocks and max_workers > 1, blocks are read in parallel using ThreadPoolExecutor with separate dataset connections per thread (rasterio datasets are not thread-safe). parallel read is automatically used when: - max_workers is set and > 1 - The window spans multiple internal COG blocks - No resampling is needed (height/width not specified) - Source is a DatasetReader (not a VRT)
|
This is quite an interesting change. To me it feels that something that GDAL should do for us |
Indeed this is definitely a workaround. Feel free to close this or if you'd like to move forward, I'll fix CI issues |
|
I've tried to replicate the performance and it seems variables. Especially that GDAL has some limitation to reduce GET requests and with this branch, you're basically pass by this optimization, doing one GET request per block using 👇 Note: I did get better performance for some run but it's not consistent. Another comment, is that this optimization will only work for the highest resolution not for the overviews (which are not materialized within rasterio's dataset) |
This work spawned from inefficiencies discovered when comparing internal tile-based cog access patterns where reading less data via
part()orfeature()would take nearly 6x as much time as concurrently requesting individual tiles.Add
max_workersparameter toread()andpart()functions to enable parallel reading of internal COG blocks. When a read window spans multiple internal blocks and max_workers > 1, blocks are read in parallel using ThreadPoolExecutor with separate dataset connections per thread (rasterio datasets are not thread-safe).parallel read is automatically used when:
cc @bscholer