Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LandsatHlsRaster::findRasters needs to be optimized, remove mutex #430

Closed
elidwa opened this issue Sep 9, 2024 · 2 comments
Closed

LandsatHlsRaster::findRasters needs to be optimized, remove mutex #430

elidwa opened this issue Sep 9, 2024 · 2 comments
Assignees

Comments

@elidwa
Copy link
Contributor

elidwa commented Sep 9, 2024

_findRasters in the base class (GeoIndexedRaster) uses multiple finder threads to search for rasters containing a point. In the Landsat dataset code, an SR dictionary is currently used to store all valid band names ("B09", "B01", etc.). However, access to the dictionary must be guarded by a mutex, which limits the performance of multiple raster finder threads.

There are 15 bands for L8 and 18 for S2, so replacing the dictionary with an std::vector or array will have minimal impact on retrieval time for each band.

TODO: Replace the dictionary of valid bands in LandsatHlsRaster with an std::vector to allow concurrent access by multiple threads without locking, and remove the mutex.

@elidwa elidwa self-assigned this Sep 9, 2024
@jpswinski
Copy link
Member

@elidwa, nominally, reading a dictionary does not need to be guarded by a mutex - only if the dictionary is changing while it is being read (e.g. entries are being added or deleted)

@elidwa
Copy link
Contributor Author

elidwa commented Sep 20, 2024

Fixed this in #433
I replaced SR Dictionary with std::unordered_map<std::string, bool> without changing of what goes into the dictionary/map. Mutex is no longer required. Only main thread created the dictionary and worker threads were reading from it but without mutex code was crashing.

@elidwa elidwa closed this as completed Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants