volume: add "readBufSize" option to customize read optimization (#3702)
* simplify a bit * feat: volume: add "readBufSize" option to customize read optimization * refactor : redbufSIze -> readBufferSize * simplify a bit * simplify a bit
This commit is contained in:
@@ -44,6 +44,10 @@ type ReadOption struct {
|
||||
// * read requests should complete asap, not blocking other requests.
|
||||
// * write requests may see high latency when downloading large files.
|
||||
HasSlowRead bool
|
||||
|
||||
// increasing ReadBufferSize can reduce the number of get locks times and shorten read P99 latency.
|
||||
// but will increase memory usage a bit. Use with hasSlowRead normally.
|
||||
ReadBufferSize int
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -136,7 +136,7 @@ func (v *Volume) readNeedleDataInto(n *needle.Needle, readOption *ReadOption, wr
|
||||
actualOffset += int64(MaxPossibleVolumeSize)
|
||||
}
|
||||
|
||||
buf := mem.Allocate(min(1024*1024, int(size)))
|
||||
buf := mem.Allocate(min(readOption.ReadBufferSize, int(size)))
|
||||
defer mem.Free(buf)
|
||||
|
||||
// read needle data
|
||||
|
||||
Reference in New Issue
Block a user