Skip to content

Commit

Permalink
Additional Fixes and comments
Browse files Browse the repository at this point in the history
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
  • Loading branch information
akankshamahajan15 committed Dec 1, 2023
1 parent f73c6de commit dc62c1a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
1 change: 0 additions & 1 deletion file/file_prefetch_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,6 @@ Status FilePrefetchBuffer::PrefetchAsyncInternal(const IOOptions& opts,
UpdateStats(/*found_in_buffer=*/false,
/*length_found=*/original_length - length);
} else {
end_offset1 = buf->offset_ + buf->buffer_.CurrentSize();
UpdateStats(/*found_in_buffer=*/true, original_length);
}

Expand Down
17 changes: 17 additions & 0 deletions file/file_prefetch_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,14 @@ class FilePrefetchBuffer {
Status s = fs_->AbortIO(handles);
assert(s.ok());
}

for (auto& buf : bufs_) {
if (buf->io_handle_ != nullptr) {
DestroyAndClearIOHandle(buf);
buf->async_read_in_progress_ = false;
buf->ClearBuffer();
}
}
}

// Prefetch buffer bytes discarded.
Expand Down Expand Up @@ -195,6 +203,11 @@ class FilePrefetchBuffer {
delete buf;
buf = nullptr;
}

for (auto& buf : overlap_bufs_) {
delete buf;
buf = nullptr;
}
}

bool Enabled() const { return enable_; }
Expand Down Expand Up @@ -274,6 +287,10 @@ class FilePrefetchBuffer {
// - block is sequential with the previous read and,
// - num_file_reads_ + 1 (including this read) >
// num_file_reads_for_auto_readahead_
if (bufs_.empty()) {
return;
}

size_t curr_size = bufs_.front()->async_read_in_progress_
? bufs_.front()->async_req_len_
: bufs_.front()->buffer_.CurrentSize();
Expand Down

0 comments on commit dc62c1a

Please sign in to comment.