]> granicus.if.org Git - icinga2/commitdiff
Shuffle items before config validation 6581/head
authorJean Flach <jean-marcel.flach@icinga.com>
Fri, 31 Aug 2018 11:11:50 +0000 (13:11 +0200)
committerMichael Friedrich <michael.friedrich@icinga.com>
Tue, 4 Sep 2018 09:10:27 +0000 (11:10 +0200)
lib/config/configitem.cpp

index 47b7e327cdf86a3bf5a52eec643a262467400ad9..9ac4fddaf5413550599e3af9d7622d73ae84b448 100644 (file)
@@ -39,6 +39,8 @@
 #include <boost/algorithm/string/join.hpp>
 #include <sstream>
 #include <fstream>
+#include <algorithm>
+#include <random>
 
 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);