mergerfs/mkdocs/docs/config/threads.md

79 lines
3.2 KiB
Markdown
Raw Normal View History

# threads
There are multiple thread pools used in mergerfs to provide
parallel behaviors.
fix: validate and cap thread and queue counts - std::stoi threw std::out_of_range for a func.readdir concurrency or queue depth above INT_MAX, e.g. cor:99999999999. Given at mount, mergerfs aborted. Set at runtime through .mergerfs, the daemon shut down and the mount went away, or with process-thread-count>0 the request never got a reply. Parse with str::from, which reports the overflow, and reject the value like any other malformed one. - Reject a readdir queue depth whose product with the concurrency overflows an int, e.g. cor:2147483647:2147483647, instead of wrapping it. - Limit read-thread-count, process-thread-count and the cor/cosr pool size to 64 threads per pool, after resolving automatic and CPU-divided counts, and log a warning when clamping. Resolve negative FUSE counts without overflowing on INT_MIN, and drop the unreachable negative readdir concurrency branch. - process-thread-queue-depth is multiplied by the process thread count. Saturate the product at INT_MAX instead of overflowing. - Correct the docs: cor/cosr counts accept digits only and 0 means the core count, at most 8; a queue depth of 0 means 2 per thread; read-thread-count=0 with process-thread-count=0 is 2 read threads and max(2, cores - 2) process threads, at most 8; the queue limit is depth times process threads, each read thread holding one in-flight buffer of its own. Point at threads.md for how the settings combine. - Document the per-read-thread /dev/fuse clones and their fallback. - tests.cpp covers the overflow cases. Performance: default thread counts are unchanged (8 on hosts with 8 or more cores). Only explicit or CPU-divided counts above 64, which 2.42.0 honored, are reduced.
2026-11-21 14:33:27 -05:00
Each thread pool is limited to 64 threads. This applies to
`read-thread-count`, `process-thread-count` and the pool size in
[func.readdir](func_readdir.md). Counts resolved from automatic or
negative settings are also capped. When an applied setting exceeds
the limit, mergerfs reduces the count to 64 and logs a syslog warning
(`LOG_WARNING`). Queue depths are not capped to 64.
## read-thread-count
Defaults to `0`
The number of threads used to read messages from the kernel. If used
alone processing will be done on the same thread. If
`process-thread-count` is enabled then this thread pool will read
messages and the process thread pool will do the work. This can
increase how much mergerfs can process at one time but may reduce
throughput.
* `read-thread-count=0` and `process-thread-count=-1`: Create `1`
read+process thread per logical CPU core upto `8`.
* `read-thread-count=N` where `N>0` and `process-thread-count=-1`:
Create a thread pool of `N` read+process threads.
* `read-thread-count=N` where `N<0` and `process-thread-count=-1`:
Create a read+process thread pool of `CPUCount / -N`
threads. Minimum of `1`.
* `read-thread-count=0` and `process-thread-count=0`: Create `2` read
fix: validate and cap thread and queue counts - std::stoi threw std::out_of_range for a func.readdir concurrency or queue depth above INT_MAX, e.g. cor:99999999999. Given at mount, mergerfs aborted. Set at runtime through .mergerfs, the daemon shut down and the mount went away, or with process-thread-count>0 the request never got a reply. Parse with str::from, which reports the overflow, and reject the value like any other malformed one. - Reject a readdir queue depth whose product with the concurrency overflows an int, e.g. cor:2147483647:2147483647, instead of wrapping it. - Limit read-thread-count, process-thread-count and the cor/cosr pool size to 64 threads per pool, after resolving automatic and CPU-divided counts, and log a warning when clamping. Resolve negative FUSE counts without overflowing on INT_MIN, and drop the unreachable negative readdir concurrency branch. - process-thread-queue-depth is multiplied by the process thread count. Saturate the product at INT_MAX instead of overflowing. - Correct the docs: cor/cosr counts accept digits only and 0 means the core count, at most 8; a queue depth of 0 means 2 per thread; read-thread-count=0 with process-thread-count=0 is 2 read threads and max(2, cores - 2) process threads, at most 8; the queue limit is depth times process threads, each read thread holding one in-flight buffer of its own. Point at threads.md for how the settings combine. - Document the per-read-thread /dev/fuse clones and their fallback. - tests.cpp covers the overflow cases. Performance: default thread counts are unchanged (8 on hosts with 8 or more cores). Only explicit or CPU-divided counts above 64, which 2.42.0 honored, are reduced.
2026-11-21 14:33:27 -05:00
threads and a process thread pool of `CPUCount - 2` threads.
Minimum of `2`, maximum of `8`.
* `read-thread-count=0` and `process-thread-count!=-1`: Creates `2`
read threads and number of process threads as defined below.
fix: validate and cap thread and queue counts - std::stoi threw std::out_of_range for a func.readdir concurrency or queue depth above INT_MAX, e.g. cor:99999999999. Given at mount, mergerfs aborted. Set at runtime through .mergerfs, the daemon shut down and the mount went away, or with process-thread-count>0 the request never got a reply. Parse with str::from, which reports the overflow, and reject the value like any other malformed one. - Reject a readdir queue depth whose product with the concurrency overflows an int, e.g. cor:2147483647:2147483647, instead of wrapping it. - Limit read-thread-count, process-thread-count and the cor/cosr pool size to 64 threads per pool, after resolving automatic and CPU-divided counts, and log a warning when clamping. Resolve negative FUSE counts without overflowing on INT_MIN, and drop the unreachable negative readdir concurrency branch. - process-thread-queue-depth is multiplied by the process thread count. Saturate the product at INT_MAX instead of overflowing. - Correct the docs: cor/cosr counts accept digits only and 0 means the core count, at most 8; a queue depth of 0 means 2 per thread; read-thread-count=0 with process-thread-count=0 is 2 read threads and max(2, cores - 2) process threads, at most 8; the queue limit is depth times process threads, each read thread holding one in-flight buffer of its own. Point at threads.md for how the settings combine. - Document the per-read-thread /dev/fuse clones and their fallback. - tests.cpp covers the overflow cases. Performance: default thread counts are unchanged (8 on hosts with 8 or more cores). Only explicit or CPU-divided counts above 64, which 2.42.0 honored, are reduced.
2026-11-21 14:33:27 -05:00
When there is more than one read thread, each thread reads from its
own clone of the `/dev/fuse` descriptor when the kernel supports the
`FUSE_DEV_IOC_CLONE` ioctl. If cloning fails mergerfs logs a warning
and the read threads share one descriptor.
## process-thread-count
Defaults to `-1`
When enabled this sets the number of threads in the message processing pool.
* `process-thread-count=-1`: Process thread pool is disabled.
fix: validate and cap thread and queue counts - std::stoi threw std::out_of_range for a func.readdir concurrency or queue depth above INT_MAX, e.g. cor:99999999999. Given at mount, mergerfs aborted. Set at runtime through .mergerfs, the daemon shut down and the mount went away, or with process-thread-count>0 the request never got a reply. Parse with str::from, which reports the overflow, and reject the value like any other malformed one. - Reject a readdir queue depth whose product with the concurrency overflows an int, e.g. cor:2147483647:2147483647, instead of wrapping it. - Limit read-thread-count, process-thread-count and the cor/cosr pool size to 64 threads per pool, after resolving automatic and CPU-divided counts, and log a warning when clamping. Resolve negative FUSE counts without overflowing on INT_MIN, and drop the unreachable negative readdir concurrency branch. - process-thread-queue-depth is multiplied by the process thread count. Saturate the product at INT_MAX instead of overflowing. - Correct the docs: cor/cosr counts accept digits only and 0 means the core count, at most 8; a queue depth of 0 means 2 per thread; read-thread-count=0 with process-thread-count=0 is 2 read threads and max(2, cores - 2) process threads, at most 8; the queue limit is depth times process threads, each read thread holding one in-flight buffer of its own. Point at threads.md for how the settings combine. - Document the per-read-thread /dev/fuse clones and their fallback. - tests.cpp covers the overflow cases. Performance: default thread counts are unchanged (8 on hosts with 8 or more cores). Only explicit or CPU-divided counts above 64, which 2.42.0 honored, are reduced.
2026-11-21 14:33:27 -05:00
* `process-thread-count=0`: With the default `read-thread-count=0`
this follows the combined rule under `read-thread-count` above:
`2` read threads and a process thread pool of `CPUCount - 2`
threads, minimum `2`, maximum `8`. With a nonzero
`read-thread-count` it creates a process thread pool of
`CPUCount` threads capped at `8` (minimum `1`).
* `process-thread-count=N` where `N>0`: Create a thread pool of `N` threads.
* `process-thread-count=N` where `N<-1`: Create a thread pool of `CPUCount /
-N` threads. Minimum of 1.
## process-thread-queue-depth
Defaults to `2`
Sets the depth queue for the processing thread queue per
thread. Meaning if the read threads are getting requests faster than
can be processed they will be queued up upto the queue depth. Despite
the calculation being per thread the queue depth is shared across all
in the pool.
* `process-thread-queue-depth=N` where `N>0`: Sets the number of
outstanding requests that the process thread pool can have to `N *
fix: validate and cap thread and queue counts - std::stoi threw std::out_of_range for a func.readdir concurrency or queue depth above INT_MAX, e.g. cor:99999999999. Given at mount, mergerfs aborted. Set at runtime through .mergerfs, the daemon shut down and the mount went away, or with process-thread-count>0 the request never got a reply. Parse with str::from, which reports the overflow, and reject the value like any other malformed one. - Reject a readdir queue depth whose product with the concurrency overflows an int, e.g. cor:2147483647:2147483647, instead of wrapping it. - Limit read-thread-count, process-thread-count and the cor/cosr pool size to 64 threads per pool, after resolving automatic and CPU-divided counts, and log a warning when clamping. Resolve negative FUSE counts without overflowing on INT_MIN, and drop the unreachable negative readdir concurrency branch. - process-thread-queue-depth is multiplied by the process thread count. Saturate the product at INT_MAX instead of overflowing. - Correct the docs: cor/cosr counts accept digits only and 0 means the core count, at most 8; a queue depth of 0 means 2 per thread; read-thread-count=0 with process-thread-count=0 is 2 read threads and max(2, cores - 2) process threads, at most 8; the queue limit is depth times process threads, each read thread holding one in-flight buffer of its own. Point at threads.md for how the settings combine. - Document the per-read-thread /dev/fuse clones and their fallback. - tests.cpp covers the overflow cases. Performance: default thread counts are unchanged (8 on hosts with 8 or more cores). Only explicit or CPU-divided counts above 64, which 2.42.0 honored, are reduced.
2026-11-21 14:33:27 -05:00
process-thread-count`, at most 2147483647. If requests come in
faster than can be processed and the max queue depth hit then
queuing the request will 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.