Skip to content

Commit 8646fe3

Browse files
Enable readahead by default
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.
1 parent 7b5117f commit 8646fe3

4 files changed

Lines changed: 18 additions & 1 deletion

File tree

fuse.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,17 @@ func initMount(c *Conn, conf *mountConfig) error {
232232
}
233233
c.proto = proto
234234

235+
maxReadahead := conf.maxReadahead
236+
if maxReadahead == 0 {
237+
maxReadahead = defaultReadahead
238+
}
239+
if maxReadahead > r.MaxReadahead {
240+
maxReadahead = r.MaxReadahead
241+
}
242+
235243
s := &InitResponse{
236244
Library: proto,
237-
MaxReadahead: conf.maxReadahead,
245+
MaxReadahead: maxReadahead,
238246
MaxWrite: maxWrite,
239247
Flags: InitBigWrites | conf.initFlags,
240248
}

fuse_darwin.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@ package fuse
77
// 16MB value. See TestSetxattr16MB and
88
// https://github.com/bazil/fuse/issues/42
99
const maxWrite = 16 * 1024 * 1024
10+
11+
// Default kernel readahead.
12+
const defaultReadahead = 128 * 1024

fuse_freebsd.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@ package fuse
44
//
55
// This number is just a guess.
66
const maxWrite = 128 * 1024
7+
8+
// Default kernel readahead.
9+
const defaultReadahead = 128 * 1024

fuse_linux.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ package fuse
55
// Linux 4.2.0 has been observed to cap this value at 128kB
66
// (FUSE_MAX_PAGES_PER_REQ=32, 4kB pages).
77
const maxWrite = 128 * 1024
8+
9+
// Default kernel readahead.
10+
const defaultReadahead = 128 * 1024

0 commit comments

Comments
 (0)