Skip to content

Commit

Permalink
Use MADV_WILLNEED when loading TSM files
Browse files Browse the repository at this point in the history
When the TSM index is large, this hints to the kernel to start
faulting in pages to avoid lots of smaller page faults.
  • Loading branch information
jwilder committed Jan 30, 2018
1 parent 94edb63 commit 460143f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tsdb/engine/tsm1/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"sort"
"sync"
"sync/atomic"
"syscall"

"github.com/influxdata/influxdb/pkg/bytesutil"
)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 460143f

Please sign in to comment.