From 3504ce97ef3136f57afa1921fd8f9f7b6c6475dc Mon Sep 17 00:00:00 2001 From: Marcus Holland-Moritz Date: Thu, 14 Nov 2024 11:14:55 +0100 Subject: [PATCH] fix(block_cache): skip prefetch if the block is already cached --- src/reader/internal/block_cache.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/reader/internal/block_cache.cpp b/src/reader/internal/block_cache.cpp index 8306c1a0..8667dacc 100644 --- a/src/reader/internal/block_cache.cpp +++ b/src/reader/internal/block_cache.cpp @@ -385,10 +385,10 @@ class block_cache_ final : public block_cache::impl { scope_exit do_prefetch{[&] { if (auto next = seq_access_detector_->prefetch()) { - sequential_prefetches_.fetch_add(1, std::memory_order_relaxed); + std::lock_guard lock(mx_); - { - std::lock_guard lock(mx_); + if (cache_.findWithoutPromotion(*next) == cache_.end()) { + sequential_prefetches_.fetch_add(1, std::memory_order_relaxed); create_cached_block(*next, std::promise{}, 0, std::numeric_limits::max()); }