diff --git a/file/file_prefetch_buffer.h b/file/file_prefetch_buffer.h index 418dc752ad..ae84724960 100644 --- a/file/file_prefetch_buffer.h +++ b/file/file_prefetch_buffer.h @@ -234,6 +234,8 @@ class FilePrefetchBuffer { // tracked if track_min_offset = true. size_t min_offset_read() const { return min_offset_read_; } + size_t GetPrefetchOffset() const { return bufs_[curr_].offset_; } + // Called in case of implicit auto prefetching. void UpdateReadPattern(const uint64_t& offset, const size_t& len, bool decrease_readaheadsize) { diff --git a/table/block_based/block_based_table_reader.cc b/table/block_based/block_based_table_reader.cc index 115a5315de..3294369758 100644 --- a/table/block_based/block_based_table_reader.cc +++ b/table/block_based/block_based_table_reader.cc @@ -830,10 +830,7 @@ Status BlockBasedTable::PrefetchTail( // index/filter is enabled and top-level partition pinning is enabled. // That's because we need to issue readahead before we read the // properties, at which point we don't yet know the index type. - tail_prefetch_size = - prefetch_all || preload_all - ? static_cast(4 * 1024 + 0.01 * file_size) - : 4 * 1024; + tail_prefetch_size = prefetch_all || preload_all ? 512 * 1024 : 4 * 1024; ROCKS_LOG_WARN(logger, "Tail prefetch size %zu is calculated based on heuristics", diff --git a/table/block_based/partitioned_filter_block.cc b/table/block_based/partitioned_filter_block.cc index 4ac352c14a..faddaeb1e3 100644 --- a/table/block_based/partitioned_filter_block.cc +++ b/table/block_based/partitioned_filter_block.cc @@ -493,7 +493,8 @@ Status PartitionedFilterBlockReader::CacheDependencies( handle.offset() + handle.size() + BlockBasedTable::kBlockTrailerSize; uint64_t prefetch_len = last_off - prefetch_off; std::unique_ptr prefetch_buffer; - if (tail_prefetch_buffer == nullptr || !tail_prefetch_buffer->Enabled()) { + if (tail_prefetch_buffer == nullptr || !tail_prefetch_buffer->Enabled() || + tail_prefetch_buffer->GetPrefetchOffset() > prefetch_off) { rep->CreateFilePrefetchBuffer( 0, 0, &prefetch_buffer, false /* Implicit autoreadahead */, 0 /*num_reads_*/, 0 /*num_file_reads_for_auto_readahead*/); diff --git a/table/block_based/partitioned_index_reader.cc b/table/block_based/partitioned_index_reader.cc index 7d73d0678d..d1c5591eb6 100644 --- a/table/block_based/partitioned_index_reader.cc +++ b/table/block_based/partitioned_index_reader.cc @@ -165,7 +165,8 @@ Status PartitionIndexReader::CacheDependencies( handle.offset() + BlockBasedTable::BlockSizeWithTrailer(handle); uint64_t prefetch_len = last_off - prefetch_off; std::unique_ptr prefetch_buffer; - if (tail_prefetch_buffer == nullptr || !tail_prefetch_buffer->Enabled()) { + if (tail_prefetch_buffer == nullptr || !tail_prefetch_buffer->Enabled() || + tail_prefetch_buffer->GetPrefetchOffset() > prefetch_off) { rep->CreateFilePrefetchBuffer( 0, 0, &prefetch_buffer, false /*Implicit auto readahead*/, 0 /*num_reads_*/, 0 /*num_file_reads_for_auto_readahead*/);