aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2017-11-14 15:30:03 +0200
committerRiccardo Spagni <ric@spagni.net>2017-11-14 15:30:03 +0200
commit0d0ce8c21e2b0dafbf9e684144ebbdf6682578e5 (patch)
tree827494a037b78191469402bea893a2c5f37534a7 /src
parentMerge pull request #2738 (diff)
parentIncrease LMDB maxreaders if large number of threads in use (diff)
downloadmonero-0d0ce8c21e2b0dafbf9e684144ebbdf6682578e5.tar.xz
Merge pull request #2742
7c7d3672 Increase LMDB maxreaders if large number of threads in use (Howard Chu) 6738753b Use max_concurrency as-is (Howard Chu)
Diffstat (limited to 'src')
-rw-r--r--src/blockchain_db/lmdb/db_lmdb.cpp6
-rw-r--r--src/common/threadpool.cpp4
2 files changed, 8 insertions, 2 deletions
diff --git a/src/blockchain_db/lmdb/db_lmdb.cpp b/src/blockchain_db/lmdb/db_lmdb.cpp
index 6ebb35639..6cf74b3b0 100644
--- a/src/blockchain_db/lmdb/db_lmdb.cpp
+++ b/src/blockchain_db/lmdb/db_lmdb.cpp
@@ -34,6 +34,7 @@
#include <cstring> // memcpy
#include <random>
+#include "common/util.h"
#include "cryptonote_basic/cryptonote_format_utils.h"
#include "crypto/crypto.h"
#include "profile_tools.h"
@@ -1135,6 +1136,11 @@ void BlockchainLMDB::open(const std::string& filename, const int db_flags)
if ((result = mdb_env_set_maxdbs(m_env, 20)))
throw0(DB_ERROR(lmdb_error("Failed to set max number of dbs: ", result).c_str()));
+ int threads = tools::get_max_concurrency();
+ if (threads > 110 && /* maxreaders default is 126, leave some slots for other read processes */
+ (result = mdb_env_set_maxreaders(m_env, threads+16)))
+ throw0(DB_ERROR(lmdb_error("Failed to set max number of readers: ", result).c_str()));
+
size_t mapsize = DEFAULT_MAPSIZE;
if (db_flags & DBF_FAST)
diff --git a/src/common/threadpool.cpp b/src/common/threadpool.cpp
index 41d0c25e0..20c5765b0 100644
--- a/src/common/threadpool.cpp
+++ b/src/common/threadpool.cpp
@@ -39,7 +39,7 @@ namespace tools
threadpool::threadpool() : running(true), active(0) {
boost::thread::attributes attrs;
attrs.set_stack_size(THREAD_STACK_SIZE);
- max = tools::get_max_concurrency() * 2;
+ max = tools::get_max_concurrency();
size_t i = max;
while(i--) {
threads.push_back(boost::thread(attrs, boost::bind(&threadpool::run, this)));
@@ -74,7 +74,7 @@ void threadpool::submit(waiter *obj, std::function<void()> f) {
}
int threadpool::get_max_concurrency() {
- return max / 2;
+ return max;
}
void threadpool::waiter::wait() {