Add sane defaults to ScalingConfig members

ScalingConfig was value-initialized to all zeros when no config
is provided. While the non-autoscale path gates all access, a
zero idle_threshold_usecs would cause try_wait_dequeue_for to
return immediately if the autoscale path were ever reached by
mistake.

Add default member initializers: min_threads=2, max_threads=64,
sample_interval=100ms, cooldown=200ms, idle_threshold=5s. These
match the values recommended in the scaling policy design and
provide safe behavior even if a caller constructs ScalingConfig
without setting all fields.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Antonio S. Musumeci 2026-04-09 20:43:21 -04:00
parent 73b6bb3cdf
commit e87acf0433

View file

@ -60,11 +60,11 @@ private:
public:
struct ScalingConfig
{
std::size_t min_threads;
std::size_t max_threads;
std::int64_t sample_interval_usecs; // hill-climb sample period
std::int64_t cooldown_usecs; // min time between scaling events
std::int64_t idle_threshold_usecs; // worker idle timeout before self-exit
std::size_t min_threads = 2;
std::size_t max_threads = 64;
std::int64_t sample_interval_usecs = 100000; // 100ms hill-climb sample period
std::int64_t cooldown_usecs = 200000; // 200ms min time between scaling events
std::int64_t idle_threshold_usecs = 5000000; // 5s worker idle timeout before self-exit
};
explicit