From dfbc28ca9aee8655d51c4193af12cdcf4e0bcb77 Mon Sep 17 00:00:00 2001 From: Lu Qiu Date: Mon, 27 Jul 2026 13:37:22 -0400 Subject: [PATCH] perf(cache): use the quick_cache backend for the session metadata cache Same motivation as the index cache switch (#7953): moka records every hit into a global read-op channel, which negatively scales with readers. The shard formula already handles metadata capacities: >= 4 GiB per shard, so even the largest entries (manifests of wide many-fragment tables, ~100-200 MB) stay admissible. Co-Authored-By: Claude Fable 5 --- rust/lance-core/src/cache/quick.rs | 4 ++-- rust/lance/src/session.rs | 13 +++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/rust/lance-core/src/cache/quick.rs b/rust/lance-core/src/cache/quick.rs index 83b0754122e..22873e3c0d0 100644 --- a/rust/lance-core/src/cache/quick.rs +++ b/rust/lance-core/src/cache/quick.rs @@ -3,8 +3,8 @@ //! [`CacheBackend`] backed by [quick_cache](https://crates.io/crates/quick_cache), //! whose hit path is one atomic bit — no read-op channel or inline -//! housekeeping. Used for the session index cache, which sees thousands of -//! cache reads per query. +//! housekeeping. Used for the session index and metadata caches; the index +//! cache sees thousands of cache reads per query. use std::pin::Pin; diff --git a/rust/lance/src/session.rs b/rust/lance/src/session.rs index c707586929e..e274d99518c 100644 --- a/rust/lance/src/session.rs +++ b/rust/lance/src/session.rs @@ -97,7 +97,8 @@ impl Session { /// /// - ***index_cache_size***: the size of the index cache, backed by /// [`QuickCacheBackend`]. - /// - ***metadata_cache_size***: the size of the metadata cache. + /// - ***metadata_cache_size***: the size of the metadata cache, backed by + /// [`QuickCacheBackend`]. /// - ***store_registry***: the object store registry to use when opening /// datasets. This determines which schemes are available, and also allows /// re-using object stores. @@ -110,7 +111,9 @@ impl Session { index_cache: GlobalIndexCache(LanceCache::with_backend(Arc::new( QuickCacheBackend::with_capacity(index_cache_size), ))), - metadata_cache: GlobalMetadataCache(LanceCache::with_capacity(metadata_cache_size)), + metadata_cache: GlobalMetadataCache(LanceCache::with_backend(Arc::new( + QuickCacheBackend::with_capacity(metadata_cache_size), + ))), index_extensions: HashMap::new(), store_registry, spill_store: Arc::new(LocalSpillStore::default()), @@ -120,7 +123,7 @@ impl Session { /// Create a session with a custom index cache backend. /// /// The provided backend will be used for caching index data. The metadata - /// cache will use the default Moka-based backend with the given capacity. + /// cache uses a [`QuickCacheBackend`] with the given capacity. pub fn with_index_cache_backend( index_cache_backend: Arc, metadata_cache_size: usize, @@ -128,7 +131,9 @@ impl Session { ) -> Self { Self { index_cache: GlobalIndexCache(LanceCache::with_backend(index_cache_backend)), - metadata_cache: GlobalMetadataCache(LanceCache::with_capacity(metadata_cache_size)), + metadata_cache: GlobalMetadataCache(LanceCache::with_backend(Arc::new( + QuickCacheBackend::with_capacity(metadata_cache_size), + ))), index_extensions: HashMap::new(), store_registry, spill_store: Arc::new(LocalSpillStore::default()),