Skip to content

Commit 6cf6ba5

Browse files
committed
Add memory usage tracking method to file prefetch buffer
1 parent 5938ad2 commit 6cf6ba5

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

file/file_prefetch_buffer.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ struct BufferInfo {
128128
offset < offset_ + async_req_len_);
129129
}
130130

131-
size_t CurrentSize() { return buffer_.CurrentSize(); }
131+
size_t CurrentSize() const { return buffer_.CurrentSize(); }
132132
};
133133

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

399+
size_t GetTotalBufferSize() const {
400+
size_t total = 0;
401+
for (const BufferInfo* buf_info : bufs_) {
402+
if (buf_info != nullptr) {
403+
total += buf_info->CurrentSize();
404+
}
405+
}
406+
if (overlap_buf_ != nullptr) {
407+
total += overlap_buf_->CurrentSize();
408+
}
409+
return total;
410+
}
411+
399412
void TEST_GetBufferOffsetandSize(
400413
std::vector<std::tuple<uint64_t, size_t, bool>>& buffer_info) {
401414
for (size_t i = 0; i < bufs_.size(); i++) {

0 commit comments

Comments
 (0)