Expand description
Chunk caching.
zarrs supports three types of chunk caches:
ChunkCacheTypeDecoded: caches decoded chunks.- Preferred where decoding is expensive and memory is abundant.
ChunkCacheTypeEncoded: caches encoded chunks.- Preferred where decoding is cheap and memory is scarce, provided that data is well compressed/sparse.
ChunkCacheTypePartialDecoder: caches partial decoders.- Preferred where chunks are repeatedly partially retrieved.
- Useful for retrieval of subchunks from sharded arrays, as the partial decoder caches shard indexes (but not subchunks).
- Memory usage of this cache is highly dependent on the array codecs and whether the codec chain (
Array::codecs) ends up decoding entire chunks or caching inputs based on theirPartialDecoderCapability.
zarrs implements the following Least Recently Used (LRU) chunk caches:
ChunkCacheDecodedLruChunkLimit: a decoded chunk cache with a fixed chunk capacity..ChunkCacheDecodedLruSizeLimit: a decoded chunk cache with a fixed size in bytes.ChunkCacheEncodedLruChunkLimit: an encoded chunk cache with a fixed chunk capacity.ChunkCacheEncodedLruSizeLimit: an encoded chunk cache with a fixed size in bytes.ChunkCachePartialDecoderLruChunkLimit: a partial decoder chunk cache with a fixed chunk capacityChunkCachePartialDecoderLruSizeLimit: a partial decoder chunk cache with a fixed size in bytes.
There are also ThreadLocal suffixed variants of all of these caches that have a per-thread cache.
zarrs consumers can create custom caches by implementing the ChunkCache trait.
Chunk caches implement the ChunkCache trait which has cached versions of the equivalent Array methods:
_elements and _ndarray variants are also available.
Chunk caching is likely to be effective for remote stores where redundant retrievals are costly.
Chunk caching may not outperform disk caching with a filesystem store.
The above caches use internal locking to support multithreading, which has a performance overhead.
Prefer not to use a chunk cache if chunks are not accessed repeatedly.
Aside from ChunkCacheTypePartialDecoder-based caches, caches do not use partial decoders and any intersected chunk is fully retrieved if not present in the cache.
For many access patterns, chunk caching may reduce performance. Benchmark your algorithm/data.
Structs§
- Chunk
Cache LruChunk Limit - A chunk cache with a fixed chunk capacity.
- Chunk
Cache LruChunk Limit Thread Local - A thread local chunk cache with a fixed chunk capacity per thread.
- Chunk
Cache LruSize Limit - A chunk cache with a fixed size capacity.
- Chunk
Cache LruSize Limit Thread Local - A thread local chunk cache with a fixed size capacity per thread.
Traits§
- Chunk
Cache - Traits for a chunk cache.
- Chunk
Cache Type - A chunk cache type (
ChunkCacheTypeEncoded,ChunkCacheTypeDecoded, orChunkCacheTypePartialDecoder).
Type Aliases§
- Chunk
Cache Decoded LruChunk Limit - An LRU (least recently used) decoded chunk cache with a fixed chunk capacity.
- Chunk
Cache Decoded LruChunk Limit Thread Local - An LRU (least recently used) decoded chunk cache with a fixed chunk capacity.
- Chunk
Cache Decoded LruSize Limit - An LRU (least recently used) decoded chunk cache with a fixed size capacity .
- Chunk
Cache Decoded LruSize Limit Thread Local - An LRU (least recently used) decoded chunk cache with a fixed size capacity.
- Chunk
Cache Encoded LruChunk Limit - An LRU (least recently used) encoded chunk cache with a fixed chunk capacity.
- Chunk
Cache Encoded LruChunk Limit Thread Local - An LRU (least recently used) encoded chunk cache with a fixed chunk capacity.
- Chunk
Cache Encoded LruSize Limit - An LRU (least recently used) encoded chunk cache with a fixed size capacity.
- Chunk
Cache Encoded LruSize Limit Thread Local - An LRU (least recently used) encoded chunk cache with a fixed size capacity.
- Chunk
Cache Partial Decoder LruChunk Limit - An LRU (least recently used) partial decoder chunk cache with a fixed chunk capacity.
- Chunk
Cache Partial Decoder LruChunk Limit Thread Local - An LRU (least recently used) partial decoder chunk cache with a fixed chunk capacity.
- Chunk
Cache Partial Decoder LruSize Limit - An LRU (least recently used) partial decoder chunk cache with a fixed size capacity.
- Chunk
Cache Partial Decoder LruSize Limit Thread Local - An LRU (least recently used) partial decoder chunk cache with a fixed chunk capacity.
- Chunk
Cache Type Decoded - The chunk type of a decoded chunk cache.
- Chunk
Cache Type Encoded - The chunk type of an encoded chunk cache.
- Chunk
Cache Type Partial Decoder - The chunk type of a partial decoder chunk cache.