diff --git a/lib/config/configitem.cpp b/lib/config/configitem.cpp index 47b7e327c..9ac4fddaf 100644 --- a/lib/config/configitem.cpp +++ b/lib/config/configitem.cpp @@ -39,6 +39,8 @@ #include #include #include +#include +#include using namespace icinga; @@ -437,6 +439,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);