From 6738753b3054aa69a4b585d3d9c1fdbd2b0824d4 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Mon, 30 Oct 2017 18:06:05 +0000 Subject: [PATCH 1/2] Use max_concurrency as-is Don't try to 2nd guess user --- src/common/threadpool.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 f) { } int threadpool::get_max_concurrency() { - return max / 2; + return max; } void threadpool::waiter::wait() { From 7c7d36725ae184f2357d2296397c905ca486dbca Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Mon, 30 Oct 2017 18:06:32 +0000 Subject: [PATCH 2/2] Increase LMDB maxreaders if large number of threads in use --- src/blockchain_db/lmdb/db_lmdb.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/blockchain_db/lmdb/db_lmdb.cpp b/src/blockchain_db/lmdb/db_lmdb.cpp index 3979a5edf..c44f7ad25 100644 --- a/src/blockchain_db/lmdb/db_lmdb.cpp +++ b/src/blockchain_db/lmdb/db_lmdb.cpp @@ -34,6 +34,7 @@ #include // memcpy #include +#include "common/util.h" #include "cryptonote_basic/cryptonote_format_utils.h" #include "crypto/crypto.h" #include "profile_tools.h" @@ -1129,6 +1130,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)