add a --max-concurrency flag

It sets the max number of threads to use for a parallel job.
This is different that the number of total threads, since monero
binaries typically start a lot of them.
This commit is contained in:
moneromooo-monero 2016-04-28 20:25:33 +01:00
parent bdb93cbf3d
commit 513a658c87
No known key found for this signature in database
GPG key ID: 686F07454D6CEFC3
8 changed files with 47 additions and 7 deletions

View file

@ -2124,7 +2124,7 @@ bool Blockchain::check_tx_inputs(const transaction& tx, tx_verification_context
std::vector < uint64_t > results;
results.resize(tx.vin.size(), 0);
int threads = boost::thread::hardware_concurrency();
int threads = tools::get_max_concurrency();
boost::asio::io_service ioservice;
boost::thread_group threadpool;
@ -3001,7 +3001,7 @@ bool Blockchain::prepare_handle_incoming_blocks(const std::list<block_complete_e
return true;
bool blocks_exist = false;
uint64_t threads = boost::thread::hardware_concurrency();
uint64_t threads = tools::get_max_concurrency();
if (blocks_entry.size() > 1 && threads > 1 && m_max_prepare_blocks_threads > 1)
{
@ -3200,7 +3200,7 @@ bool Blockchain::prepare_handle_incoming_blocks(const std::list<block_complete_e
// [output] stores all transactions for each tx_out_index::hash found
std::vector<std::unordered_map<crypto::hash, cryptonote::transaction>> transactions(amounts.size());
threads = boost::thread::hardware_concurrency();
threads = tools::get_max_concurrency();
if (!m_db->can_thread_bulk_indices())
threads = 1;