mirror of https://github.com/Icinga/icinga2.git
Shuffle items before config validation
This commit is contained in:
parent
504b8a17a3
commit
c721c302cd
|
@ -39,6 +39,8 @@
|
||||||
#include <boost/algorithm/string/join.hpp>
|
#include <boost/algorithm/string/join.hpp>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <random>
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
|
@ -437,6 +439,10 @@ bool ConfigItem::CommitNewItems(const ActivationContext::Ptr& context, WorkQueue
|
||||||
if (items.empty())
|
if (items.empty())
|
||||||
return true;
|
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)
|
for (const auto& ip : items)
|
||||||
newItems.push_back(ip.first);
|
newItems.push_back(ip.first);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue