diff --git a/tsdb/engine/tsm1/reader.go b/tsdb/engine/tsm1/reader.go index b3b13bd0838..77e1759c5b0 100644 --- a/tsdb/engine/tsm1/reader.go +++ b/tsdb/engine/tsm1/reader.go @@ -11,6 +11,7 @@ import ( "sort" "sync" "sync/atomic" + "syscall" "github.com/influxdata/influxdb/pkg/bytesutil" ) @@ -1374,6 +1375,10 @@ func (m *mmapAccessor) init() (*indirectIndex, error) { return nil, fmt.Errorf("mmapAccessor: invalid indexStart") } + // Hint to the kernal that we will be reading the file. It would be better to hint + // that we will be reading the index section, but that doesn't seem to work ATM. + _ = madvise(m.b, syscall.MADV_WILLNEED) + m.index = NewIndirectIndex() if err := m.index.UnmarshalBinary(m.b[indexStart:indexOfsPos]); err != nil { return nil, err