Skip to content

Commit

Permalink
Decrease Linux and FreeBSD max request payload size from 16MB to 128kB
Browse files Browse the repository at this point in the history
OSX is kept at 16MB to avoid triggering a bug with large Setxattr
calls: #42

While this was already using sync.Pool and in theory reusing the
buffers, real world isn't as merciful. Apparently 2*16MB plus some
waste from other parts of the system was enough to keep triggering GC
runs all too often. Decreasing the buffer size helps keep us below
that threshold.

New buffer size is the largest Write payload size observed on Linux,
and the most common size for write-heavy workloads.

Improves performance and decreases memory use on Linux.

Thanks to Aaron Jacobs <[email protected]>
and Damien Tournoud <[email protected]>.
  • Loading branch information
tv42 committed Jun 24, 2016
1 parent b0373c4 commit 9e8e652
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
3 changes: 0 additions & 3 deletions fuse.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,9 +403,6 @@ func (h *Header) RespondError(err error) {
h.respond(buf)
}

// Maximum file write size we are prepared to receive from the kernel.
const maxWrite = 16 * 1024 * 1024

// All requests read from the kernel, without data, are shorter than
// this.
var maxRequestSize = syscall.Getpagesize()
Expand Down
9 changes: 9 additions & 0 deletions fuse_darwin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package fuse

// Maximum file write size we are prepared to receive from the kernel.
//
// This value has to be >=16MB or OSXFUSE (3.4.0 observed) will
// forcibly close the /dev/fuse file descriptor on a Setxattr with a
// 16MB value. See TestSetxattr16MB and
// https://github.com/bazil/fuse/issues/42
const maxWrite = 16 * 1024 * 1024
6 changes: 6 additions & 0 deletions fuse_freebsd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package fuse

// Maximum file write size we are prepared to receive from the kernel.
//
// This number is just a guess.
const maxWrite = 128 * 1024
7 changes: 7 additions & 0 deletions fuse_linux.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package fuse

// Maximum file write size we are prepared to receive from the kernel.
//
// 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

0 comments on commit 9e8e652

Please sign in to comment.