mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
d70ba7eb37
This should improve performance when reading many small blocks.
22 lines
397 B
Go
22 lines
397 B
Go
// +build linux freebsd
|
|
|
|
package fs
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"golang.org/x/sys/unix"
|
|
)
|
|
|
|
func fadviseSequentialRead(f *os.File, prefetch bool) error {
|
|
fd := int(f.Fd())
|
|
mode := unix.FADV_SEQUENTIAL
|
|
if prefetch {
|
|
mode |= unix.FADV_WILLNEED
|
|
}
|
|
if err := unix.Fadvise(int(fd), 0, 0, mode); err != nil {
|
|
return fmt.Errorf("error returned from unix.Fadvise(%d): %s", mode, err)
|
|
}
|
|
return nil
|
|
}
|