mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-12-02 21:00:13 -05:00
Restore splice zero-copy I/O as runtime options
Reinstate the splice read/write/move paths removed in 84592a9f, now
gated behind runtime options with negotiated pipe sizing and fallback
logging.
- Transport: msgbuf-piped splice receive, fd-referenced splice reply
(vmsplice + splice), splice-move pipe-bounce, and restored
fuse_buf_copy/fuse_buf_flags plumbing for copy fallbacks
- Negotiation: new pipe-max-size option (auto-raised at INIT when
possible; the sysctl read/write is factored into src/pipe_max_size.cpp
so fuse_init.cpp and option_parser.cpp share one implementation);
fuse-msg-size clamped to what the pipe can hold; splice is disabled
at INIT with a warning if the sysctl can't fit even the minimum,
retracting the FUSE_CAP_SPLICE_* bits already advertised to the
kernel in that case
- Read replies and splice-move are gated at 128 KiB (below that the
syscalls cost more than the copy they avoid); every fallback path
degrades to the copy path and logs once per process via SysLog
- msgbuf pipe cache is process-global and mutex-guarded (mutex_lockguard)
so pipes can move between read and worker threads under
process-thread mode
- API simplified after review: collapsed the three per-axis options
(splice-read/write/move) into a single splice boolean (default on);
no-splice-read/write/move and the bare splice-read/write/move
spellings stay registered as accepted no-ops so existing mount
options don't fail the mount, but they do NOT alter the splice
knob - upgraders with no-splice-* in their config get splice
enabled and must set splice=false explicitly (see
deprecated_options.md)
- Fixed several correctness issues found in parallel review: a
dropped write_buf registration that silently corrupted writes, a
dirty-pipe reuse bug in msgbuf_free, an iov double-send in
fuse_reply_data's splice-move fallback, and pipe-capacity math that
assumed a 4096-byte page size
- Modernized the transport/negotiation code to this codebase's C++
style: RAII (unique_ptr/DEFER) instead of malloc/free and manual fd
close(), std::from_chars/to_chars instead of stoul/snprintf,
_ReplyPipe's pipe ops as methods instead of free functions closing
over a thread_local global, and vendored/libfuse/lib/buffer.cpp (a
near-verbatim port of upstream's buffer.c) brought in line with the
rest of the fork
- Documented splice and pipe-max-size options (mkdocs, FAQ,
deprecated-options list); added tools/bench-splice.sh
- Benchmarked on tmpfs: seq_write +21%, seq_read +52%, small_write
+5%, small_read +12%; validated with a 1h soak (~271 GiB
hash-verified I/O, zero integrity failures), a live-mount round-trip
of I/O above the splice threshold, and the existing unit/smoke
suites at their pre-existing baseline
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
8ea47df13e
commit
8eed256747
30 changed files with 3098 additions and 42 deletions
|
|
@ -19,6 +19,12 @@ function or have been replaced. **They should not be used.**
|
|||
* **remember-nodes**: Use `never-forget-nodes`.
|
||||
* **noforget**: Use `never-forget-nodes`.
|
||||
* **nonempty**: Does nothing.
|
||||
* **no-splice-read**: Does nothing. Use [splice=false](splice.md) to
|
||||
disable splice.
|
||||
* **no-splice-write**: Does nothing. Use [splice=false](splice.md) to
|
||||
disable splice.
|
||||
* **no-splice-move**: Does nothing. Use [splice=false](splice.md) to
|
||||
disable splice.
|
||||
* **splice_move**: Does nothing.
|
||||
* **splice_read**: Does nothing.
|
||||
* **splice_write**: Does nothing.
|
||||
|
|
|
|||
|
|
@ -123,6 +123,16 @@ config file.
|
|||
directory and symlink to it.
|
||||
* **[readahead](readahead.md)=UINT**: Set readahead (in kilobytes) for
|
||||
mergerfs and branches if greater than 0. (default: 0)
|
||||
* **[splice](splice.md)=BOOL**: Enable the kernel's splice syscall to
|
||||
move data between the FUSE device and the underlying filesystems
|
||||
without copying through user space. Read replies of 128KiB or larger
|
||||
are spliced; smaller read replies use the copy path. Writes stage
|
||||
their payload through a pipe at any size. Falls back automatically
|
||||
when unsupported. (default: true)
|
||||
* **[pipe-max-size](pipe-max-size.md)=SIZE**: The value to write to
|
||||
/proc/sys/fs/pipe-max-size at mount time, needed only when
|
||||
fuse-msg-size exceeds the current limit while splice is enabled.
|
||||
Root-only; unprivileged mounts log and clamp instead. (default: 0)
|
||||
* **posix-acl=BOOL**: Enable POSIX ACL support (if supported by kernel
|
||||
and underlying filesystem). (default: false)
|
||||
* **async-read=BOOL**: Perform reads asynchronously. If disabled or
|
||||
|
|
|
|||
34
mkdocs/docs/config/pipe-max-size.md
Normal file
34
mkdocs/docs/config/pipe-max-size.md
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
# pipe-max-size
|
||||
|
||||
* type: `SIZE`
|
||||
* default: `0`
|
||||
* example: `pipe-max-size=8M`
|
||||
|
||||
Sets the value written to `/proc/sys/fs/pipe-max-size` at mount time,
|
||||
before the FUSE connection is negotiated. This is the kernel's limit
|
||||
on the capacity of a single pipe, which bounds how much data can be
|
||||
moved in a single `splice` call.
|
||||
|
||||
mergerfs already raises this sysctl on its own, automatically,
|
||||
whenever splice is enabled (the default) and `fuse-msg-size` doesn't
|
||||
fit the current `pipe-max-size` (default 1MiB on most kernels) - that
|
||||
automatic behavior does not depend on this option being set. Setting
|
||||
`pipe-max-size` explicitly is for cases where you want the sysctl
|
||||
raised to a specific value up front (e.g. more headroom than the
|
||||
minimum mergerfs would otherwise request), or want it raised before
|
||||
mergerfs starts negotiating rather than during. If you use the
|
||||
default `fuse-msg-size` you do not need this option.
|
||||
|
||||
Writing the sysctl requires running as root. When not root mergerfs
|
||||
will log (at info level) that it could not raise the limit and will
|
||||
clamp `fuse-msg-size` to what the current pipe limit allows instead.
|
||||
|
||||
Note that this is a system wide setting that persists after mergerfs
|
||||
exits; mergerfs does not restore the previous value on unmount.
|
||||
|
||||
For unprivileged usage the kernel also caps the total number of pipe
|
||||
pages a non-root user may have allocated, via
|
||||
`/proc/sys/fs/pipe-user-pages-soft` and
|
||||
`/proc/sys/fs/pipe-user-pages-hard` (both present since Linux
|
||||
v4.5). This is a separate limit from `pipe-max-size`, which caps a
|
||||
single pipe's capacity.
|
||||
33
mkdocs/docs/config/splice.md
Normal file
33
mkdocs/docs/config/splice.md
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
# splice
|
||||
|
||||
* type: `BOOL`
|
||||
* default: `true`
|
||||
* example: `splice=false`
|
||||
|
||||
Controls whether mergerfs uses the kernel's
|
||||
[splice](https://man7.org/linux/man-pages/man2/splice.2.html) syscall
|
||||
to move data between `/dev/fuse` and the underlying filesystems
|
||||
without copying it through user space memory.
|
||||
|
||||
When enabled, `read` and `write` requests can be serviced with zero
|
||||
copies: the kernel moves pages directly between the branch
|
||||
filesystem's page cache and the FUSE device through pipes. This can
|
||||
significantly improve sequential throughput on modern hardware.
|
||||
|
||||
Due to the extra syscall overhead for small requests, splice replies
|
||||
to `read` requests are only used for requests of 128KiB or larger;
|
||||
smaller read replies use the traditional write path. `write` requests
|
||||
of any size stage their payload into the receive pipe and splice it
|
||||
to the branch when possible.
|
||||
|
||||
If the filesystem or kernel does not support the needed
|
||||
functionality mergerfs will automatically fall back to the
|
||||
traditional read/write behavior.
|
||||
|
||||
Historical note: splice support was previously removed from
|
||||
mergerfs's own vendored libfuse (see the
|
||||
[FAQ](../faq/technical_behavior_and_limitations.md) for why), and
|
||||
the `no-splice-read`, `no-splice-write`, and `no-splice-move`
|
||||
spellings were accepted as no-ops during that period. They remain
|
||||
accepted as no-ops for backward compatibility; use `splice=false`
|
||||
instead.
|
||||
|
|
@ -215,13 +215,20 @@ If `mergerfs` doesn't work as a type it could be due to how the
|
|||
permissions.
|
||||
|
||||
|
||||
## Why was splice support removed?
|
||||
## Why was splice support removed and then restored?
|
||||
|
||||
After a lot of testing over the years, splicing always appeared to
|
||||
at best, provide equivalent performance, and in some cases, worse
|
||||
performance. Splice is not supported on other platforms forcing a
|
||||
traditional read/write fallback to be provided. The splice code was
|
||||
removed to simplify the codebase.
|
||||
Splice support was originally removed after testing showed it, at
|
||||
best, provided equivalent performance and in some cases worse.
|
||||
It was restored in 2026 after a rewrite for the current transport
|
||||
layer: request receive staging, fd-referenced read replies, and a
|
||||
128 KiB threshold below which read replies stay on the copy path
|
||||
(write requests stage their payload through a pipe at any size). On
|
||||
tmpfs branches the restored paths benchmark at seq_read +52%,
|
||||
seq_write +21%. See [splice](../config/splice.md) and
|
||||
[pipe-max-size](../config/pipe-max-size.md) in the options
|
||||
documentation. Splice remains
|
||||
unavailable on platforms that lack it; the copy path is the
|
||||
fallback everywhere.
|
||||
|
||||
|
||||
## How does mergerfs handle credentials?
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue