Skip to content

Conversation

@iverase
Copy link
Contributor

@iverase iverase commented Oct 22, 2025

This PR proposes a new implementation for DirectIO prefetching that is optimised for access in monotonically increase order which is the typical access when doing vector rescoring.

@elasticsearchmachine elasticsearchmachine added the Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch label Oct 22, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-search-relevance (Team:Search Relevance)

@iverase iverase marked this pull request as draft October 22, 2025 10:24
@iverase
Copy link
Contributor Author

iverase commented Oct 22, 2025

Move to draft and there is something odd. We are in places aligning the data to the blockSize and my change align data to the prefetch block size.

I guess that's really the change in the approach. What it makes very difficult to maintain slots in the current approach is that we align data using the block size but then we try to fit it in prefetch blocks of different size so a byte can be loaded differently depending on the alignment. Aligning the data to the prefetch block size ensures a position on the file will be always add to the same position on a prefetch block. I guess everything works because in my machine the prefetch block size = 2 * block size.

@benwtrent
Copy link
Member

I wonder if it's better to just check the 'floor' of already requested blocks when potentially adding a position slot.

I think the "grabbing oldest" is likely ok logic if you want to split it out of this PR

@iverase iverase marked this pull request as ready for review October 23, 2025 09:30
@iverase
Copy link
Contributor Author

iverase commented Oct 23, 2025

I made data to be blockSize align in 3f32209

Copy link
Member

@benwtrent benwtrent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this. have you benchmarked it to see if it helps?

@iverase
Copy link
Contributor Author

iverase commented Oct 30, 2025

I like this. have you benchmarked it to see if it helps?

I tried with some local examples and it helped quite a lot, of course it was a case the current code was doing very bad. I will try to get a realistic example.

@benwtrent
Copy link
Member

@iverase I tried with vector rescoring and this PR seems to make things slower. Could you confirm? Maybe I have benchmarking bias here :)

@benwtrent
Copy link
Member

I ran more benchmarks, this does seem faster.

this pr

min: 204.92
max: 355.87
50th_percentile: 271.39

baseline:

min: 163.13
max: 270.27
50th_percentile: 216.45

If you agree, I think its good to merge.

@iverase iverase merged commit 1d9ab12 into elastic:main Nov 7, 2025
34 checks passed
@iverase iverase deleted the DirectIOPrefetch branch November 7, 2025 08:53
Kubik42 pushed a commit to Kubik42/elasticsearch that referenced this pull request Nov 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

>non-issue :Search Relevance/Vectors Vector search Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch v9.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants