Flexible MultiRead demonstration #13331
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We want to enable
FilePrefetchBuffer
to make read requests that are block aligned whenever possible. This means rounding up the read requests to the next block boundary.There are quite a few different options we can go down, and I have written some analysis on their tradeoffs.
Working through a sample prototype / hacky implementation can make the decision more obvious, and in this case I think that was very true.
It looks like the "flexible reads" approach is the most attractive. However, we will be using the
MultiRead
API, rather than theRead
API, since we want to take advantage of the file system buffer reuse optimization, which onlyMultiRead
supports currently. We can easily add new fields toFSReadRequest
to support our use case, while maintaining backwards compatibility.I really think that our final approach can be very, very simple. I put one approach in this PR where we only need to:
FSRandomAccessFile
andRandomAccessFileReader
FSReadRequest
Minor decisions to be made:
IOOptions
to gate the feature. Right now we can just rely onfor_compaction
which is given to us inTryReadFromCache
. In the future we want to expand this to low-priority reads, but right nowIOOptions
's priority field is marked as deprecated.FSRandomAccessFile
/RandomAccessFileReader
. We still would want to specify some max read size for rate limiting purposes, but this option may work if we allow more flexibility into how much more data can be returned. As long as our max readahead size covers the block boundary, we would benefit from the optimization. Personally I don't think adding the block size interface is too bad, since it is a somewhat general concept.I think this approach is very promising. We can hide almost all of the complexity on the RocksDB end, maintain backwards compatibility / safety, and still make the optimally sized read requests.