The latest release of zarr (2.14.0) includes experimental support for sharding, along with a number of other features from the v3 spec.
Previous zarr specs stored one chunk per storage object. This can be problematic for zarr stores with a large number of chunks due to design constraints of the underlying storage (e.g. inode limits). Sharding allows storing multiple chunks in one storage object.
Full zarr v3 spec here
Details on zarr sharding here
1 Like
Aidan
(Aidan Heerdegen, ACCESS-NRI Release Team Lead)
2
In practice are there recommended minimum sizes for storage objects in S3 buckets? Or put another way, maximum number of objects per bucket?
I can see the utility of reducing the inode count on lustre file systems, but I thought the current work-around for this was to compress the whole zarr directory tree? I suppose that gets problematic for extremely large datasets? Are there are any other reasons to favour sharding over compressing the whole zarr directory structure?
It is great that this functionality now exists, but I can now see a similar issue arising for zarr that weāve had for a long time with netCDF: aligning read/write chunk size to object size on disk. Not a deal breaker, but a subtlety that often needs to be taken into account.
My understanding is that there is no limit to the number of objects you can store in a bucket, but latency overheads still can be problematic for large numbers of small objects.
Yes, Iāve zipped some pretty large zarr stores (order 10s TB), but it doesnāt feel like an ideal work-around:
zarr.ZipStores are not safe to write in multiple processes and thereās no way to update an existing zip file without unzipping and rezipping. Zipping/unzipping can take a really long time for large stores.
Iāve hit hard limits on file size on some systems.
Dividing a dataset across multiple ZipStores helps with the above, but this can be a pain to manage and Iāve experienced unexplained performance issues doing this (newer versions of dask may be better).
Yes, though from my skim through the specs Iām not sure how this issue has changed for zarr with the introduction of sharding. My (ignorant) understanding is that read/write will still occur at the chunk level.
A bit late this this thread but I have some huge zarr stores that Iāve had good success converting to sharded Zarr V3 stores to significantly reduce inode usage. However since the hh5/xp65 analysis envs use V2 these V3 stores are not usable for the wider community.
Iāve gotten sharding to work really well with Zarr V3 but I have to use my own conda env to have this version of Zarr as the hh5/xp65 conda envs only have Zarr V2.18.3. Is there any reason why the Zarr package hasnāt been updated to Zarr V3 as it has some nice upgrades from V2?
@dougiesquire did you ever manage to get this experimental support for sharding in V2 to work? Iām trying to use:
import os
os.environ["ZARR_V3_SHARDING"] = "1"
from zarr._storage.v3_storage_transformers import ShardingStorageTransformer
but I canāt get it to recognise that Iāve enabled "ZARR_V3_SHARDING".
I was looking into this. Intake-ESM is blocking the upgrade to Zarr v3.0. @CharlesTurner is the maintainer of the package. Charles, could you look into this and see if we can safely move to Zarr v3.0?
It would be great to upgrade to Zarr v3 but I understand if it takes a while to make intake-esm v2025.2.3 compatible. Let me know if thereās anything I can do.
I suspect it can be done - looks like some major progress was made here, but itās just a case of me getting a few days to sit down and really wrap my head around the changes and how they affect intake-esm.
Tentatively, Iām going to say that unless I get some unexpected time to work on this or it turns out to be easier than I thought, Iāll aim to get it cracked in spring.
It appears that some updated have been made to some relevant dependencies in the meantime - Iām guessing the zarr v3.1 release (I havenāt checked yet) & I think weāll be able to unpin zarr v2 in intake-esm sooner rather than later.
Sorry I didnāt get a notification that you replied to this thread, just seen your 2 messages now. No problem on the length of time, I understand that dependancies can be problematic. Thanks for keeping this in your to-do list!
No worries - the fix has been merged into main on intake-esm now. Just waiting on one more PR to go in and Iāll trigger a new release, at which point weāll be able to upgrade zarr.
Hopefully this should be within the next week or two.