mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-11-19 14:36:36 -05:00
Log actual thread count after hill-climb scaling
The monitor thread read the thread count before calling add_thread or remove_thread, then logged count+1 or count-1 as the new size. If concurrent scaling (fast-path grow, idle self-exit) changed the count between the read and the action, the logged value was wrong. Read thread_count() after the scaling action for the log message so it reflects reality. The pre-action read is kept for the bounds check (direction guard) since that only needs to be approximately correct. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
78d320a64c
commit
20acdfce19
1 changed files with 5 additions and 8 deletions
|
|
@ -534,12 +534,6 @@ ThreadPool::monitor_routine(void *arg_)
|
|||
continue;
|
||||
}
|
||||
|
||||
std::size_t count;
|
||||
{
|
||||
mutex_lockguard(btp->_threads_mutex);
|
||||
count = btp->_threads.size();
|
||||
}
|
||||
|
||||
// Hill-climb: did smoothed throughput improve since last sample?
|
||||
if(ema_throughput >= prev_ema)
|
||||
{
|
||||
|
|
@ -568,6 +562,9 @@ ThreadPool::monitor_routine(void *arg_)
|
|||
continue;
|
||||
}
|
||||
|
||||
// Read count, act, then re-read for an accurate log message.
|
||||
std::size_t count = btp->thread_count();
|
||||
|
||||
if(direction > 0 && count < btp->_scaling_config.max_threads)
|
||||
{
|
||||
btp->add_thread();
|
||||
|
|
@ -577,7 +574,7 @@ ThreadPool::monitor_routine(void *arg_)
|
|||
"threadpool (%s): hill-climb grow to %zu threads "
|
||||
"(ema %.1f -> %.1f)",
|
||||
btp->_name.c_str(),
|
||||
count + 1,
|
||||
btp->thread_count(),
|
||||
prev_ema,
|
||||
ema_throughput);
|
||||
}
|
||||
|
|
@ -590,7 +587,7 @@ ThreadPool::monitor_routine(void *arg_)
|
|||
"threadpool (%s): hill-climb shrink to %zu threads "
|
||||
"(ema %.1f -> %.1f)",
|
||||
btp->_name.c_str(),
|
||||
count - 1,
|
||||
btp->thread_count(),
|
||||
prev_ema,
|
||||
ema_throughput);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue