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
|
|
@ -199,7 +199,8 @@ struct SyncWorker
|
|||
|
||||
static
|
||||
int
|
||||
_calculate_thread_count(const int raw_thread_count_)
|
||||
_calculate_thread_count(const int raw_thread_count_,
|
||||
const char *option_)
|
||||
{
|
||||
int thread_count = 1;
|
||||
|
||||
|
|
@ -210,7 +211,7 @@ _calculate_thread_count(const int raw_thread_count_)
|
|||
}
|
||||
else if(raw_thread_count_ < 0)
|
||||
{
|
||||
thread_count = (::_nproc() / -raw_thread_count_);
|
||||
thread_count = (::_nproc() / -(long long)raw_thread_count_);
|
||||
thread_count = std::max(1,thread_count);
|
||||
}
|
||||
else if(raw_thread_count_ > 0)
|
||||
|
|
@ -218,6 +219,14 @@ _calculate_thread_count(const int raw_thread_count_)
|
|||
thread_count = raw_thread_count_;
|
||||
}
|
||||
|
||||
if(thread_count > ThreadPool::max_thread_count())
|
||||
{
|
||||
SysLog::warning("{}={} requests {} threads; limiting pool to {}",
|
||||
option_,raw_thread_count_,thread_count,
|
||||
ThreadPool::max_thread_count());
|
||||
thread_count = ThreadPool::max_thread_count();
|
||||
}
|
||||
|
||||
return thread_count;
|
||||
}
|
||||
|
||||
|
|
@ -246,13 +255,16 @@ _calculate_thread_counts(int *read_thread_count_,
|
|||
else if((*read_thread_count_ == 0) && (*process_thread_count_ != -1))
|
||||
{
|
||||
*read_thread_count_ = 2;
|
||||
*process_thread_count_ = ::_calculate_thread_count(*process_thread_count_);
|
||||
*process_thread_count_ = ::_calculate_thread_count(*process_thread_count_,
|
||||
"process-thread-count");
|
||||
}
|
||||
else
|
||||
{
|
||||
*read_thread_count_ = ::_calculate_thread_count(*read_thread_count_);
|
||||
*read_thread_count_ = ::_calculate_thread_count(*read_thread_count_,
|
||||
"read-thread-count");
|
||||
if(*process_thread_count_ != -1)
|
||||
*process_thread_count_ = ::_calculate_thread_count(*process_thread_count_);
|
||||
*process_thread_count_ = ::_calculate_thread_count(*process_thread_count_,
|
||||
"process-thread-count");
|
||||
}
|
||||
|
||||
if(*process_thread_queue_depth_ <= 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue