From dcaeee89700afc639889d55832cdcbbb5970bb9c Mon Sep 17 00:00:00 2001 From: chihe Date: Thu, 30 Oct 2025 15:22:36 +0800 Subject: [PATCH] fix(client): update rightOffset to make window for aheadRead move forward @formatter:off Signed-off-by: chihe --- proto/mount_options.go | 2 +- sdk/data/stream/extent_client.go | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/proto/mount_options.go b/proto/mount_options.go index a5ebac19f..0666e70c3 100644 --- a/proto/mount_options.go +++ b/proto/mount_options.go @@ -191,7 +191,7 @@ func InitMountOptions(opts []MountOption) { opts[AheadReadEnable] = MountOption{"aheadReadEnable", "enable ahead read", "", false} opts[AheadReadTotalMemGB] = MountOption{"aheadReadTotalMemGB", "ahead read total mem(GB)", "", int64(30)} opts[AheadReadBlockTimeOut] = MountOption{"aheadReadBlockTimeOut", "ahead read block expiration time", "", int64(3)} - opts[AheadReadWindowCnt] = MountOption{"aheadReadWindowCnt", "ahead read window block count", "", int64(8)} + opts[AheadReadWindowCnt] = MountOption{"aheadReadWindowCnt", "ahead read window block count", "", int64(128)} opts[ForceRemoteCache] = MountOption{"forceRemoteCache", "All read requests are handled by the remote cache.", "", false} opts[DebugCluster] = MountOption{"debugCluster", "display cluster name", "", ""} opts[EnableAsyncFlush] = MountOption{"enableAsyncFlush", "async flush extent handler", "", true} diff --git a/sdk/data/stream/extent_client.go b/sdk/data/stream/extent_client.go index ddafeab10..ce0a9a833 100644 --- a/sdk/data/stream/extent_client.go +++ b/sdk/data/stream/extent_client.go @@ -509,6 +509,7 @@ func (client *ExtentClient) OpenStream(inode uint64, openForWrite, isCache bool, if !ok { s = NewStreamer(client, inode, openForWrite, isCache, fullPath) client.streamers[inode] = s + log.LogDebugf("action[OpenStream] create new streamer for ino(%v) %p", inode, s) } else { // If you open a file in write mode first and then open the same file // in read mode without modifying any attributes, maintaining the file's immutability status. @@ -516,6 +517,11 @@ func (client *ExtentClient) OpenStream(inode uint64, openForWrite, isCache bool, s.openForWrite = openForWrite } // TODO: update isCache? + log.LogDebugf("action[OpenStream] reuse streamer for ino(%v)%p", inode, s) + // update rightOffset to make window for aheadRead move forward + if s.aheadReadWindow != nil { + s.aheadReadWindow.rightOffset = 0 + } } return s.IssueOpenRequest() } @@ -554,6 +560,10 @@ func (client *ExtentClient) OpenStreamWithCache(inode uint64, needBCache, openFo if !client.disableMetaCache && needBCache { client.streamerList.PushFront(inode) } + } else { + if s.aheadReadWindow != nil { + s.aheadReadWindow.rightOffset = 0 + } } s.needBCache = needBCache if !s.isOpen && !client.disableMetaCache {