Skip to content

Conversation

benwtrent
Copy link
Member

This adds prefetching to directIO. The idea is pretty simple,

  • configure a number of "prefetch buffers" that are the same size as the directIO buffer
  • calling prefetch will start a prefetch virtual thread to fill an available buffer
  • On read, DirectIO will attempt to refill from any prefetched buffers that match the position before attempting to do directIO itself.

When doing many prefetches and handling things in batches, this can significantly improve throughput.

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.

@github-actions github-actions bot added this to the 11.0.0 milestone Sep 23, 2025
private final int prefetchBytesSize;
private final Deque<Long> pendingPrefetches = new ArrayDeque<>();
private final FileChannel channel;
private final ExecutorService executor = Executors.newVirtualThreadPerTaskExecutor();
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the executor something you would want to share within a directory or potentially even across directories? I can't find any documentation that indicates that this pattern would be a problem.

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