From 911441a5863045b56584ec6aadfcbb7c4b90cb33 Mon Sep 17 00:00:00 2001 From: MrCroxx Date: Wed, 12 Nov 2025 18:09:33 +0800 Subject: [PATCH 1/8] refactor(foyer): upgrade foyer to v0.21.0-dev Temporarily remove vector cache stats, restore it after state check is fixed. Signed-off-by: MrCroxx --- Cargo.lock | 28 +- Cargo.toml | 6 +- src/common/Cargo.toml | 1 + src/common/src/lru.rs | 2 +- .../src/rpc/service/monitor_service.rs | 18 +- src/storage/benches/bench_block_cache.rs | 29 +- src/storage/src/hummock/block_cache.rs | 20 +- src/storage/src/hummock/sstable_store.rs | 267 ++++++++++-------- 8 files changed, 194 insertions(+), 177 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index afcbd4a1744e6..9e7e619c2dda1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5613,15 +5613,15 @@ dependencies = [ [[package]] name = "foyer" -version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa5d15035074ac205314ecc39ffb7697d59ba9deed2380fa12a7d54ddf35e9ba" +version = "0.21.0-dev" +source = "git+https://github.com/foyer-rs/foyer?rev=f8c68089548f3635ac641b03ae15b55e16f344e4#f8c68089548f3635ac641b03ae15b55e16f344e4" dependencies = [ "equivalent", "fastrace", "foyer-common", "foyer-memory", "foyer-storage", + "futures-util", "madsim-tokio", "mixtrics", "pin-project", @@ -5633,9 +5633,8 @@ dependencies = [ [[package]] name = "foyer-common" -version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "181bfdf387bd81442dd529e46b4cf632fd75076349d962b8a96aea24eddf5848" +version = "0.21.0-dev" +source = "git+https://github.com/foyer-rs/foyer?rev=f8c68089548f3635ac641b03ae15b55e16f344e4#f8c68089548f3635ac641b03ae15b55e16f344e4" dependencies = [ "bincode 1.3.3", "bytes", @@ -5663,9 +5662,8 @@ dependencies = [ [[package]] name = "foyer-memory" -version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "757d608277911c2292b7563638b5b7f804904ff71a4e4757d97a94cd6a067e57" +version = "0.21.0-dev" +source = "git+https://github.com/foyer-rs/foyer?rev=f8c68089548f3635ac641b03ae15b55e16f344e4#f8c68089548f3635ac641b03ae15b55e16f344e4" dependencies = [ "arc-swap", "bitflags 2.10.0", @@ -5674,11 +5672,13 @@ dependencies = [ "fastrace", "foyer-common", "foyer-intrusive-collections", - "hashbrown 0.15.5", + "futures-util", + "hashbrown 0.16.0", "itertools 0.14.0", "madsim-tokio", "mixtrics", "parking_lot 0.12.1", + "paste", "pin-project", "serde", "thiserror 2.0.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5688,9 +5688,8 @@ dependencies = [ [[package]] name = "foyer-storage" -version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e1045dd1812baa313d8cb97b53f540bd8ed315f4585982f78ae7f6a1cdde4e2" +version = "0.21.0-dev" +source = "git+https://github.com/foyer-rs/foyer?rev=f8c68089548f3635ac641b03ae15b55e16f344e4#f8c68089548f3635ac641b03ae15b55e16f344e4" dependencies = [ "allocator-api2", "anyhow", @@ -5705,7 +5704,7 @@ dependencies = [ "fs4", "futures-core", "futures-util", - "hashbrown 0.15.5", + "hashbrown 0.16.0", "io-uring", "itertools 0.14.0", "libc", @@ -11475,6 +11474,7 @@ dependencies = [ "foyer", "futures", "hashbrown 0.14.5", + "hashbrown 0.15.5", "hashbrown 0.16.0", "hex", "http 1.3.1", diff --git a/Cargo.toml b/Cargo.toml index f6e3b2f461295..0e5d1df713c16 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -155,7 +155,8 @@ criterion = { version = "0.7", features = ["async_futures"] } # compile time and binary size. deltalake = { version = "0.26", features = ["s3", "gcs", "datafusion"] } faiss = { version = "0.12.2-alpha.0", features = ["static"] } -foyer = { version = "0.20.0", features = ["serde", "tracing", "nightly"] } +# TODO(MrCroxx): Switch to a release version. +foyer = { git = "https://github.com/foyer-rs/foyer", rev = "f8c68089548f3635ac641b03ae15b55e16f344e4", features = ["serde", "tracing", "nightly"] } futures-async-stream = "0.2.9" governor = { version = "0.10", default-features = false, features = ["std"] } hashbrown = { version = "0.16", features = [ @@ -166,6 +167,9 @@ hashbrown = { version = "0.16", features = [ hashbrown0_14 = { package = "hashbrown", version = "0.14", features = [ "nightly", ] } +hashbrown0_15 = { package = "hashbrown", version = "0.15", features = [ + "nightly", +] } hytra = "0.1" # branch dev_rebase_main_20250325 iceberg = { git = "https://github.com/risingwavelabs/iceberg-rust.git", rev = "0b5d05b20e8a5277a47585141082a7a638238ae1", features = [ diff --git a/src/common/Cargo.toml b/src/common/Cargo.toml index 5f200d7651f16..9b117bf6c7b59 100644 --- a/src/common/Cargo.toml +++ b/src/common/Cargo.toml @@ -46,6 +46,7 @@ foyer = { workspace = true } futures = { version = "0.3", default-features = false, features = ["alloc"] } hashbrown = { workspace = true } hashbrown0_14 = { workspace = true } +hashbrown0_15 = { workspace = true } hex = "0.4.3" http = "1" humantime = "2.3" diff --git a/src/common/src/lru.rs b/src/common/src/lru.rs index c2094dc1a0b08..b853a3d2dcdde 100644 --- a/src/common/src/lru.rs +++ b/src/common/src/lru.rs @@ -23,7 +23,7 @@ use std::sync::atomic::Ordering; pub use ahash::RandomState; use hashbrown::HashTable; use hashbrown::hash_table::Entry; -use hashbrown0_14 as _; +use {hashbrown0_14 as _, hashbrown0_15 as _}; use crate::sequence::{AtomicSequence, Sequence, Sequencer}; diff --git a/src/compute/src/rpc/service/monitor_service.rs b/src/compute/src/rpc/service/monitor_service.rs index ad2029f8d4944..72edc1057dfc8 100644 --- a/src/compute/src/rpc/service/monitor_service.rs +++ b/src/compute/src/rpc/service/monitor_service.rs @@ -496,17 +496,14 @@ impl MonitorService for MonitorServiceImpl { options = options.with_record_hybrid_get_threshold(Duration::from_millis(threshold as _)); } - if let Some(threshold) = req.record_hybrid_obtain_threshold_ms { - options = options - .with_record_hybrid_obtain_threshold(Duration::from_millis(threshold as _)); - } if let Some(threshold) = req.record_hybrid_remove_threshold_ms { options = options .with_record_hybrid_remove_threshold(Duration::from_millis(threshold as _)); } if let Some(threshold) = req.record_hybrid_fetch_threshold_ms { - options = options - .with_record_hybrid_fetch_threshold(Duration::from_millis(threshold as _)); + options = options.with_record_hybrid_get_or_fetch_threshold(Duration::from_millis( + threshold as _, + )); } cache.update_tracing_options(options); } @@ -526,17 +523,14 @@ impl MonitorService for MonitorServiceImpl { options = options.with_record_hybrid_get_threshold(Duration::from_millis(threshold as _)); } - if let Some(threshold) = req.record_hybrid_obtain_threshold_ms { - options = options - .with_record_hybrid_obtain_threshold(Duration::from_millis(threshold as _)); - } if let Some(threshold) = req.record_hybrid_remove_threshold_ms { options = options .with_record_hybrid_remove_threshold(Duration::from_millis(threshold as _)); } if let Some(threshold) = req.record_hybrid_fetch_threshold_ms { - options = options - .with_record_hybrid_fetch_threshold(Duration::from_millis(threshold as _)); + options = options.with_record_hybrid_get_or_fetch_threshold(Duration::from_millis( + threshold as _, + )); } cache.update_tracing_options(options); } diff --git a/src/storage/benches/bench_block_cache.rs b/src/storage/benches/bench_block_cache.rs index 3eb6c69916563..fc087b0e6a7ad 100644 --- a/src/storage/benches/bench_block_cache.rs +++ b/src/storage/benches/bench_block_cache.rs @@ -156,18 +156,17 @@ impl FoyerCache { #[async_trait] impl CacheBase for FoyerCache { async fn try_get_with(&self, sst_object_id: u64, block_idx: u64) -> HummockResult> { + let latency = self.fake_io_latency; let entry = self .inner - .fetch((sst_object_id, block_idx), || { - let latency = self.fake_io_latency; - async move { - get_fake_block(sst_object_id, block_idx, latency) - .await - .map(Arc::new) - .map_err(foyer::Error::other) - } + .get_or_fetch(&(sst_object_id, block_idx), move |_| async move { + get_fake_block(sst_object_id, block_idx, latency) + .await + .map(Arc::new) + .map_err(foyer::MemoryError::other) }) .await + .map_err(foyer::Error::from) .map_err(HummockError::foyer_error)?; Ok(entry.value().clone()) } @@ -220,16 +219,14 @@ impl FoyerHybridCache { #[async_trait] impl CacheBase for FoyerHybridCache { async fn try_get_with(&self, sst_object_id: u64, block_idx: u64) -> HummockResult> { + let latency = self.fake_io_latency; let entry = self .inner - .fetch((sst_object_id, block_idx), || { - let latency = self.fake_io_latency; - async move { - get_fake_block(sst_object_id, block_idx, latency) - .await - .map(Arc::new) - .map_err(foyer::Error::other) - } + .get_or_fetch(&(sst_object_id, block_idx), move |_| async move { + get_fake_block(sst_object_id, block_idx, latency) + .await + .map(Arc::new) + .map_err(foyer::Error::other) }) .await .map_err(HummockError::foyer_error)?; diff --git a/src/storage/src/hummock/block_cache.rs b/src/storage/src/hummock/block_cache.rs index 9792e4013ba75..b732c7ea2a951 100644 --- a/src/storage/src/hummock/block_cache.rs +++ b/src/storage/src/hummock/block_cache.rs @@ -16,7 +16,7 @@ use std::ops::Deref; use std::sync::Arc; use await_tree::{InstrumentAwait, SpanExt}; -use foyer::{FetchState, HybridCacheEntry, HybridFetch}; +use foyer::{FetchState, HybridCacheEntry, HybridGetOrFetch}; use risingwave_common::config::EvictionConfig; use super::{Block, HummockResult, SstableBlockIndex}; @@ -81,27 +81,27 @@ pub struct BlockCacheConfig { pub enum BlockResponse { Block(BlockHolder), - Entry(HybridFetch>), + Fetch(HybridGetOrFetch>), } impl BlockResponse { pub async fn wait(self) -> HummockResult { - let entry = match self { + let fetch = match self { BlockResponse::Block(block) => return Ok(block), - BlockResponse::Entry(entry) => entry, + BlockResponse::Fetch(fetch) => fetch, }; - match entry.state() { - FetchState::Hit => entry + match fetch.state() { + FetchState::Hit => fetch .await .map(BlockHolder::from_hybrid_cache_entry) .map_err(HummockError::foyer_error), - FetchState::Wait => entry - .instrument_await("wait_pending_fetch_block".verbose()) + _ if fetch.is_leader() => fetch + .instrument_await("fetch_block".verbose()) .await .map(BlockHolder::from_hybrid_cache_entry) .map_err(HummockError::foyer_error), - FetchState::Miss => entry - .instrument_await("fetch_block".verbose()) + _ => fetch + .instrument_await("wait_pending_fetch_block".verbose()) .await .map(BlockHolder::from_hybrid_cache_entry) .map_err(HummockError::foyer_error), diff --git a/src/storage/src/hummock/sstable_store.rs b/src/storage/src/hummock/sstable_store.rs index 98efd1ee1cc77..ec619a09c0938 100644 --- a/src/storage/src/hummock/sstable_store.rs +++ b/src/storage/src/hummock/sstable_store.rs @@ -15,7 +15,7 @@ use std::clone::Clone; use std::collections::VecDeque; use std::future::Future; -use std::ops::Deref; +use std::ops::{Deref, Range}; use std::pin::Pin; use std::sync::Arc; use std::sync::atomic::{AtomicUsize, Ordering}; @@ -24,8 +24,8 @@ use await_tree::{InstrumentAwait, SpanExt}; use bytes::Bytes; use fail::fail_point; use foyer::{ - Cache, CacheBuilder, CacheEntry, EventListener, FetchState, Hint, HybridCache, - HybridCacheBuilder, HybridCacheEntry, HybridCacheProperties, + Cache, CacheBuilder, CacheEntry, EventListener, Hint, HybridCache, HybridCacheBuilder, + HybridCacheEntry, HybridCacheProperties, }; use futures::{StreamExt, future}; use prost::Message; @@ -457,6 +457,57 @@ impl SstableStore { ))) } + async fn fetch_block( + store: ObjectStoreRef, + object_id: HummockSstableObjectId, + data_path: Arc, + file_size: u32, + range: Range, + uncompressed_capacity: usize, + ) -> foyer::Result> { + let block_data = match store + .read(&data_path, range.clone()) + .instrument_await("get_block_response".verbose()) + .await + { + Ok(data) => data, + Err(e) => { + tracing::error!( + "get_block_response meet error when read {:?} from sst-{}, total length: {}", + range, + object_id, + file_size + ); + return Err(foyer::Error::other(HummockError::from(e))); + } + }; + let block = Box::new( + Block::decode(block_data, uncompressed_capacity).map_err(foyer::Error::other)?, + ); + Ok(block) + } + + async fn fetch_block_with_hint( + store: ObjectStoreRef, + object_id: HummockSstableObjectId, + data_path: Arc, + file_size: u32, + range: Range, + uncompressed_capacity: usize, + hint: Hint, + ) -> foyer::Result<(Box, HybridCacheProperties)> { + Self::fetch_block( + store, + object_id, + data_path, + file_size, + range, + uncompressed_capacity, + ) + .await + .map(|block| (block, HybridCacheProperties::default().with_hint(hint))) + } + pub async fn get_block_response( &self, sst: &Sstable, @@ -470,7 +521,7 @@ impl SstableStore { stats.cache_data_block_total += 1; let file_size = sst.meta.estimated_size; - let data_path = self.get_sst_data_path(object_id); + let data_path = Arc::new(self.get_sst_data_path(object_id)); let disable_cache: fn() -> bool = || { fail_point!("disable_block_cache", |_| true); @@ -488,49 +539,23 @@ impl SstableStore { block_idx: block_index as _, }; - // future: fetch block if hybrid cache miss - let fetch_block = move || { - let range = range.clone(); - - async move { - let block_data = match store - .read(&data_path, range.clone()) - .instrument_await("get_block_response".verbose()) - .await - { - Ok(data) => data, - Err(e) => { - tracing::error!( - "get_block_response meet error when read {:?} from sst-{}, total length: {}", - range, - object_id, - file_size - ); - return Err(foyer::Error::other(HummockError::from(e))); - } - }; - let block = Box::new( - Block::decode(block_data, uncompressed_capacity) - .map_err(foyer::Error::other)?, - ); - Ok(block) - } - }; - self.recent_filter .extend([(object_id, usize::MAX), (object_id, block_index)]); match policy { CachePolicy::Fill(hint) => { - let entry = self.block_cache.fetch_with_properties( - idx, - HybridCacheProperties::default().with_hint(hint), - fetch_block, - ); - if matches!(entry.state(), FetchState::Miss) { - stats.cache_data_block_miss += 1; - } - Ok(BlockResponse::Entry(entry)) + let fetch = self.block_cache.get_or_fetch(&idx, move |_| { + Self::fetch_block_with_hint( + store, + object_id, + data_path, + file_size, + range, + uncompressed_capacity, + hint, + ) + }); + Ok(BlockResponse::Fetch(fetch)) } CachePolicy::NotFill => { match self @@ -543,13 +568,31 @@ impl SstableStore { entry, ))), _ => { - let block = fetch_block().await.map_err(HummockError::foyer_error)?; + let block = Self::fetch_block( + store, + object_id, + data_path, + file_size, + range, + uncompressed_capacity, + ) + .await + .map_err(HummockError::foyer_error)?; Ok(BlockResponse::Block(BlockHolder::from_owned_block(block))) } } } CachePolicy::Disable => { - let block = fetch_block().await.map_err(HummockError::foyer_error)?; + let block = Self::fetch_block( + store, + object_id, + data_path, + file_size, + range, + uncompressed_capacity, + ) + .await + .map_err(HummockError::foyer_error)?; Ok(BlockResponse::Block(BlockHolder::from_owned_block(block))) } } @@ -574,31 +617,24 @@ impl SstableStore { pub async fn get_vector_file_meta( &self, vector_file: &VectorFileInfo, - stats: &mut VectorStoreCacheStats, + _stats: &mut VectorStoreCacheStats, ) -> HummockResult { + let store = self.store.clone(); + let path = self.get_object_data_path(HummockObjectId::VectorFile(vector_file.object_id)); + let meta_offset = vector_file.meta_offset; let entry = self .vector_meta_cache - .fetch(vector_file.object_id.as_raw(), || { - let store = self.store.clone(); - let path = - self.get_object_data_path(HummockObjectId::VectorFile(vector_file.object_id)); - let meta_offset = vector_file.meta_offset; - async move { - let encoded_footer = store - .read(&path, meta_offset..) - .await - .map_err(foyer::Error::other)?; - let meta = VectorFileMeta::decode_footer(&encoded_footer) - .map_err(foyer::Error::other)?; - Ok::<_, foyer::Error>(meta.into()) - } - }); - if let FetchState::Miss = entry.state() { - stats.file_meta_miss += 1; - } - stats.file_meta_total += 1; - - let entry = entry.await?; + .get_or_fetch(&vector_file.object_id.as_raw(), move |_| async move { + let encoded_footer = store + .read(&path, meta_offset..) + .await + .map_err(foyer::MemoryError::other)?; + let meta = VectorFileMeta::decode_footer(&encoded_footer) + .map_err(foyer::MemoryError::other)?; + Ok(HummockVectorIndexMetaFile::from(meta)) + }) + .await + .map_err(HummockError::other)?; VectorFileHolder::try_from_entry(entry, vector_file.object_id.as_raw()) } @@ -607,31 +643,25 @@ impl SstableStore { vector_file: &VectorFileInfo, block_idx: usize, block_meta: &VectorBlockMeta, - stats: &mut VectorStoreCacheStats, + _stats: &mut VectorStoreCacheStats, ) -> HummockResult { - let entry = self - .vector_block_cache - .fetch((vector_file.object_id, block_idx), || { - let store = self.store.clone(); - let path = - self.get_object_data_path(HummockObjectId::VectorFile(vector_file.object_id)); - let start_offset = block_meta.offset; - let end_offset = start_offset + block_meta.block_size; - async move { - let encoded_block = store - .read(&path, start_offset..end_offset) - .await - .map_err(foyer::Error::other)?; - let block = VectorBlock::decode(&encoded_block).map_err(foyer::Error::other)?; - Ok(Box::new(block)) - } - }); - if let FetchState::Miss = entry.state() { - stats.file_block_miss += 1; - } - stats.file_block_total += 1; - - entry.await.map_err(HummockError::foyer_error) + let store = self.store.clone(); + let path = self.get_object_data_path(HummockObjectId::VectorFile(vector_file.object_id)); + let start_offset = block_meta.offset; + let end_offset = start_offset + block_meta.block_size; + self.vector_block_cache + .get_or_fetch(&(vector_file.object_id, block_idx), move |_| async move { + let encoded_block = store + .read(&path, start_offset..end_offset) + .await + .map_err(foyer::MemoryError::other)?; + let block = + VectorBlock::decode(&encoded_block).map_err(foyer::MemoryError::other)?; + Ok(Box::new(block)) + }) + .await + .map_err(foyer::Error::from) + .map_err(HummockError::foyer_error) } pub fn insert_vector_cache( @@ -656,30 +686,25 @@ impl SstableStore { pub async fn get_hnsw_graph( &self, graph_file: &HnswGraphFileInfo, - stats: &mut VectorStoreCacheStats, + _stats: &mut VectorStoreCacheStats, ) -> HummockResult { + let store = self.store.clone(); + let graph_file_path = + self.get_object_data_path(HummockObjectId::HnswGraphFile(graph_file.object_id)); let entry = self .vector_meta_cache - .fetch(graph_file.object_id.as_raw(), || { - let store = self.store.clone(); - let graph_file_path = - self.get_object_data_path(HummockObjectId::HnswGraphFile(graph_file.object_id)); - async move { - let encoded_graph = store - .read(&graph_file_path, ..) - .await - .map_err(foyer::Error::other)?; - let graph = - PbHnswGraph::decode(encoded_graph.as_ref()).map_err(foyer::Error::other)?; - Ok::<_, foyer::Error>(graph.into()) - } - }); - if let FetchState::Miss = entry.state() { - stats.hnsw_graph_miss += 1; - } - stats.hnsw_graph_total += 1; - - let entry = entry.await?; + .get_or_fetch(&graph_file.object_id.as_raw(), |_| async move { + let encoded_graph = store + .read(&graph_file_path, ..) + .await + .map_err(foyer::MemoryError::other)?; + let graph = PbHnswGraph::decode(encoded_graph.as_ref()) + .map_err(foyer::MemoryError::other)?; + Ok(HummockVectorIndexMetaFile::from(graph)) + }) + .await + .map_err(foyer::Error::from) + .map_err(HummockError::foyer_error)?; HnswGraphFileHolder::try_from_entry(entry, graph_file.object_id.as_raw()) } @@ -736,13 +761,14 @@ impl SstableStore { stats: &mut StoreLocalStatistic, ) -> impl Future> + Send + 'static + use<> { let object_id = sstable_info_ref.object_id; + let store = self.store.clone(); + let meta_path = self.get_sst_data_path(object_id); + let stats_ptr = stats.remote_io_time.clone(); + let range = sstable_info_ref.meta_offset as usize..; - let entry = self.meta_cache.fetch(object_id, || { - let store = self.store.clone(); - let meta_path = self.get_sst_data_path(object_id); - let stats_ptr = stats.remote_io_time.clone(); - let range = sstable_info_ref.meta_offset as usize..; - async move { + let entry = self + .meta_cache + .get_or_fetch(&object_id, move |_| async move { let now = Instant::now(); let buf = store .read(&meta_path, range) @@ -754,12 +780,7 @@ impl SstableStore { let add = (now.elapsed().as_secs_f64() * 1000.0).ceil(); stats_ptr.fetch_add(add as u64, Ordering::Relaxed); Ok(Box::new(sst)) - } - }); - - if matches! { entry.state(), FetchState::Wait | FetchState::Miss } { - stats.cache_meta_block_miss += 1; - } + }); stats.cache_meta_block_total += 1; From 4e835b8e199ad2cb14807833ae0af91869934a2a Mon Sep 17 00:00:00 2001 From: MrCroxx Date: Thu, 13 Nov 2025 17:22:44 +0800 Subject: [PATCH 2/8] chore: upgrade foyer Signed-off-by: MrCroxx --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9608d2fa7116e..7eb685ae4d67c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5614,7 +5614,7 @@ dependencies = [ [[package]] name = "foyer" version = "0.21.0-dev" -source = "git+https://github.com/foyer-rs/foyer?rev=f8c68089548f3635ac641b03ae15b55e16f344e4#f8c68089548f3635ac641b03ae15b55e16f344e4" +source = "git+https://github.com/foyer-rs/foyer?rev=14225a492167deb404692c6dc46c004edfeebe1a#14225a492167deb404692c6dc46c004edfeebe1a" dependencies = [ "equivalent", "fastrace", @@ -5634,7 +5634,7 @@ dependencies = [ [[package]] name = "foyer-common" version = "0.21.0-dev" -source = "git+https://github.com/foyer-rs/foyer?rev=f8c68089548f3635ac641b03ae15b55e16f344e4#f8c68089548f3635ac641b03ae15b55e16f344e4" +source = "git+https://github.com/foyer-rs/foyer?rev=14225a492167deb404692c6dc46c004edfeebe1a#14225a492167deb404692c6dc46c004edfeebe1a" dependencies = [ "bincode 1.3.3", "bytes", @@ -5663,7 +5663,7 @@ dependencies = [ [[package]] name = "foyer-memory" version = "0.21.0-dev" -source = "git+https://github.com/foyer-rs/foyer?rev=f8c68089548f3635ac641b03ae15b55e16f344e4#f8c68089548f3635ac641b03ae15b55e16f344e4" +source = "git+https://github.com/foyer-rs/foyer?rev=14225a492167deb404692c6dc46c004edfeebe1a#14225a492167deb404692c6dc46c004edfeebe1a" dependencies = [ "arc-swap", "bitflags 2.10.0", @@ -5689,7 +5689,7 @@ dependencies = [ [[package]] name = "foyer-storage" version = "0.21.0-dev" -source = "git+https://github.com/foyer-rs/foyer?rev=f8c68089548f3635ac641b03ae15b55e16f344e4#f8c68089548f3635ac641b03ae15b55e16f344e4" +source = "git+https://github.com/foyer-rs/foyer?rev=14225a492167deb404692c6dc46c004edfeebe1a#14225a492167deb404692c6dc46c004edfeebe1a" dependencies = [ "allocator-api2", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index dae2eee61f4ee..62a3da5a4c318 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -156,7 +156,7 @@ criterion = { version = "0.7", features = ["async_futures"] } deltalake = { version = "0.26", features = ["s3", "gcs", "datafusion"] } faiss = { version = "0.12.2-alpha.0", features = ["static"] } # TODO(MrCroxx): Switch to a release version. -foyer = { git = "https://github.com/foyer-rs/foyer", rev = "f8c68089548f3635ac641b03ae15b55e16f344e4", features = ["serde", "tracing", "nightly"] } +foyer = { git = "https://github.com/foyer-rs/foyer", rev = "14225a492167deb404692c6dc46c004edfeebe1a", features = ["serde", "tracing", "nightly"] } futures-async-stream = "0.2.9" governor = { version = "0.10", default-features = false, features = ["std"] } hashbrown = { version = "0.16", features = [ From 9aa28dd642a4776ac17edc4e38ccd0b9f2865ce4 Mon Sep 17 00:00:00 2001 From: MrCroxx Date: Fri, 14 Nov 2025 13:58:25 +0800 Subject: [PATCH 3/8] feat: restor meta/data cache stat Signed-off-by: MrCroxx --- Cargo.lock | 8 ++-- Cargo.toml | 2 +- src/storage/src/hummock/block_cache.rs | 6 ++- src/storage/src/hummock/sstable/xor_filter.rs | 3 +- src/storage/src/hummock/sstable_store.rs | 40 +++++++++++++------ 5 files changed, 38 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2bfe767ce5202..3ffb380c98845 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5614,7 +5614,7 @@ dependencies = [ [[package]] name = "foyer" version = "0.21.0-dev" -source = "git+https://github.com/foyer-rs/foyer?rev=14225a492167deb404692c6dc46c004edfeebe1a#14225a492167deb404692c6dc46c004edfeebe1a" +source = "git+https://github.com/foyer-rs/foyer?rev=4d7ff76556b77a79a367de275013cfb8207fde21#4d7ff76556b77a79a367de275013cfb8207fde21" dependencies = [ "equivalent", "fastrace", @@ -5634,7 +5634,7 @@ dependencies = [ [[package]] name = "foyer-common" version = "0.21.0-dev" -source = "git+https://github.com/foyer-rs/foyer?rev=14225a492167deb404692c6dc46c004edfeebe1a#14225a492167deb404692c6dc46c004edfeebe1a" +source = "git+https://github.com/foyer-rs/foyer?rev=4d7ff76556b77a79a367de275013cfb8207fde21#4d7ff76556b77a79a367de275013cfb8207fde21" dependencies = [ "bincode 1.3.3", "bytes", @@ -5663,7 +5663,7 @@ dependencies = [ [[package]] name = "foyer-memory" version = "0.21.0-dev" -source = "git+https://github.com/foyer-rs/foyer?rev=14225a492167deb404692c6dc46c004edfeebe1a#14225a492167deb404692c6dc46c004edfeebe1a" +source = "git+https://github.com/foyer-rs/foyer?rev=4d7ff76556b77a79a367de275013cfb8207fde21#4d7ff76556b77a79a367de275013cfb8207fde21" dependencies = [ "arc-swap", "bitflags 2.10.0", @@ -5689,7 +5689,7 @@ dependencies = [ [[package]] name = "foyer-storage" version = "0.21.0-dev" -source = "git+https://github.com/foyer-rs/foyer?rev=14225a492167deb404692c6dc46c004edfeebe1a#14225a492167deb404692c6dc46c004edfeebe1a" +source = "git+https://github.com/foyer-rs/foyer?rev=4d7ff76556b77a79a367de275013cfb8207fde21#4d7ff76556b77a79a367de275013cfb8207fde21" dependencies = [ "allocator-api2", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index 62a3da5a4c318..45f0691a35f4f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -156,7 +156,7 @@ criterion = { version = "0.7", features = ["async_futures"] } deltalake = { version = "0.26", features = ["s3", "gcs", "datafusion"] } faiss = { version = "0.12.2-alpha.0", features = ["static"] } # TODO(MrCroxx): Switch to a release version. -foyer = { git = "https://github.com/foyer-rs/foyer", rev = "14225a492167deb404692c6dc46c004edfeebe1a", features = ["serde", "tracing", "nightly"] } +foyer = { git = "https://github.com/foyer-rs/foyer", rev = "4d7ff76556b77a79a367de275013cfb8207fde21", features = ["serde", "tracing", "nightly"] } futures-async-stream = "0.2.9" governor = { version = "0.10", default-features = false, features = ["std"] } hashbrown = { version = "0.16", features = [ diff --git a/src/storage/src/hummock/block_cache.rs b/src/storage/src/hummock/block_cache.rs index b732c7ea2a951..deabf9dc34664 100644 --- a/src/storage/src/hummock/block_cache.rs +++ b/src/storage/src/hummock/block_cache.rs @@ -24,7 +24,7 @@ use crate::hummock::HummockError; type HybridCachedBlockEntry = HybridCacheEntry>; -enum BlockEntry { +pub enum BlockEntry { HybridCache(#[allow(dead_code)] HybridCachedBlockEntry), Owned(#[allow(dead_code)] Box), RefEntry(#[allow(dead_code)] Arc), @@ -59,6 +59,10 @@ impl BlockHolder { block: ptr, } } + + pub fn entry(&self) -> &BlockEntry { + &self._handle + } } impl Deref for BlockHolder { diff --git a/src/storage/src/hummock/sstable/xor_filter.rs b/src/storage/src/hummock/sstable/xor_filter.rs index 63f19f72bd696..ac7fd603b48a5 100644 --- a/src/storage/src/hummock/sstable/xor_filter.rs +++ b/src/storage/src/hummock/sstable/xor_filter.rs @@ -517,11 +517,10 @@ mod tests { .sstable(&sst, &mut StoreLocalStatistic::default()) .await .unwrap(); - let mut stat = StoreLocalStatistic::default(); if let XorFilter::BlockXor16(reader) = &sstable.filter_reader.filter { for idx in 0..sstable.meta.block_metas.len() { let resp = sstable_store - .get_block_response(&sstable, idx, CachePolicy::Fill(Hint::Normal), &mut stat) + .get_block_response(&sstable, idx, CachePolicy::Fill(Hint::Normal)) .await .unwrap(); let block = resp.wait().await.unwrap(); diff --git a/src/storage/src/hummock/sstable_store.rs b/src/storage/src/hummock/sstable_store.rs index ec619a09c0938..4556f478aa89c 100644 --- a/src/storage/src/hummock/sstable_store.rs +++ b/src/storage/src/hummock/sstable_store.rs @@ -54,7 +54,7 @@ use crate::hummock::block_stream::{ use crate::hummock::none::NoneRecentFilter; use crate::hummock::vector::file::{VectorBlock, VectorBlockMeta, VectorFileMeta}; use crate::hummock::vector::monitor::VectorStoreCacheStats; -use crate::hummock::{BlockHolder, HummockError, HummockResult, RecentFilterTrait}; +use crate::hummock::{BlockEntry, BlockHolder, HummockError, HummockResult, RecentFilterTrait}; use crate::monitor::{HummockStateStoreMetrics, StoreLocalStatistic}; macro_rules! impl_vector_index_meta_file { @@ -347,7 +347,6 @@ impl SstableStore { None, ))); } - stats.cache_data_block_total += 1; if let Some(entry) = self .block_cache .get(&SstableBlockIndex { @@ -357,6 +356,10 @@ impl SstableStore { .await .map_err(HummockError::foyer_error)? { + stats.cache_data_block_total += 1; + if entry.source() == foyer::Source::Outer { + stats.cache_data_block_miss += 1; + } let block = BlockHolder::from_hybrid_cache_entry(entry); return Ok(Box::new(PrefetchBlockStream::new( VecDeque::from([block]), @@ -513,13 +516,11 @@ impl SstableStore { sst: &Sstable, block_index: usize, policy: CachePolicy, - stats: &mut StoreLocalStatistic, ) -> HummockResult { let object_id = sst.id; let (range, uncompressed_capacity) = sst.calculate_block_info(block_index); let store = self.store.clone(); - stats.cache_data_block_total += 1; let file_size = sst.meta.estimated_size; let data_path = Arc::new(self.get_sst_data_path(object_id)); @@ -605,19 +606,21 @@ impl SstableStore { policy: CachePolicy, stats: &mut StoreLocalStatistic, ) -> HummockResult { - match self - .get_block_response(sst, block_index, policy, stats) - .await + let block_response = self.get_block_response(sst, block_index, policy).await?; + let block_holder = block_response.wait().await?; + stats.cache_data_block_total += 1; + if let BlockEntry::HybridCache(entry) = block_holder.entry() + && entry.source() == foyer::Source::Outer { - Ok(block_response) => block_response.wait().await, - Err(err) => Err(err), + stats.cache_data_block_miss += 1; } + Ok(block_holder) } pub async fn get_vector_file_meta( &self, vector_file: &VectorFileInfo, - _stats: &mut VectorStoreCacheStats, + stats: &mut VectorStoreCacheStats, ) -> HummockResult { let store = self.store.clone(); let path = self.get_object_data_path(HummockObjectId::VectorFile(vector_file.object_id)); @@ -635,6 +638,10 @@ impl SstableStore { }) .await .map_err(HummockError::other)?; + stats.file_meta_total += 1; + if entry.source() == foyer::Source::Outer { + stats.file_meta_miss += 1; + } VectorFileHolder::try_from_entry(entry, vector_file.object_id.as_raw()) } @@ -643,13 +650,14 @@ impl SstableStore { vector_file: &VectorFileInfo, block_idx: usize, block_meta: &VectorBlockMeta, - _stats: &mut VectorStoreCacheStats, + stats: &mut VectorStoreCacheStats, ) -> HummockResult { let store = self.store.clone(); let path = self.get_object_data_path(HummockObjectId::VectorFile(vector_file.object_id)); let start_offset = block_meta.offset; let end_offset = start_offset + block_meta.block_size; - self.vector_block_cache + let entry = self + .vector_block_cache .get_or_fetch(&(vector_file.object_id, block_idx), move |_| async move { let encoded_block = store .read(&path, start_offset..end_offset) @@ -661,7 +669,13 @@ impl SstableStore { }) .await .map_err(foyer::Error::from) - .map_err(HummockError::foyer_error) + .map_err(HummockError::foyer_error)?; + + stats.file_meta_total += 1; + if entry.source() == foyer::Source::Outer { + stats.file_meta_miss += 1; + } + Ok(entry) } pub fn insert_vector_cache( From b35513cdbfc227c574e4029394adc96f9e8319e5 Mon Sep 17 00:00:00 2001 From: MrCroxx Date: Fri, 14 Nov 2025 17:26:39 +0800 Subject: [PATCH 4/8] fix: upgrade foyer with spawned fetch Signed-off-by: MrCroxx --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3ffb380c98845..22ac774e3d2dc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5614,7 +5614,7 @@ dependencies = [ [[package]] name = "foyer" version = "0.21.0-dev" -source = "git+https://github.com/foyer-rs/foyer?rev=4d7ff76556b77a79a367de275013cfb8207fde21#4d7ff76556b77a79a367de275013cfb8207fde21" +source = "git+https://github.com/foyer-rs/foyer?rev=0593c1f7ae6cf231b3f0e89fd6fe419e69f02657#0593c1f7ae6cf231b3f0e89fd6fe419e69f02657" dependencies = [ "equivalent", "fastrace", @@ -5634,7 +5634,7 @@ dependencies = [ [[package]] name = "foyer-common" version = "0.21.0-dev" -source = "git+https://github.com/foyer-rs/foyer?rev=4d7ff76556b77a79a367de275013cfb8207fde21#4d7ff76556b77a79a367de275013cfb8207fde21" +source = "git+https://github.com/foyer-rs/foyer?rev=0593c1f7ae6cf231b3f0e89fd6fe419e69f02657#0593c1f7ae6cf231b3f0e89fd6fe419e69f02657" dependencies = [ "bincode 1.3.3", "bytes", @@ -5663,7 +5663,7 @@ dependencies = [ [[package]] name = "foyer-memory" version = "0.21.0-dev" -source = "git+https://github.com/foyer-rs/foyer?rev=4d7ff76556b77a79a367de275013cfb8207fde21#4d7ff76556b77a79a367de275013cfb8207fde21" +source = "git+https://github.com/foyer-rs/foyer?rev=0593c1f7ae6cf231b3f0e89fd6fe419e69f02657#0593c1f7ae6cf231b3f0e89fd6fe419e69f02657" dependencies = [ "arc-swap", "bitflags 2.10.0", @@ -5689,7 +5689,7 @@ dependencies = [ [[package]] name = "foyer-storage" version = "0.21.0-dev" -source = "git+https://github.com/foyer-rs/foyer?rev=4d7ff76556b77a79a367de275013cfb8207fde21#4d7ff76556b77a79a367de275013cfb8207fde21" +source = "git+https://github.com/foyer-rs/foyer?rev=0593c1f7ae6cf231b3f0e89fd6fe419e69f02657#0593c1f7ae6cf231b3f0e89fd6fe419e69f02657" dependencies = [ "allocator-api2", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index 45f0691a35f4f..eb73d93717455 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -156,7 +156,7 @@ criterion = { version = "0.7", features = ["async_futures"] } deltalake = { version = "0.26", features = ["s3", "gcs", "datafusion"] } faiss = { version = "0.12.2-alpha.0", features = ["static"] } # TODO(MrCroxx): Switch to a release version. -foyer = { git = "https://github.com/foyer-rs/foyer", rev = "4d7ff76556b77a79a367de275013cfb8207fde21", features = ["serde", "tracing", "nightly"] } +foyer = { git = "https://github.com/foyer-rs/foyer", rev = "0593c1f7ae6cf231b3f0e89fd6fe419e69f02657", features = ["serde", "tracing", "nightly"] } futures-async-stream = "0.2.9" governor = { version = "0.10", default-features = false, features = ["std"] } hashbrown = { version = "0.16", features = [ From 80f7ce46dd659ad1a44b2eaca2ca566b50d2f6b8 Mon Sep 17 00:00:00 2001 From: MrCroxx Date: Fri, 14 Nov 2025 17:33:03 +0800 Subject: [PATCH 5/8] fix: temporarily remove an instrument for testing Signed-off-by: MrCroxx --- src/storage/src/hummock/block_cache.rs | 39 ++++++++++++++------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/src/storage/src/hummock/block_cache.rs b/src/storage/src/hummock/block_cache.rs index deabf9dc34664..45ac76c4ad6cb 100644 --- a/src/storage/src/hummock/block_cache.rs +++ b/src/storage/src/hummock/block_cache.rs @@ -15,8 +15,7 @@ use std::ops::Deref; use std::sync::Arc; -use await_tree::{InstrumentAwait, SpanExt}; -use foyer::{FetchState, HybridCacheEntry, HybridGetOrFetch}; +use foyer::{HybridCacheEntry, HybridGetOrFetch}; use risingwave_common::config::EvictionConfig; use super::{Block, HummockResult, SstableBlockIndex}; @@ -94,21 +93,25 @@ impl BlockResponse { BlockResponse::Block(block) => return Ok(block), BlockResponse::Fetch(fetch) => fetch, }; - match fetch.state() { - FetchState::Hit => fetch - .await - .map(BlockHolder::from_hybrid_cache_entry) - .map_err(HummockError::foyer_error), - _ if fetch.is_leader() => fetch - .instrument_await("fetch_block".verbose()) - .await - .map(BlockHolder::from_hybrid_cache_entry) - .map_err(HummockError::foyer_error), - _ => fetch - .instrument_await("wait_pending_fetch_block".verbose()) - .await - .map(BlockHolder::from_hybrid_cache_entry) - .map_err(HummockError::foyer_error), - } + fetch + .await + .map(BlockHolder::from_hybrid_cache_entry) + .map_err(HummockError::foyer_error) + // match fetch.state() { + // FetchState::Hit => fetch + // .await + // .map(BlockHolder::from_hybrid_cache_entry) + // .map_err(HummockError::foyer_error), + // _ if fetch.is_leader() => fetch + // .instrument_await("fetch_block".verbose()) + // .await + // .map(BlockHolder::from_hybrid_cache_entry) + // .map_err(HummockError::foyer_error), + // _ => fetch + // .instrument_await("wait_pending_fetch_block".verbose()) + // .await + // .map(BlockHolder::from_hybrid_cache_entry) + // .map_err(HummockError::foyer_error), + // } } } From 9365f6d7d71c140888cd78434f1f389560f0d68a Mon Sep 17 00:00:00 2001 From: MrCroxx Date: Sat, 15 Nov 2025 16:03:31 +0800 Subject: [PATCH 6/8] fix: restore fetch await tree instrument Signed-off-by: MrCroxx --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- src/storage/src/hummock/block_cache.rs | 22 ++++++---------------- 3 files changed, 11 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 22ac774e3d2dc..6aca8e941afba 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5614,7 +5614,7 @@ dependencies = [ [[package]] name = "foyer" version = "0.21.0-dev" -source = "git+https://github.com/foyer-rs/foyer?rev=0593c1f7ae6cf231b3f0e89fd6fe419e69f02657#0593c1f7ae6cf231b3f0e89fd6fe419e69f02657" +source = "git+https://github.com/foyer-rs/foyer?rev=7e1f2cb1981e7d1c194f7b01fbad198dba7cc53d#7e1f2cb1981e7d1c194f7b01fbad198dba7cc53d" dependencies = [ "equivalent", "fastrace", @@ -5634,7 +5634,7 @@ dependencies = [ [[package]] name = "foyer-common" version = "0.21.0-dev" -source = "git+https://github.com/foyer-rs/foyer?rev=0593c1f7ae6cf231b3f0e89fd6fe419e69f02657#0593c1f7ae6cf231b3f0e89fd6fe419e69f02657" +source = "git+https://github.com/foyer-rs/foyer?rev=7e1f2cb1981e7d1c194f7b01fbad198dba7cc53d#7e1f2cb1981e7d1c194f7b01fbad198dba7cc53d" dependencies = [ "bincode 1.3.3", "bytes", @@ -5663,7 +5663,7 @@ dependencies = [ [[package]] name = "foyer-memory" version = "0.21.0-dev" -source = "git+https://github.com/foyer-rs/foyer?rev=0593c1f7ae6cf231b3f0e89fd6fe419e69f02657#0593c1f7ae6cf231b3f0e89fd6fe419e69f02657" +source = "git+https://github.com/foyer-rs/foyer?rev=7e1f2cb1981e7d1c194f7b01fbad198dba7cc53d#7e1f2cb1981e7d1c194f7b01fbad198dba7cc53d" dependencies = [ "arc-swap", "bitflags 2.10.0", @@ -5689,7 +5689,7 @@ dependencies = [ [[package]] name = "foyer-storage" version = "0.21.0-dev" -source = "git+https://github.com/foyer-rs/foyer?rev=0593c1f7ae6cf231b3f0e89fd6fe419e69f02657#0593c1f7ae6cf231b3f0e89fd6fe419e69f02657" +source = "git+https://github.com/foyer-rs/foyer?rev=7e1f2cb1981e7d1c194f7b01fbad198dba7cc53d#7e1f2cb1981e7d1c194f7b01fbad198dba7cc53d" dependencies = [ "allocator-api2", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index eb73d93717455..62331b27d0f76 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -156,7 +156,7 @@ criterion = { version = "0.7", features = ["async_futures"] } deltalake = { version = "0.26", features = ["s3", "gcs", "datafusion"] } faiss = { version = "0.12.2-alpha.0", features = ["static"] } # TODO(MrCroxx): Switch to a release version. -foyer = { git = "https://github.com/foyer-rs/foyer", rev = "0593c1f7ae6cf231b3f0e89fd6fe419e69f02657", features = ["serde", "tracing", "nightly"] } +foyer = { git = "https://github.com/foyer-rs/foyer", rev = "7e1f2cb1981e7d1c194f7b01fbad198dba7cc53d", features = ["serde", "tracing", "nightly"] } futures-async-stream = "0.2.9" governor = { version = "0.10", default-features = false, features = ["std"] } hashbrown = { version = "0.16", features = [ diff --git a/src/storage/src/hummock/block_cache.rs b/src/storage/src/hummock/block_cache.rs index 45ac76c4ad6cb..a0ea9ce80c4b3 100644 --- a/src/storage/src/hummock/block_cache.rs +++ b/src/storage/src/hummock/block_cache.rs @@ -15,6 +15,7 @@ use std::ops::Deref; use std::sync::Arc; +use await_tree::{InstrumentAwait, SpanExt}; use foyer::{HybridCacheEntry, HybridGetOrFetch}; use risingwave_common::config::EvictionConfig; @@ -93,25 +94,14 @@ impl BlockResponse { BlockResponse::Block(block) => return Ok(block), BlockResponse::Fetch(fetch) => fetch, }; + let fetch = match fetch.try_unwrap() { + Ok(entry) => return Ok(BlockHolder::from_hybrid_cache_entry(entry)), + Err(fetch) => fetch, + }; fetch + .instrument_await("wait_pending_fetch_block".verbose()) .await .map(BlockHolder::from_hybrid_cache_entry) .map_err(HummockError::foyer_error) - // match fetch.state() { - // FetchState::Hit => fetch - // .await - // .map(BlockHolder::from_hybrid_cache_entry) - // .map_err(HummockError::foyer_error), - // _ if fetch.is_leader() => fetch - // .instrument_await("fetch_block".verbose()) - // .await - // .map(BlockHolder::from_hybrid_cache_entry) - // .map_err(HummockError::foyer_error), - // _ => fetch - // .instrument_await("wait_pending_fetch_block".verbose()) - // .await - // .map(BlockHolder::from_hybrid_cache_entry) - // .map_err(HummockError::foyer_error), - // } } } From 9b58dc5ef3e206ca6eb574de73f6878c50460593 Mon Sep 17 00:00:00 2001 From: MrCroxx Date: Mon, 17 Nov 2025 16:20:44 +0800 Subject: [PATCH 7/8] fix: fix statistics updates Signed-off-by: MrCroxx --- src/storage/src/hummock/sstable_store.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/storage/src/hummock/sstable_store.rs b/src/storage/src/hummock/sstable_store.rs index 4556f478aa89c..4a40fadb81fba 100644 --- a/src/storage/src/hummock/sstable_store.rs +++ b/src/storage/src/hummock/sstable_store.rs @@ -671,9 +671,9 @@ impl SstableStore { .map_err(foyer::Error::from) .map_err(HummockError::foyer_error)?; - stats.file_meta_total += 1; + stats.file_block_total += 1; if entry.source() == foyer::Source::Outer { - stats.file_meta_miss += 1; + stats.file_block_miss += 1; } Ok(entry) } @@ -700,7 +700,7 @@ impl SstableStore { pub async fn get_hnsw_graph( &self, graph_file: &HnswGraphFileInfo, - _stats: &mut VectorStoreCacheStats, + stats: &mut VectorStoreCacheStats, ) -> HummockResult { let store = self.store.clone(); let graph_file_path = @@ -719,6 +719,10 @@ impl SstableStore { .await .map_err(foyer::Error::from) .map_err(HummockError::foyer_error)?; + stats.hnsw_graph_total += 1; + if entry.source() == foyer::Source::Outer { + stats.hnsw_graph_miss += 1; + } HnswGraphFileHolder::try_from_entry(entry, graph_file.object_id.as_raw()) } From 48b5daeaf1690996fb765c032d7d933c95b57180 Mon Sep 17 00:00:00 2001 From: MrCroxx Date: Wed, 26 Nov 2025 15:07:30 +0800 Subject: [PATCH 8/8] chore: bump foyer to latest commit Signed-off-by: MrCroxx --- Cargo.lock | 12 ++++++------ Cargo.toml | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 09bc3cd55f7f3..1e28a99a42adc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5348,9 +5348,9 @@ dependencies = [ [[package]] name = "fastant" -version = "0.1.10" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62bf7fa928ce0c4a43bd6e7d1235318fc32ac3a3dea06a2208c44e729449471a" +checksum = "2e825441bfb2d831c47c97d05821552db8832479f44c571b97fededbf0099c07" dependencies = [ "small_ctor", "web-time", @@ -5614,7 +5614,7 @@ dependencies = [ [[package]] name = "foyer" version = "0.21.0-dev" -source = "git+https://github.com/foyer-rs/foyer?rev=7e1f2cb1981e7d1c194f7b01fbad198dba7cc53d#7e1f2cb1981e7d1c194f7b01fbad198dba7cc53d" +source = "git+https://github.com/foyer-rs/foyer?rev=66056d08a50cce0ba92b815dee1b82be0dab26ef#66056d08a50cce0ba92b815dee1b82be0dab26ef" dependencies = [ "equivalent", "fastrace", @@ -5634,7 +5634,7 @@ dependencies = [ [[package]] name = "foyer-common" version = "0.21.0-dev" -source = "git+https://github.com/foyer-rs/foyer?rev=7e1f2cb1981e7d1c194f7b01fbad198dba7cc53d#7e1f2cb1981e7d1c194f7b01fbad198dba7cc53d" +source = "git+https://github.com/foyer-rs/foyer?rev=66056d08a50cce0ba92b815dee1b82be0dab26ef#66056d08a50cce0ba92b815dee1b82be0dab26ef" dependencies = [ "bincode 1.3.3", "bytes", @@ -5663,7 +5663,7 @@ dependencies = [ [[package]] name = "foyer-memory" version = "0.21.0-dev" -source = "git+https://github.com/foyer-rs/foyer?rev=7e1f2cb1981e7d1c194f7b01fbad198dba7cc53d#7e1f2cb1981e7d1c194f7b01fbad198dba7cc53d" +source = "git+https://github.com/foyer-rs/foyer?rev=66056d08a50cce0ba92b815dee1b82be0dab26ef#66056d08a50cce0ba92b815dee1b82be0dab26ef" dependencies = [ "arc-swap", "bitflags 2.10.0", @@ -5689,7 +5689,7 @@ dependencies = [ [[package]] name = "foyer-storage" version = "0.21.0-dev" -source = "git+https://github.com/foyer-rs/foyer?rev=7e1f2cb1981e7d1c194f7b01fbad198dba7cc53d#7e1f2cb1981e7d1c194f7b01fbad198dba7cc53d" +source = "git+https://github.com/foyer-rs/foyer?rev=66056d08a50cce0ba92b815dee1b82be0dab26ef#66056d08a50cce0ba92b815dee1b82be0dab26ef" dependencies = [ "allocator-api2", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index ae561b8a233d9..6152f5baf2317 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -156,7 +156,7 @@ criterion = { version = "0.7", features = ["async_futures"] } deltalake = { version = "0.26", features = ["s3", "gcs", "datafusion"] } faiss = { version = "0.12.2-alpha.0", features = ["static"] } # TODO(MrCroxx): Switch to a release version. -foyer = { git = "https://github.com/foyer-rs/foyer", rev = "7e1f2cb1981e7d1c194f7b01fbad198dba7cc53d", features = ["serde", "tracing", "nightly"] } +foyer = { git = "https://github.com/foyer-rs/foyer", rev = "66056d08a50cce0ba92b815dee1b82be0dab26ef", features = ["serde", "tracing", "nightly"] } futures-async-stream = "0.2.9" governor = { version = "0.10", default-features = false, features = ["std"] } hashbrown = { version = "0.16", features = [