Skip to content

Commit

Permalink
cmd/mount: add max-readahead option to set the max buffer of each r…
Browse files Browse the repository at this point in the history
…eadahead (#5225)
  • Loading branch information
ddrid authored Oct 12, 2024
1 parent fe6bb88 commit 1ca8bba
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions cmd/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ func dataCacheFlags() []cli.Flag {
Value: "300M",
Usage: "total read/write buffering in MiB",
},
&cli.StringFlag{
Name: "max-readahead",
Usage: "max buffering for read ahead in MiB",
},
&cli.IntFlag{
Name: "prefetch",
Value: 1,
Expand Down
1 change: 1 addition & 0 deletions cmd/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ func getChunkConf(c *cli.Context, format *meta.Format) *chunk.Config {
Writeback: c.Bool("writeback"),
Prefetch: c.Int("prefetch"),
BufferSize: utils.ParseBytes(c, "buffer-size", 'M'),
Readahead: int(utils.ParseBytes(c, "max-readahead", 'M')),
UploadLimit: utils.ParseMbps(c, "upload-limit") * 1e6 / 8,
DownloadLimit: utils.ParseMbps(c, "download-limit") * 1e6 / 8,
UploadDelay: utils.Duration(c.String("upload-delay")),
Expand Down
2 changes: 1 addition & 1 deletion pkg/vfs/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ func NewDataReader(conf *Config, m meta.Meta, store chunk.ChunkStore) DataReader
readAheadTotal = int(conf.Chunk.BufferSize / 10 * 8) // 80% of total buffer
}
if conf.Chunk.Readahead > 0 {
readAheadMax = conf.Chunk.Readahead
readAheadMax = utils.Min(conf.Chunk.Readahead, readAheadTotal)
}
r := &dataReader{
m: m,
Expand Down

0 comments on commit 1ca8bba

Please sign in to comment.