From b7b91bb28fba243a7c82e1d45947178546252cdf Mon Sep 17 00:00:00 2001 From: WenyXu Date: Thu, 12 Dec 2024 07:01:04 +0000 Subject: [PATCH] chore: set `file_size_hint` for cached blob reader --- src/mito2/src/sst/index/inverted_index/applier.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/mito2/src/sst/index/inverted_index/applier.rs b/src/mito2/src/sst/index/inverted_index/applier.rs index da399bcf31f4..24a5f0248c04 100644 --- a/src/mito2/src/sst/index/inverted_index/applier.rs +++ b/src/mito2/src/sst/index/inverted_index/applier.rs @@ -123,7 +123,7 @@ impl InvertedIndexApplier { index_not_found_strategy: IndexNotFoundStrategy::ReturnEmpty, }; - let blob = match self.cached_blob_reader(file_id).await { + let blob = match self.cached_blob_reader(file_id, file_size_hint).await { Ok(Some(puffin_reader)) => puffin_reader, other => { if let Err(err) = other { @@ -153,7 +153,11 @@ impl InvertedIndexApplier { } /// Creates a blob reader from the cached index file. - async fn cached_blob_reader(&self, file_id: FileId) -> Result> { + async fn cached_blob_reader( + &self, + file_id: FileId, + file_size_hint: Option, + ) -> Result> { let Some(file_cache) = &self.file_cache else { return Ok(None); }; @@ -170,6 +174,8 @@ impl InvertedIndexApplier { .reader(&puffin_file_name) .await .context(PuffinBuildReaderSnafu)? + // Skips file system stat to minimize additional I/O overhead, which can take hundreds of microseconds. + .with_file_size_hint(file_size_hint) .blob(INDEX_BLOB_TYPE) .await .context(PuffinReadBlobSnafu)?