Summary
The internal tile cache (ITileCache / LRUTileCache / GlobalCacheManager, and the enable_caching / cache_size_mb fields on SlideOpenOptions) is fully wired into the Python bindings (src/python/fastslide.cpp), but is unreachable from the C API and therefore from the Rust bindings (fastslide-sys / fastslide crates).
Current behavior (traced from Rust)
SlideReader::open(path) (rust/fastslide/src/reader.rs) calls fastslide_create_reader(path).
- That calls
ReaderRegistry::CreateReader(filename, cache = nullptr) (include/fastslide/runtime/reader_registry.h), where cache always defaults to nullptr since no C API entry point exposes it.
- Format factories only call
reader->SetCache(cache) when cache is non-null, so SlideReader::cache_ stays nullptr and IsCacheEnabled() returns false.
- As a result,
CachedTileExecutor::ReadWithCache skips all Get/Put calls, and every tile is decoded from disk on every read — including repeated/adjacent reads that fall within the same native tile grid cell (e.g. two 256×256 ReadRegion calls inside the same 512×512 SVS tile).
SlideOpenOptions.enable_caching / cache_size_mb are declared in include/fastslide/slide_options.h but are never constructed or read anywhere in src/ — dead code with respect to this call path.
GlobalCacheManager::Instance() (1 GiB default LRUTileCache) is likewise never invoked outside the Python bindings.
This means C/Rust consumers get none of the decode-reuse benefit that the cache architecture (and the Python bindings) already provide — comparable to running OpenSlide with tile caching disabled.
Request
Expose a way to enable/configure the internal tile cache from the C API, so Rust (and other C API consumers) can opt in without reimplementing tile-grid-aware caching at the application layer. For example:
- A C API function such as
fastslide_reader_set_cache(reader, capacity_bytes) (or fastslide_create_reader_with_cache(path, capacity_bytes)), mirroring what examples/cache_example.cpp already does in C++ (LRUTileCache::Create(bytes) + reader->SetCache(cache)).
- Optionally, wire
SlideOpenOptions.enable_caching / cache_size_mb through to this path so the struct isn't dead code, or remove it if superseded by an explicit cache-injection API.
- Surface the equivalent call in
fastslide-sys/fastslide Rust crates (e.g. SlideReader::open_with_cache(path, capacity_bytes)).
Summary
The internal tile cache (
ITileCache/LRUTileCache/GlobalCacheManager, and theenable_caching/cache_size_mbfields onSlideOpenOptions) is fully wired into the Python bindings (src/python/fastslide.cpp), but is unreachable from the C API and therefore from the Rust bindings (fastslide-sys/fastslidecrates).Current behavior (traced from Rust)
SlideReader::open(path)(rust/fastslide/src/reader.rs) callsfastslide_create_reader(path).ReaderRegistry::CreateReader(filename, cache = nullptr)(include/fastslide/runtime/reader_registry.h), wherecachealways defaults tonullptrsince no C API entry point exposes it.reader->SetCache(cache)whencacheis non-null, soSlideReader::cache_staysnullptrandIsCacheEnabled()returnsfalse.CachedTileExecutor::ReadWithCacheskips allGet/Putcalls, and every tile is decoded from disk on every read — including repeated/adjacent reads that fall within the same native tile grid cell (e.g. two 256×256ReadRegioncalls inside the same 512×512 SVS tile).SlideOpenOptions.enable_caching/cache_size_mbare declared ininclude/fastslide/slide_options.hbut are never constructed or read anywhere insrc/— dead code with respect to this call path.GlobalCacheManager::Instance()(1 GiB defaultLRUTileCache) is likewise never invoked outside the Python bindings.This means C/Rust consumers get none of the decode-reuse benefit that the cache architecture (and the Python bindings) already provide — comparable to running OpenSlide with tile caching disabled.
Request
Expose a way to enable/configure the internal tile cache from the C API, so Rust (and other C API consumers) can opt in without reimplementing tile-grid-aware caching at the application layer. For example:
fastslide_reader_set_cache(reader, capacity_bytes)(orfastslide_create_reader_with_cache(path, capacity_bytes)), mirroring whatexamples/cache_example.cppalready does in C++ (LRUTileCache::Create(bytes)+reader->SetCache(cache)).SlideOpenOptions.enable_caching/cache_size_mbthrough to this path so the struct isn't dead code, or remove it if superseded by an explicit cache-injection API.fastslide-sys/fastslideRust crates (e.g.SlideReader::open_with_cache(path, capacity_bytes)).