Commit graph

9 commits

Author SHA1 Message Date
Antonio SJ Musumeci
0a82dfe2e0 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.
2026-11-21 17:48:28 -05:00
Antonio SJ Musumeci
8555c56418 fix: free a read thread's buffer when it is cancelled at shutdown
- At shutdown the main loop cancels read threads that are still in
  receive_buf. The buffer each one had allocated for the next request
  was a raw pointer, so the cancel unwind left it allocated.
  LeakSanitizer reported it in about one daemon in six when unmounting
  under load.
- Hold it in a unique_ptr so the unwind frees it. The async worker
  releases it when handing the request to the process pool, as before.
2026-11-21 14:53:56 -05:00
neargye
cb930ee7a0 Fix fuse loop hang when a read worker exits
- DEFERs run in reverse order, so workers posted the semaphore before
  setting exited; the main loop could wake, see exited == 0 and wait
  again. With one read thread mergerfs then stayed running after
  unmount until signaled.
- Set exited and post in a single DEFER, in that order.
2026-11-17 09:00:59 -06:00
Antonio SJ Musumeci
7ec6f8e2f2 Manage cloned /dev/fuse fds in sessions
- Store cloned read-worker fds on fuse_session and close them there.
- Set up clone fallback through session helpers used by the loop.
- Carry per-request fds through receive, process, and reply paths.

Tests show significant performance increases in highly concurrent
workloads on a high core count system. Upto 15% better on reads and
27% on writes.
2026-05-14 20:13:07 -05:00
Antonio S. Musumeci
bd0714272e libfuse: thread_pool/objpool/fuse_loop - safer memory and iteration
- ThreadPool::destroy used to iterate _threads directly while another
  thread could be adjusting the same vector. Snapshot the vector
  under the mutex and iterate the local copy for pthread_cancel /
  pthread_join.

- ObjPool::construct now returns NULL when the pooled allocator
  returns NULL instead of invoking placement-new on a null
  pointer. In destroy, compute to_node(obj) before running the
  destructor - the destructor may scrub bytes the to_node helper
  reads.

- In the async/sync workers in fuse_loop, msgbuf_alloc can return
  NULL under memory pressure. Fail the worker cleanly with a
  diagnostic rather than dereferencing. Also introduce a small
  _nproc() helper that treats hardware_concurrency()==0 as 1, so
  the downstream min/max arithmetic doesn't produce a zero thread
  count.
2026-04-18 13:47:23 -05:00
Antonio SJ Musumeci
96eb51eecb Move fuse_session to C++ and make exit flag atomic 2026-03-24 21:13:34 -04:00
Antonio SJ Musumeci
61365d226d Move scope_guard to vendored/ 2026-03-24 21:13:34 -04:00
Antonio SJ Musumeci
076e359891 Improve thread pool 2026-03-24 21:13:34 -04:00
Antonio SJ Musumeci
8f1ef59770 Move 3rd party libraries to "vendored" directory 2026-03-02 01:09:16 -05:00
Renamed from libfuse/lib/fuse_loop.cpp (Browse further)