mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Improve automatic tuning of thread pool:
The job queue can automatically tune the number of threads that it creates based on the number of processors or processor cores that are available. The existing tuning was very conservative, limiting the maximum number of threads to only 6. Adjust the new algorithm to allow a larger number of threads and allow server administrators to override the value in the config file.
This commit is contained in:
committed by
Nik Bougalis
parent
cb91d56d07
commit
68b8ffdb63
@@ -152,7 +152,8 @@ JobQueue::getJobCountGE (JobType t) const
|
||||
}
|
||||
|
||||
void
|
||||
JobQueue::setThreadCount (int c, bool const standaloneMode)
|
||||
JobQueue::setThreadCount (int c, bool const standaloneMode,
|
||||
bool const validator)
|
||||
{
|
||||
if (standaloneMode)
|
||||
{
|
||||
@@ -161,10 +162,18 @@ JobQueue::setThreadCount (int c, bool const standaloneMode)
|
||||
else if (c == 0)
|
||||
{
|
||||
c = static_cast<int>(std::thread::hardware_concurrency());
|
||||
c = 2 + std::min (c, 4); // I/O will bottleneck
|
||||
|
||||
JLOG(m_journal.info()) << "Auto-tuning to " << c <<
|
||||
" validation/transaction/proposal threads";
|
||||
if (validator)
|
||||
c = 2 + std::min(c, 4); // I/O will bottleneck
|
||||
else
|
||||
c *= 2; // Tested to improve stability under high RPC load.
|
||||
JLOG (m_journal.info()) << "Auto-tuning to " << c <<
|
||||
" validation/transaction/proposal threads for " <<
|
||||
(validator ? "" : "non-") << "validator.";
|
||||
}
|
||||
else
|
||||
{
|
||||
JLOG (m_journal.info()) << "Configured " << c <<
|
||||
" validation/transaction/proposal threads.";
|
||||
}
|
||||
|
||||
m_workers.setNumberOfThreads (c);
|
||||
|
||||
Reference in New Issue
Block a user