Shuffle items before config validation

refs #6581
This commit is contained in:
Jean Flach 2018-08-31 13:11:50 +02:00 committed by Michael Friedrich
parent 7f7e81d905
commit 6ebb507af7
1 changed files with 6 additions and 0 deletions

View File

@ -38,6 +38,8 @@
#include "base/function.hpp"
#include <sstream>
#include <fstream>
#include <algorithm>
#include <random>
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);