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
Increased the default value of`async.concurrency` from 10 to 64 to improve parallelism and throughput for concurrent I/O operations. This change enables better performance out-of-the-box for most workloads. Users with specific resource constraints or when using many Dask threads may want to lower this value via the`ZARR_ASYNC_CONCURRENCY` environment variable or by setting`zarr.config.set({'async.concurrency': N})`.
Copy file name to clipboardExpand all lines: docs/release-notes.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@
9
9
- Add a command-line interface to migrate v2 Zarr metadata to v3. Corresponding functions are also provided under zarr.metadata. ([#1798](https://github.com/zarr-developers/zarr-python/issues/1798))
10
10
- Add obstore implementation of delete_dir. ([#3310](https://github.com/zarr-developers/zarr-python/issues/3310))
11
11
- Adds a registry for chunk key encodings for extensibility. This allows users to implement a custom`ChunkKeyEncoding`, which can be registered via`register_chunk_key_encoding` or as an entry point under`zarr.chunk_key_encoding`. ([#3436](https://github.com/zarr-developers/zarr-python/issues/3436))
12
-
- Trying to open a group at a pathwere a array already exists now raises a helpful error. ([#3444](https://github.com/zarr-developers/zarr-python/issues/3444))
12
+
- Trying to open a group at a pathwhere an array already exists now raises a helpful error. ([#3444](https://github.com/zarr-developers/zarr-python/issues/3444))
Copy file name to clipboardExpand all lines: docs/user-guide/performance.md
+78-1Lines changed: 78 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -175,7 +175,84 @@ Coming soon.
175
175
176
176
##Parallel computing and synchronization
177
177
178
-
Coming soon.
178
+
Zarr is designed to support parallel computing and enables concurrent reads and writes to arrays. This section covers how to optimize Zarr's concurrency settings for different parallel computing scenarios.
179
+
180
+
###Concurrent I/O operations
181
+
182
+
Zarr uses asynchronous I/O internally to enable concurrent reads and writes across multiple chunks. The level of concurrency is controlled by the`async.concurrency` configuration setting, which determines the maximum number of concurrent I/O operations.
183
+
184
+
The default value is 64, which provides good performance for most workloads. You can adjust this value based on your specific needs:
185
+
186
+
```python
187
+
import zarr
188
+
189
+
# Set concurrency for the current session
190
+
zarr.config.set({'async.concurrency':128})
191
+
192
+
# Or use environment variable
193
+
# export ZARR_ASYNC_CONCURRENCY=128
194
+
```
195
+
196
+
Higher concurrency values can improve throughput when:
197
+
- Working with remote storage (e.g., S3, GCS) where network latency is high
198
+
- Reading/writing many small chunks in parallel
199
+
- The storage backend can handle many concurrent requests
200
+
201
+
Lower concurrency values may be beneficial when:
202
+
- Working with local storage with limited I/O bandwidth
203
+
- Memory is constrained (each concurrent operation requires buffer space)
204
+
- Using Zarr within a parallel computing framework (see below)
205
+
206
+
###Using Zarr with Dask
207
+
208
+
[Dask](https://www.dask.org/) is a popular parallel computing library that works well with Zarr for processing large arrays. When using Zarr with Dask, it's important to consider the interaction between Dask's thread pool and Zarr's concurrency settings.
209
+
210
+
**Important**: When using many Dask threads, you may need to reduce both Zarr's`async.concurrency` and`threading.max_workers` settings to avoid creating too many concurrent operations. The total number of concurrent I/O operations can be roughly estimated as:
For example, if you're running Dask with 10 threads and Zarr's default concurrency of 64, you could potentially have up to 640 concurrent operations, which may overwhelm your storage system or cause memory issues.
217
+
218
+
**Recommendation**: When using Dask with many threads, configure Zarr's concurrency settings:
219
+
220
+
```python
221
+
import zarr
222
+
import dask.arrayas da
223
+
224
+
# If using Dask with many threads (e.g., 8-16), reduce Zarr's concurrency settings
-`async.concurrency`: Controls the maximum number of concurrent async I/O operations. Start with a lower value (e.g., 4-8) when using many Dask threads.
243
+
-`threading.max_workers`: Controls Zarr's internal thread pool size for blocking operations (defaults to CPU count). Reduce this to avoid thread contention with Dask's scheduler.
244
+
245
+
You may need to experiment with different values to find the optimal balance for your workload. Monitor your system's resource usage and adjust these settings based on whether your storage system or CPU is the bottleneck.
246
+
247
+
###Thread safety and process safety
248
+
249
+
Zarr arrays are designed to be thread-safe for concurrent reads and writes from multiple threads within the same process. However, proper synchronization is required when writing to overlapping regions from multiple threads.
250
+
251
+
For multi-process parallelism, Zarr provides safe concurrent writes as long as:
252
+
- Different processes write to different chunks
253
+
- The storage backend supports atomic writes (most do)
254
+
255
+
When writing to the same chunks from multiple processes, you should use external synchronization mechanisms or ensure that writes are coordinated to avoid race conditions.