From 8cb1c36cfcbce5b625d606ee281fcc3edf322460 Mon Sep 17 00:00:00 2001 From: Luke Lombardi Date: Sun, 24 May 2026 16:24:17 -0400 Subject: [PATCH] Tune FUSE init limits for geesefs --- connection.go | 16 ++++++++++++++++ conversions.go | 5 ++--- internal/buffer/in_message_linux.go | 4 ++-- mount_config.go | 10 ++++++++++ ops.go | 11 ++++++----- 5 files changed, 36 insertions(+), 10 deletions(-) diff --git a/connection.go b/connection.go index 0d99f0e..073eb4d 100644 --- a/connection.go +++ b/connection.go @@ -56,6 +56,11 @@ var contextKey interface{} = contextKeyType(0) // Reading a page at a time is a drag. Ask for a larger size. const maxReadahead = 1 << 20 +const ( + defaultMaxBackground = 128 + defaultCongestionThreshold = 96 +) + // Connection represents a connection to the fuse kernel process. It is used to // receive and reply to requests from the kernel. type Connection struct { @@ -159,6 +164,17 @@ func (c *Connection) Init() error { initOp.Library = c.protocol initOp.MaxReadahead = maxReadahead initOp.MaxWrite = buffer.MaxWriteSize + initOp.MaxBackground = c.cfg.MaxBackground + if initOp.MaxBackground == 0 { + initOp.MaxBackground = defaultMaxBackground + } + initOp.CongestionThreshold = c.cfg.CongestionThreshold + if initOp.CongestionThreshold == 0 { + initOp.CongestionThreshold = defaultCongestionThreshold + if initOp.CongestionThreshold >= initOp.MaxBackground { + initOp.CongestionThreshold = initOp.MaxBackground * 3 / 4 + } + } initOp.Flags = 0 diff --git a/conversions.go b/conversions.go index 4d76f36..91d5ade 100644 --- a/conversions.go +++ b/conversions.go @@ -1061,9 +1061,8 @@ func (c *Connection) kernelResponseForOp( out.Minor = o.Library.Minor out.MaxReadahead = o.MaxReadahead out.Flags = uint32(o.Flags) - // Default values - out.MaxBackground = 12 - out.CongestionThreshold = 9 + out.MaxBackground = o.MaxBackground + out.CongestionThreshold = o.CongestionThreshold out.MaxWrite = o.MaxWrite out.TimeGran = 1 out.MaxPages = o.MaxPages diff --git a/internal/buffer/in_message_linux.go b/internal/buffer/in_message_linux.go index 6273733..d7410ab 100644 --- a/internal/buffer/in_message_linux.go +++ b/internal/buffer/in_message_linux.go @@ -16,5 +16,5 @@ package buffer // The maximum fuse write request size that InMessage can acommodate. // -// As of kernel 4.20 Linux accepts writes up to 256 pages or 1MiB -const MaxWriteSize = 1 << 17 +// As of kernel 4.20 Linux accepts writes up to 256 pages or 1MiB. +const MaxWriteSize = 1 << 20 diff --git a/mount_config.go b/mount_config.go index b21d5ff..192d910 100644 --- a/mount_config.go +++ b/mount_config.go @@ -169,6 +169,16 @@ type MountConfig struct { // being read from the file as a list of slices in ReadFileOp.Data. UseVectoredRead bool + // Linux only. Controls the maximum number of outstanding FUSE requests the + // kernel may queue before applying backpressure. If zero, the library uses a + // high-throughput default. + MaxBackground uint16 + + // Linux only. Controls the number of outstanding FUSE requests at which the + // kernel considers the connection congested. If zero, the library derives a + // value from MaxBackground. + CongestionThreshold uint16 + // OS X only. // // The name of the mounted volume, as displayed in the Finder. If empty, a diff --git a/ops.go b/ops.go index fe21a64..03008dc 100644 --- a/ops.go +++ b/ops.go @@ -40,9 +40,10 @@ type initOp struct { Flags fusekernel.InitFlags // Out - Library fusekernel.Protocol - MaxReadahead uint32 - MaxBackground uint16 - MaxWrite uint32 - MaxPages uint16 + Library fusekernel.Protocol + MaxReadahead uint32 + MaxBackground uint16 + CongestionThreshold uint16 + MaxWrite uint32 + MaxPages uint16 }