diff options
| author | famosss <zzq09494@ly.com> | 2022-09-16 15:30:40 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-09-16 00:30:40 -0700 |
| commit | d949a238b83dc05fe79a1fb02a047a25355feb7b (patch) | |
| tree | 11cfe94e1ee8c09bfe5f67716987e62e1edc3f39 /weed/storage | |
| parent | cf90f76a35df8c8509ad3ccece566ecb0b74cf66 (diff) | |
| download | seaweedfs-d949a238b83dc05fe79a1fb02a047a25355feb7b.tar.xz seaweedfs-d949a238b83dc05fe79a1fb02a047a25355feb7b.zip | |
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
Diffstat (limited to 'weed/storage')
| -rw-r--r-- | weed/storage/store.go | 4 | ||||
| -rw-r--r-- | weed/storage/volume_read.go | 2 |
2 files changed, 5 insertions, 1 deletions
diff --git a/weed/storage/store.go b/weed/storage/store.go index 48736c1a9..45f87525b 100644 --- a/weed/storage/store.go +++ b/weed/storage/store.go @@ -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 } /* diff --git a/weed/storage/volume_read.go b/weed/storage/volume_read.go index e045137b4..ee3cff45c 100644 --- a/weed/storage/volume_read.go +++ b/weed/storage/volume_read.go @@ -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 |
