]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Reduce mmap size for lmdb on 32 bits plus restrict number of shards 7700/head
authorbert hubert <bert.hubert@netherlabs.nl>
Wed, 10 Apr 2019 13:20:13 +0000 (15:20 +0200)
committerbert hubert <bert.hubert@netherlabs.nl>
Wed, 10 Apr 2019 13:20:13 +0000 (15:20 +0200)
modules/lmdbbackend/lmdb-safe.cc
modules/lmdbbackend/lmdbbackend.cc

index eea586455bb0903eb413f99d5fc2e335120ced35..094303f2533dbfab77978f059bbab4c66d7922bf 100644 (file)
@@ -26,8 +26,10 @@ MDBDbi::MDBDbi(MDB_env* env, MDB_txn* txn, const string_view dbname, int flags)
 
 MDBEnv::MDBEnv(const char* fname, int flags, int mode)
 {
-  mdb_env_create(&d_env);   
-  if(mdb_env_set_mapsize(d_env, 16ULL*4096*244140ULL)) // 4GB
+  mdb_env_create(&d_env);
+  uint64_t mapsizeMB = (sizeof(long)==4) ? 100 : 16000;
+  // on 32 bit platforms, there is just no room for more
+  if(mdb_env_set_mapsize(d_env, mapsizeMB * 1048576))
     throw std::runtime_error("setting map size");
     /*
 Various other options may also need to be set before opening the handle, e.g. mdb_env_set_mapsize(), mdb_env_set_maxreaders(), mdb_env_set_maxdbs(),
index 58c61e5c17e4b253e492d97d45616c8f7bdc1d21..c4a48a538860149c224221743e36580cde97e180 100644 (file)
@@ -1592,7 +1592,8 @@ public:
   {
     declare(suffix,"filename","Filename for lmdb","./pdns.lmdb");
     declare(suffix,"sync-mode","Synchronisation mode: nosync, nometasync, mapasync","mapasync");
-    declare(suffix,"shards","Records database will be split into this number of shards","64");
+    // there just is no room for more on 32 bit
+    declare(suffix,"shards","Records database will be split into this number of shards", (sizeof(long) == 4) ? "2" : "64"); 
   }
   DNSBackend *make(const string &suffix="")
   {