Add fuse-read-spin-us: poll /dev/fuse briefly before blocking

After handling a request, a sync read thread polls its /dev/fuse fd for
up to fuse-read-spin-us microseconds before blocking in read(). Default
0 (disabled). Measured at 50us (tmpfs branch, direct_io): sequential
128K/1M reads +27-32%, 128K writes +14%, metadata walks +24-32%; no
change on 8 parallel streams or 1M writes. Costs roughly one core on a
busy-but-quiet mount, nothing when idle.
This commit is contained in:
Antonio S. Musumeci 2026-10-14 19:55:12 -04:00
parent 54166afe08
commit 76d3990776
7 changed files with 84 additions and 8 deletions

View file

@ -155,6 +155,9 @@ config file.
multiplied by the number of process threads plus read thread
count. 0 sets the depth to the same as the process thread
count. (default: 2)
* **[fuse-read-spin-us](threads.md)=UINT**: Microseconds a read thread
polls for the next request before sleeping. Trades CPU for lower
latency on synchronous workloads. (default: 0)
* **[pin-threads](pin-threads.md)=STR**: Selects a strategy to pin
threads to CPUs (default: unset)
* **[flush-on-close](flush-on-close.md)=never|always|opened-for-write**:

View file

@ -59,3 +59,26 @@ in the pool.
block in order to limit memory growth.
* `process-thread-queue-depth<=0`: Sets the queue depth to 2. May be
used in the future to set dynamically.
## fuse-read-spin-us
Defaults to `0` (disabled)
Applies only when `process-thread-count=-1` (read threads also process
requests). After handling a request, each read thread polls for the
next request for up to this many microseconds before going to sleep.
This lowers per-request latency for synchronous, single-stream workloads
(sequential reads, small writes, metadata-heavy walks such as `ls -l`,
`find`, or `rsync` scans) at the cost of CPU: while requests keep
arriving, a read thread stays busy instead of sleeping. On a quiet,
low-rate request stream this costs roughly one CPU core's worth of
polling with no benefit. An idle mount costs nothing.
`50` is the only value tested. Larger values increase CPU use. Parallel
multi-stream workloads and large (1MiB) writes showed no change.
* `fuse-read-spin-us=0`: Disabled. Read threads block immediately.
* `fuse-read-spin-us=N`: Poll for up to `N` microseconds after each
request.