Skip to content

Commit 2eaf8aa

Browse files
committed
Regate the binary search pivots as it was just polluting cache
1 parent e62cf3d commit 2eaf8aa

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

sa-index/src/sa_searcher.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,8 +597,15 @@ impl Searcher {
597597
/// call. One fetch will be wasted; both are free (single non-blocking CPU instruction).
598598
/// From iteration 2 onward the needed SA entry is already in L1/L2 cache.
599599
#[inline]
600+
#[cfg_attr(not(feature = "mmap"), allow(unused_variables))]
600601
fn prefetch_binary_search_pivots(&self, lo: usize, center: usize, hi: usize) {
602+
// Pivot prefetching pays off only for mmap where cold pages are the bottleneck.
603+
// For preloaded (in-memory) data, hot SA positions stay in L3 from temporal
604+
// locality, so PREFETCHT0 adds overhead without benefit and pollutes L1 for
605+
// the text comparison that follows immediately in the same iteration.
606+
#[cfg(feature = "mmap")]
601607
self.sa.prefetch_sa_index((lo + center) / 2);
608+
#[cfg(feature = "mmap")]
602609
self.sa.prefetch_sa_index((center + hi) / 2);
603610
}
604611

0 commit comments

Comments
 (0)