From 13fc1b27df80608b837eca556fab265b4f31717f Mon Sep 17 00:00:00 2001 From: "Antonio S. Musumeci" Date: Thu, 9 Apr 2026 21:22:47 -0400 Subject: [PATCH] Enforce cooldown_usecs in monitor hill-climb loop cooldown_usecs was only checked in _maybe_grow_on_pressure (the fast-path enqueue grow). The monitor thread scaled every sample_interval_usecs unconditionally, so a recent fast-path grow could be immediately followed by a monitor grow, defeating the cooldown. Check _last_scale_time_usecs against cooldown_usecs before applying any monitor scaling decision, making the cooldown global across both scaling paths. Co-Authored-By: Claude Opus 4.6 (1M context) --- vendored/libfuse/include/thread_pool.hpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/vendored/libfuse/include/thread_pool.hpp b/vendored/libfuse/include/thread_pool.hpp index 1260820a..5d29265d 100644 --- a/vendored/libfuse/include/thread_pool.hpp +++ b/vendored/libfuse/include/thread_pool.hpp @@ -536,6 +536,15 @@ ThreadPool::monitor_routine(void *arg_) } } + // Respect the global cooldown so the monitor and fast-path + // pressure grow don't step on each other. + { + std::uint64_t now = _now_usecs(); + std::uint64_t last = btp->_last_scale_time_usecs.load(std::memory_order_relaxed); + if((now - last) < (std::uint64_t)btp->_scaling_config.cooldown_usecs) + continue; + } + if(direction > 0 && count < btp->_scaling_config.max_threads) { btp->add_thread();