Skip to content

Conversation

@abiesps
Copy link

@abiesps abiesps commented Oct 28, 2025

Description

I would appreciate feedback on BKD traversal with prefetching.

At a high level, this is what I am doing:

Start traversing the BKD tree as is,

If cell is inside the query
a) Call goes to prepareDocIDs method variation where if isLeaf is true.
b) Do not read the leaf node yet. Instead, get the leafOrdinal, if this leaf ordinal is in continuation to last matching leaf ordinal (which I am storing in visitor) i.e leafOrdinal == visitor.lastMatchingLeafOrdinal() + 1. Do not call prefetch as this should be hopefully taken care by kernel readaheads. Otherwise if its not a continuous match i.e leafOrdinal != visitor.lastMatchingLeafOrdinal() + 1, then call prefetch on this leaf node file pointer. Also store this leaf node fp in visitor for visting matching doc IDs later.
c) If its not a leafNode continue with recursion as is.
d) Visit the cached leaf node file pointers after recursion.

For remaining traversal code remains unchanged.

Related Issue

@github-actions
Copy link
Contributor

This PR does not have an entry in lucene/CHANGES.txt. Consider adding one. If the PR doesn't need a changelog entry, then add the skip-changelog label to it and you will stop receiving this reminder on future updates to the PR.

@abiesps abiesps changed the title Proposal for alternate way to traverse BKD tree with prefetching matching leaves Proposal for alternate way to traverse BKD tree with prefetching matching leaves for IO concurrency Oct 28, 2025
@abiesps
Copy link
Author

abiesps commented Oct 30, 2025

I am looking for overall feedback on high level idea for this. I do want to make the api interfaces added/modified more cleaner and possibly minimal.
Based on the directional feedback, I'll also add more tests

@github-actions
Copy link
Contributor

This PR has not had activity in the past 2 weeks, labeling it as stale. If the PR is waiting for review, notify the [email protected] list. Thank you for your contribution!

@github-actions github-actions bot added the Stale label Nov 14, 2025
@iverase
Copy link
Contributor

iverase commented Nov 14, 2025

In general, I am not in favour of adding a new intersects method to the PointValues API like you are doing with PointValues#intersectWithPrefetch. Prefetching should be an implementation detail and not leak to the API.

@abiesps
Copy link
Author

abiesps commented Nov 14, 2025

Thanks for the feedback @iverase !! I'll hide prefetching detail into existing intersect api. That would need adding some new methods to existing Visitor.

@iverase
Copy link
Contributor

iverase commented Nov 14, 2025

That would need adding some new methods to existing Visitor.

As far as we can add some default implementation, we should be ok.

@abiesps abiesps force-pushed the bkd-prefetch-optimization branch from ffc030a to 2bdef68 Compare November 14, 2025 17:07
@abiesps abiesps force-pushed the bkd-prefetch-optimization branch from 2bdef68 to a54f8e5 Compare November 14, 2025 17:10
@abiesps
Copy link
Author

abiesps commented Nov 14, 2025

@iverase I removed the new intersect api in PointValues. However I have to create a new visitor PrefetchCapableVisitor because I want to cache the prefetched leaf blocks so that I can visit them after recursion. This is a new abstract class with some state in PointValues.java. Let me know your thoughts on this.

@abiesps abiesps force-pushed the bkd-prefetch-optimization branch 3 times, most recently from d0bc069 to e0f150b Compare November 14, 2025 20:41
@abiesps abiesps force-pushed the bkd-prefetch-optimization branch from e0f150b to 2d488aa Compare November 14, 2025 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants