lucene icon indicating copy to clipboard operation
lucene copied to clipboard

Share prefetch hit counter across slices/clones

Open shubhamsrkdev opened this issue 10 months ago • 2 comments

Description

In the discussion in #14156 we found out:

Lucene’s MemorySegmentIndexInput uses a counter (consecutivePrefetchHitCount) to avoid repeated calls to isLoaded() and madviseWillNeed().

However every slice() or clone() resets it. This means prefetch suppression never converges, causing repeated expensive checks on the same underlying memory.

This issue tracks whether we should share the counter across slices/clones to make suppression effective.

Version and environment details

No response

shubhamsrkdev avatar Jan 14 '26 18:01 shubhamsrkdev

I would like to work on this. I propose modifying MemorySegmentIndexInput to share the consecutivePrefetchHitCount state across slices and clones (likely via a shared mutable container) so that prefetch suppression converges correctly

ML-dev-crypto avatar Jan 16 '26 19:01 ML-dev-crypto

Sorry @ML-dev-crypto, missed your comment, but feel free to review the PR: https://github.com/apache/lucene/pull/15585

shubhamsrkdev avatar Jan 19 '26 12:01 shubhamsrkdev