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.
This commit is contained in:
parent
0f9d52d9d8
commit
0a82dfe2e0
6 changed files with 69 additions and 17 deletions
|
|
@ -23,7 +23,10 @@
|
|||
#include "fuse_readdir_seq.hpp"
|
||||
|
||||
#include "from_string.hpp"
|
||||
#include "syslog.hpp"
|
||||
#include "thread_pool.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
|
|
@ -42,7 +45,8 @@ void
|
|||
_read_cfg(const std::string_view str_,
|
||||
std::string &type_,
|
||||
int &concurrency_,
|
||||
int &max_queue_depth_)
|
||||
int &max_queue_depth_,
|
||||
const bool warn_)
|
||||
{
|
||||
std::string type;
|
||||
int concurrency;
|
||||
|
|
@ -86,6 +90,8 @@ _read_cfg(const std::string_view str_,
|
|||
|
||||
if(concurrency <= 0)
|
||||
concurrency = 1;
|
||||
const bool clamped = (concurrency > ThreadPool::max_thread_count());
|
||||
concurrency = std::min(concurrency,ThreadPool::max_thread_count());
|
||||
|
||||
if(max_queue_depth <= 0)
|
||||
max_queue_depth = 2;
|
||||
|
|
@ -96,6 +102,10 @@ _read_cfg(const std::string_view str_,
|
|||
else
|
||||
max_queue_depth *= concurrency;
|
||||
|
||||
if(warn_ && clamped && ((type == "cor") || (type == "cosr")))
|
||||
SysLog::warning("func.readdir={} exceeds the thread limit; clamping to {} threads",
|
||||
str_,ThreadPool::max_thread_count());
|
||||
|
||||
type_ = type;
|
||||
concurrency_ = concurrency;
|
||||
max_queue_depth_ = max_queue_depth;
|
||||
|
|
@ -108,7 +118,7 @@ FUSE::ReadDirFactory::valid(const std::string_view str_)
|
|||
int max_queue_depth;
|
||||
std::string type;
|
||||
|
||||
::_read_cfg(str_,type,concurrency,max_queue_depth);
|
||||
::_read_cfg(str_,type,concurrency,max_queue_depth,false);
|
||||
|
||||
return ((type == "seq") ||
|
||||
(type == "cosr") ||
|
||||
|
|
@ -122,7 +132,7 @@ FUSE::ReadDirFactory::make(const std::string_view str_)
|
|||
int max_queue_depth;
|
||||
std::string type;
|
||||
|
||||
::_read_cfg(str_,type,concurrency,max_queue_depth);
|
||||
::_read_cfg(str_,type,concurrency,max_queue_depth,true);
|
||||
|
||||
if(type == "seq")
|
||||
return std::make_shared<FUSE::ReadDirSeq>();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue