From 6ebb507af797c583a6b45e361b20ef5a1cc11feb Mon Sep 17 00:00:00 2001 From: Jean Flach Date: Fri, 31 Aug 2018 13:11:50 +0200 Subject: [PATCH] Shuffle items before config validation refs #6581 --- lib/config/configitem.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/config/configitem.cpp b/lib/config/configitem.cpp index c790f8794..d93087287 100644 --- a/lib/config/configitem.cpp +++ b/lib/config/configitem.cpp @@ -38,6 +38,8 @@ #include "base/function.hpp" #include #include +#include +#include using namespace icinga; @@ -428,6 +430,10 @@ bool ConfigItem::CommitNewItems(const ActivationContext::Ptr& context, WorkQueue if (items.empty()) return true; + // Shuffle all items to evenly distribute them over the threads of the workqueue. This increases perfomance + // noticably in environments with lots of objects and available threads. + std::shuffle(std::begin(items), std::end(items), std::default_random_engine {}); + for (const auto& ip : items) newItems.push_back(ip.first);