Skip to content

Commit

Permalink
Make test parameterized to cover async prefetch too
Browse files Browse the repository at this point in the history
  • Loading branch information
archang19 committed Nov 19, 2024
1 parent 0a71c0f commit a070928
Show file tree
Hide file tree
Showing 4 changed files with 248 additions and 119 deletions.
10 changes: 10 additions & 0 deletions file/file_prefetch_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,16 @@ Status FilePrefetchBuffer::PrefetchInternal(const IOOptions& opts,
if (copy_to_overlap_buffer) {
// Data is overlapping i.e. some of the data has been copied to overlap
// buffer and remaining will be updated below.
// Note: why do we not end up performing a duplicate copy when we already
// copy to the overlap buffer in HandleOverlappingAsyncData /
// HandleOverlappingSyncData? The reason is that when we call
// CopyDataToOverlapBuffer, if the buffer is only a "partial hit", then we
// clear it out since it does not have any more useful data once we copy
// to the overlap buffer. Once we reallocate a fresh buffer, that buffer
// will have no data, and it will be the "first" buffer when num_buffers_
// = 1. When num_buffers_ > 1, we call ClearOutdatedData() so we know
// that, if we get to this point in the control flow, the "front" buffer
// has to have the data we need.
size_t initial_buf_size = overlap_buf_->CurrentSize();
CopyDataToOverlapBuffer(buf, offset, length);
UpdateStats(
Expand Down
11 changes: 6 additions & 5 deletions file/file_prefetch_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -389,12 +389,13 @@ class FilePrefetchBuffer {
void PrefetchAsyncCallback(FSReadRequest& req, void* cb_arg);

void TEST_GetBufferOffsetandSize(
std::vector<std::pair<uint64_t, size_t>>& buffer_info) {
std::vector<std::tuple<uint64_t, size_t, bool>>& buffer_info) {
for (size_t i = 0; i < bufs_.size(); i++) {
buffer_info[i].first = bufs_[i]->offset_;
buffer_info[i].second = bufs_[i]->async_read_in_progress_
? bufs_[i]->async_req_len_
: bufs_[i]->CurrentSize();
std::get<0>(buffer_info[i]) = bufs_[i]->offset_;
std::get<1>(buffer_info[i]) = bufs_[i]->async_read_in_progress_
? bufs_[i]->async_req_len_
: bufs_[i]->CurrentSize();
std::get<2>(buffer_info[i]) = bufs_[i]->async_read_in_progress_;
}
}

Expand Down
Loading

0 comments on commit a070928

Please sign in to comment.