From 5c63ef6819ff130a7a01a6f04708d69716f3f22e Mon Sep 17 00:00:00 2001 From: Changxin Miao Date: Fri, 17 May 2024 13:46:46 +0800 Subject: [PATCH] Fix read buffer usage (#4860) Signed-off-by: Changxin Miao --- pkg/vfs/reader.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/vfs/reader.go b/pkg/vfs/reader.go index 2a29189ad400..5938b5cd9e30 100644 --- a/pkg/vfs/reader.go +++ b/pkg/vfs/reader.go @@ -269,8 +269,8 @@ func (s *sliceReader) delete() { } else { s.file.last = s.prev } + atomic.AddInt64(&readBufferUsed, -int64(cap(s.page.Data))) s.page.Release() - atomic.AddInt64(&readBufferUsed, -int64(s.block.len)) } type session struct { @@ -327,7 +327,7 @@ func (f *fileReader) newSlice(block *frange) *sliceReader { *(f.last) = s f.last = &(s.next) go s.run() - atomic.AddInt64(&readBufferUsed, int64(s.block.len)) + atomic.AddInt64(&readBufferUsed, int64(cap(s.page.Data))) return s }