mirror of
https://github.com/distribution/distribution.git
synced 2025-07-17 08:53:54 +00:00
feat(filereader): allow tuning fileReader buffer size via FILE_READER_BUFFER_MB
This commit is contained in:
parent
28b02b3764
commit
3294f814e9
@ -6,16 +6,32 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"os"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
storagedriver "github.com/distribution/distribution/v3/registry/storage/driver"
|
storagedriver "github.com/distribution/distribution/v3/registry/storage/driver"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var defaultBufMB = getEnvFloat("FILE_READER_BUFFER_MB", 4.0)
|
||||||
|
|
||||||
// TODO(stevvooe): Set an optimal buffer size here. We'll have to
|
// TODO(stevvooe): Set an optimal buffer size here. We'll have to
|
||||||
// understand the latency characteristics of the underlying network to
|
// understand the latency characteristics of the underlying network to
|
||||||
// set this correctly, so we may want to leave it to the driver. For
|
// set this correctly, so we may want to leave it to the driver. For
|
||||||
// out of process drivers, we'll have to optimize this buffer size for
|
// out of process drivers, we'll have to optimize this buffer size for
|
||||||
// local communication.
|
// local communication.
|
||||||
const fileReaderBufferSize = 4 * 1024 * 1024
|
var fileReaderBufferSize = int(defaultBufMB * 1024 * 1024)
|
||||||
|
|
||||||
|
func getEnvFloat(key string, def float64) float64 {
|
||||||
|
valStr := os.Getenv(key)
|
||||||
|
if valStr == "" {
|
||||||
|
return def
|
||||||
|
}
|
||||||
|
val, err := strconv.ParseFloat(valStr, 64)
|
||||||
|
if err != nil {
|
||||||
|
return def
|
||||||
|
}
|
||||||
|
return val
|
||||||
|
}
|
||||||
|
|
||||||
// remoteFileReader provides a read seeker interface to files stored in
|
// remoteFileReader provides a read seeker interface to files stored in
|
||||||
// storagedriver. Used to implement part of layer interface and will be used
|
// storagedriver. Used to implement part of layer interface and will be used
|
||||||
|
Loading…
Reference in New Issue
Block a user