Set filesystem constructor parameter for FilePrefetchBuffer inside PrefetchTail #13157
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.
Summary
After #13118 was merged, I did some investigation to see whether the file system buffer reuse code was actually being used.
The good news is that I was able to see from the CPU profiling results that my code is getting invoked through the warm storage stress tests.
The bad news is that most of the time, the optimization is not being used, so we end up going through the regular old
RandomAccessFileReader::Read
path.Here is the entire function call chain up to
FilePrefetchBuffer::Read
At this point, we split into
rocksdb::RandomAccessFileReader::Read
androcksdb::FilePrefetchBuffer::FSBufferDirectRead
.FSBufferDirectRead
gets called <3% of the time.I think the root cause is that the
FileSystem* fs
parameter is not getting passed into theFilePrefetchBuffer
constructor. Whenfs
isnullptr
,UseFSBuffer()
will always returnfalse
and we do not end up callingFSBufferDirectRead
.Luckily, it does not seem like there are too many places I need to change.
BlockBasedTable
resets itsprefetch_buffer
in 3 separate places. When it disables the prefetch buffer (2/3 of the instances), we don't care about whether thefs
parameter is there. This PR is addressing the third instance, where it is not trying to disable the buffer.Note that there is another method,
PrefetchBufferCollection::GetOrCreatePrefetchBuffer
that creates newFilePrefetchBuffer
s without thefs
parameter. This method gets called bycompaction_iterator
andmerge_helper
. I think we can address this in a subsequent PR:rocksdb::FilePrefetchBuffer::FSBufferDirectRead
was invoked.PrefetchBufferCollection
Test Plan
The existing unit test coverage guards against obvious bugs. I ran another set of performance tests to confirm there were no regressions in CPU utilization.