mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-12-02 04:46:41 -05:00
fix: cap thread pools at 64 and warn when clamped
- Limit read-thread-count, process-thread-count and the cor/cosr pool size in func.readdir to 64 threads per pool. Apply the cap after resolving automatic and CPU-divided counts; keep disabled process pools disabled and preserve the configured strings. - Log a syslog warning identifying the setting and limit when clamped. For readdir, warn only when applying a valid concurrent policy, not during validation. - Document the fixed cap and warning behavior. Queue depths retain their separate limits and use the clamped thread count. - Resolve negative FUSE counts without overflowing on INT_MIN. Document that both readdir inputs must fit in int and that a queue depth whose product with the resolved thread count exceeds INT_MAX is rejected, not clamped.
This commit is contained in:
parent
8d93e29ad8
commit
127c2e6238
6 changed files with 80 additions and 21 deletions
|
|
@ -9,12 +9,23 @@
|
|||
| Policy | Description |
|
||||
| ------ | ----------- |
|
||||
| seq | "sequential" : Iterate sequentially over branches in the order defined in `branches`. This is the default and traditional behavior found prior to the readdir policy introduction. This will be increasingly slower as more branches are added to the pool. Especially if needing to wait for drives to spin up or network filesystems to respond. |
|
||||
| cosr:N:M | "concurrent open, sequential read" : Concurrently open branch directories using a thread pool and process them in the order defined in `branches`. This keeps memory and CPU usage low while also reducing the time spent waiting on branches to respond. `N` is the number of threads. If negative it will be the core count divided by `abs(N)`. `M` is the queue depth. If either value is `0` it will be decided based on system configuration. |
|
||||
| cosr:N:M | "concurrent open, sequential read" : Concurrently open branch directories using a thread pool and process them in the order defined in `branches`. This keeps memory and CPU usage low while also reducing the time spent waiting on branches to respond. `N` is the number of threads, at most 64. If negative it will be the core count divided by `abs(N)`. `M` is the queue depth. If either value is `0` it will be decided based on system configuration. |
|
||||
| cosr:N | cosr:N:M with M = 0 |
|
||||
| cosr | cosr:N:M with N = 0 and M = 0 |
|
||||
| cor:N:M | "concurrent open and read" : Concurrently open branch directories and immediately start reading their contents using a thread pool. This will result in slightly higher memory and CPU usage but reduced latency. Particularly when using higher latency / slower speed network filesystem branches. Unlike `seq` and `cosr` the order of files could change due the async nature of the thread pool. This should not be a problem since the order of files returned in not guaranteed. `N` is the number of threads. If negative it will be the core count divided by `abs(N)`. `M` is the queue depth. If either value is `0` it will be decided based on system configuration. |
|
||||
| cor:N | cosr:N:M with M = 0 |
|
||||
| cor | cosr:N:M with N = 0 and M = 0 |
|
||||
| cor:N:M | "concurrent open and read" : Concurrently open branch directories and immediately start reading their contents using a thread pool. This will result in slightly higher memory and CPU usage but reduced latency. Particularly when using higher latency / slower speed network filesystem branches. Unlike `seq` and `cosr` the order of files could change due the async nature of the thread pool. This should not be a problem since the order of files returned in not guaranteed. `N` is the number of threads, at most 64. If negative it will be the core count divided by `abs(N)`. `M` is the queue depth. If either value is `0` it will be decided based on system configuration. |
|
||||
| cor:N | cor:N:M with M = 0 |
|
||||
| cor | cor:N:M with N = 0 and M = 0 |
|
||||
|
||||
For `cor` and `cosr`, write `N` and `M` as decimal digits only (no sign),
|
||||
from 0 through `INT_MAX` (2147483647). Out-of-range values are rejected,
|
||||
not clamped. A valid thread count above 64 is clamped to 64 with a syslog
|
||||
warning (`LOG_WARNING`); the cap does not apply to the per-thread queue
|
||||
depth. After defaults and the thread cap are applied, `N * M` must fit in
|
||||
`INT_MAX` or the entire setting is rejected; the queue depth is not saturated.
|
||||
|
||||
For example, `cor:65:2` uses 64 threads and 128 queue slots. `cor:4294967296`
|
||||
is rejected because the count is out of range; `cor:64:34000000` is rejected
|
||||
because its total queue depth exceeds `INT_MAX`.
|
||||
|
||||
Keep in mind that `readdir` mostly just provides a list of file names
|
||||
in a directory and possibly some basic metadata about said files. To
|
||||
|
|
|
|||
|
|
@ -140,21 +140,24 @@ config file.
|
|||
thread count is set negative it will look up the number of cores
|
||||
then divide by the absolute value. ie. threads=-2 on an 8 core
|
||||
machine will result in 8 / 2 = 4 threads. There will always be at
|
||||
least 1 thread. If set to -1 in combination with
|
||||
`process-thread-count` then it will try to pick reasonable values
|
||||
based on CPU thread count. NOTE: higher number of threads increases
|
||||
parallelism but usually decreases throughput. (default: 0)
|
||||
least 1 thread and at most 64, including counts resolved from automatic
|
||||
or negative settings. Counts above 64 are clamped with a syslog warning
|
||||
(`LOG_WARNING`). If set to -1 in combination with `process-thread-count`
|
||||
then it will try to pick reasonable values based on CPU thread count. NOTE:
|
||||
higher number of threads increases parallelism but usually
|
||||
decreases throughput. (default: 0)
|
||||
* **[process-thread-count](threads.md)=INT**: Enables separate thread
|
||||
pool to asynchronously process FUSE requests. In this mode
|
||||
`read-thread-count` refers to the number of threads reading FUSE
|
||||
messages which are dispatched to process threads. -1 means disabled
|
||||
otherwise acts like `read-thread-count`. (default: -1)
|
||||
otherwise acts like `read-thread-count`, including the 64-thread cap
|
||||
and warning when clamped. (default: -1)
|
||||
* **[process-thread-queue-depth](threads.md)=UINT**: Sets the number
|
||||
of requests any single process thread can have queued up at one
|
||||
time. Meaning the total memory usage of the queues is queue depth
|
||||
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)
|
||||
count. Queue depths are not capped to 64. (default: 2)
|
||||
* **[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**:
|
||||
|
|
@ -171,9 +174,13 @@ config file.
|
|||
* **[func.FUNC](functions_categories_policies.md)=POLICY**: Sets the
|
||||
specific FUSE function's policy. See below for the list of value
|
||||
types. Example: **func.getattr=newest**
|
||||
* **[func.readdir](func_readdir.md)=seq|cosr|cor|cosr:INT|cor:INT**:
|
||||
Sets `readdir` policy. INT value sets the number of threads to use
|
||||
for concurrency. (default: seq)
|
||||
* **[func.readdir](func_readdir.md)**: `seq` (default), `cosr[:N[:M]]`,
|
||||
or `cor[:N[:M]]`. `N` (threads) and `M` (queue slots per thread) accept
|
||||
decimal digits only. Values above `INT_MAX` (2147483647) are rejected.
|
||||
Omitted or zero values use the core count (at most 8) for `N` and 2 for `M`. Valid
|
||||
thread counts above 64 are clamped to 64 with a syslog warning; `M` is
|
||||
not capped at 64. If the effective `N * M` exceeds `INT_MAX`, the entire
|
||||
setting is rejected.
|
||||
* **[category.action](functions_categories_policies.md)=POLICY**: Sets
|
||||
policy of all FUSE functions in the action category. (default:
|
||||
epall)
|
||||
|
|
|
|||
|
|
@ -3,6 +3,13 @@
|
|||
There are multiple thread pools used in mergerfs to provide
|
||||
parallel behaviors.
|
||||
|
||||
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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue