mergerfs/mkdocs/docs/config/threads.md
Antonio SJ Musumeci 127c2e6238 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.
2026-11-21 17:48:28 -05:00

2.6 KiB

threads

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. 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 threads and a process thread per logical CPU core upto 8.
  • read-thread-count=0 and process-thread-count!=-1: Creates 2 read threads and number of process threads as defined below.

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.
  • process-thread-count=0: Create 1 thread process thread per logical CPU core upto 8.
  • 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 * process-thread-count. 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.