// If there's not too many entries in the queue, restart the scan task
const auto instance_count = Task::instance_count();
const auto instance_limit = BEES_MAX_EXTENT_REF_COUNT;
- const bool queue_empty = s_throttled && instance_count < instance_limit;
- const bool queue_full = !s_throttled && instance_count > instance_limit;
+ // Add some hysteresis so that we aren't constantly flipping throttle on and off
+ const bool queue_empty = s_throttled && instance_count < instance_limit * .90;
+ const bool queue_full = !s_throttled && instance_count > instance_limit * .99;
if (queue_full) {
BEESLOGDEBUG("Throttling crawl at " << instance_count << " tasks");
s_throttled = true;
{
BEESTRACE("bsm scan");
- if (should_throttle()) return;
-
unique_lock<mutex> lock(m_mutex);
const auto task_map_copy = m_task_map;
lock.unlock();
{
BEESTRACE("map_next_extent " << subvol);
- if (should_throttle()) return;
-
size_t discard_count = 0;
size_t gen_low_count = 0;
size_t gen_high_count = 0;
<< " time " << crawl_time << " subvol " << subvol);
}
- // We did something! Get in line to run again
- Task::current_task().idle();
+ // We did something! Get in line to run again...unless we're throttled
+ if (!should_throttle()) {
+ Task::current_task().idle();
+ }
return;
}