feat!: store-defined concurrency limits#3547
Conversation
…v-b/zarr-python into feat/global-concurrency-limit
|
Nice, the other one that bugs me when profiling is zarr-python/src/zarr/codecs/zstd.py Line 79 in b3e9aed |
…at/global-concurrency-limit
|
@d-v-b do you have thoughts on how downstream libraries would interact with Zarr's concurrency limit? Would those set there own concurrency approaches (e.g., global or per function) or could there be a way to share the limit with Zarr? |
|
@maxrjones this PR is moving away from a global concurrency limit because it's actually very hard to implement a top-down concurrency control in our codebase. the new direction I'm taking with this PR is for each store to set its own concurrency limit. for stateless stores like local and remote (basically anything except zip), concurrency-sensitive applications should be able to cheaply create store instances with concurrency limits tuned to the needs of the application. |
…at/global-concurrency-limit
…at/global-concurrency-limit
|
this is ready for a look. The basic idea is that we make concurrency limits an implementation detail of a particular store and thereby remove all concurrency limiting logic from array / group routines. Some stores will have no concurrency limits (e.g., memory and local storage) and so their performance will go up. Stores that actually benefit from a concurrency limit (remote stuff) has the default limit of 10 but that's something we can play with. To cut down on boilerplate we (claude and I) define a |
…at/global-concurrency-limit
|
quick check: are there any storage backends where we need a concurrency limit defined in zarr-python? I'm wondering if this PR should actually just be removing any reference to concurrency limits, since this seems to be a storage backend concern. |
edit: this PR has now improved since its initial submission. Here are the key changes:
async.concurrencyis gone from the global config, using this setting triggers a warning.concurrent_mapis gone.asyncio.gatheris used instead, because concurrency limits are now the store's concern.ConcurrencyLimitermixin adds a semaphore-based concurrency limit via a decoratorLocalStoreandMemoryStorehave no concurrency limits. This results in a large performance improvement.FSSpecStoreandObjectStorehave a default concurrency of 50.