Skip to content

Commit

Permalink
Add memory usage tracking method to file prefetch buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
archang19 committed Jan 15, 2025
1 parent 5938ad2 commit 6cf6ba5
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion file/file_prefetch_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ struct BufferInfo {
offset < offset_ + async_req_len_);
}

size_t CurrentSize() { return buffer_.CurrentSize(); }
size_t CurrentSize() const { return buffer_.CurrentSize(); }
};

enum class FilePrefetchBufferUsage {
Expand Down Expand Up @@ -396,6 +396,19 @@ class FilePrefetchBuffer {
// Callback function passed to underlying FS in case of asynchronous reads.
void PrefetchAsyncCallback(FSReadRequest& req, void* cb_arg);

size_t GetTotalBufferSize() const {
size_t total = 0;
for (const BufferInfo* buf_info : bufs_) {
if (buf_info != nullptr) {
total += buf_info->CurrentSize();
}
}
if (overlap_buf_ != nullptr) {
total += overlap_buf_->CurrentSize();
}
return total;
}

void TEST_GetBufferOffsetandSize(
std::vector<std::tuple<uint64_t, size_t, bool>>& buffer_info) {
for (size_t i = 0; i < bufs_.size(); i++) {
Expand Down

0 comments on commit 6cf6ba5

Please sign in to comment.