Skip to content

Commit

Permalink
fix readahead bug then trying to turn off readahead totally
Browse files Browse the repository at this point in the history
  • Loading branch information
Timur Vankov committed Jan 12, 2025
1 parent 5714660 commit d524296
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 8 additions & 0 deletions pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ func Min(a, b int) int {
return b
}

// Max returns max of 2 int
func Max(a, b int) int {
if a > b {
return a
}
return b
}

func Min64(a, b uint64) uint64 {
if a < b {
return a
Expand Down
5 changes: 1 addition & 4 deletions pkg/vfs/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -697,13 +697,10 @@ type dataReader struct {

func NewDataReader(conf *Config, m meta.Meta, store chunk.ChunkStore) DataReader {
var readAheadTotal = 256 << 20
var readAheadMax = conf.Chunk.BlockSize * 8
var readAheadMax = utils.Min(utils.Max(conf.Chunk.Readahead, 0), readAheadTotal)
if conf.Chunk.BufferSize > 0 {
readAheadTotal = int(conf.Chunk.BufferSize / 10 * 8) // 80% of total buffer
}
if conf.Chunk.Readahead > 0 {
readAheadMax = utils.Min(conf.Chunk.Readahead, readAheadTotal)
}
r := &dataReader{
m: m,
store: store,
Expand Down

0 comments on commit d524296

Please sign in to comment.