]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
lmdb-safe: Use unordered maps for the transaction maps 15776/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 27 Jun 2025 10:15:48 +0000 (12:15 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 2 Jul 2025 14:07:08 +0000 (16:07 +0200)
We don't need the maps to be ordered, and unordered maps are usually
slightly faster.

Signed-off-by: Remi Gacogne <remi.gacogne@powerdns.com>
(cherry picked from commit 883aec59cf56f9345b0a229ed7af35490a113494)

ext/lmdb-safe/lmdb-safe.hh

index 2f19124c698f5b1b96e4b9cf6c3e2fa9fba94957..294fba6bae41d93b05c28e95f538d16a5dfb0d1a 100644 (file)
@@ -5,7 +5,7 @@
 #include <stdexcept>
 #include <string_view>
 #include <lmdb.h>
-#include <map>
+#include <unordered_map>
 #include <thread>
 #include <memory>
 #include <string>
@@ -111,8 +111,8 @@ public:
 private:
   std::mutex d_openmut;
   std::shared_mutex d_countmutex;
-  std::map<std::thread::id, std::atomic<int>> d_RWtransactionsOut;
-  std::map<std::thread::id, std::atomic<int>> d_ROtransactionsOut;
+  std::unordered_map<std::thread::id, std::atomic<int>> d_RWtransactionsOut;
+  std::unordered_map<std::thread::id, std::atomic<int>> d_ROtransactionsOut;
 };
 
 std::shared_ptr<MDBEnv> getMDBEnv(const char* fname, int flags, int mode, uint64_t mapsizeMB=(sizeof(void *)==4) ? 100 : 16000);