Skip to content

Commit

Permalink
Enable readahead by default
Browse files Browse the repository at this point in the history
The Linux kernel and FUSE default to a readahead size of 128 KB, but
because there is no default value for conf.maxReadhead, it gets
completely disabled leading to huge overhead due to many page sized
FUSE read requests with only 4 KB.
  • Loading branch information
felixbuenemann committed Mar 1, 2020
1 parent 7b5117f commit 8646fe3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
10 changes: 9 additions & 1 deletion fuse.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,17 @@ func initMount(c *Conn, conf *mountConfig) error {
}
c.proto = proto

maxReadahead := conf.maxReadahead
if maxReadahead == 0 {
maxReadahead = defaultReadahead
}
if maxReadahead > r.MaxReadahead {
maxReadahead = r.MaxReadahead
}

s := &InitResponse{
Library: proto,
MaxReadahead: conf.maxReadahead,
MaxReadahead: maxReadahead,
MaxWrite: maxWrite,
Flags: InitBigWrites | conf.initFlags,
}
Expand Down
3 changes: 3 additions & 0 deletions fuse_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ package fuse
// 16MB value. See TestSetxattr16MB and
// https://github.com/bazil/fuse/issues/42
const maxWrite = 16 * 1024 * 1024

// Default kernel readahead.
const defaultReadahead = 128 * 1024
3 changes: 3 additions & 0 deletions fuse_freebsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ package fuse
//
// This number is just a guess.
const maxWrite = 128 * 1024

// Default kernel readahead.
const defaultReadahead = 128 * 1024
3 changes: 3 additions & 0 deletions fuse_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ package fuse
// Linux 4.2.0 has been observed to cap this value at 128kB
// (FUSE_MAX_PAGES_PER_REQ=32, 4kB pages).
const maxWrite = 128 * 1024

// Default kernel readahead.
const defaultReadahead = 128 * 1024

0 comments on commit 8646fe3

Please sign in to comment.