Skip to content

Commit 5409404

Browse files
author
Philip Kaufmann
committed
add constant for shared (GUI/core) -par settings
- introduce DEFAULT_SCRIPTCHECK_THREADS in main.h - only show values from -"MAX_HW_THREADS" up to 16 for -par, as it makes no sense to try to leave more "cores free" than the system supports anyway - use the new constant in optionsdialog and remove defaults from .ui file
1 parent 77eaa6f commit 5409404

File tree

5 files changed

+19
-20
lines changed

5 files changed

+19
-20
lines changed

src/init.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ std::string HelpMessage(HelpMessageMode hmm)
205205
strUsage += " -dbcache=<n> " + strprintf(_("Set database cache size in megabytes (%d to %d, default: %d)"), nMinDbCache, nMaxDbCache, nDefaultDbCache) + "\n";
206206
strUsage += " -keypool=<n> " + _("Set key pool size to <n> (default: 100)") + "\n";
207207
strUsage += " -loadblock=<file> " + _("Imports blocks from external blk000??.dat file") + " " + _("on startup") + "\n";
208-
strUsage += " -par=<n> " + _("Set the number of script verification threads (up to 16, 0 = auto, <0 = leave that many cores free, default: 0)") + "\n";
208+
strUsage += " -par=<n> " + strprintf(_("Set the number of script verification threads (%u to %d, 0 = auto, <0 = leave that many cores free, default: %d)"), -(int)boost::thread::hardware_concurrency(), MAX_SCRIPTCHECK_THREADS, DEFAULT_SCRIPTCHECK_THREADS) + "\n";
209209
strUsage += " -pid=<file> " + _("Specify pid file (default: bitcoind.pid)") + "\n";
210210
strUsage += " -reindex " + _("Rebuild block chain index from current blk000??.dat files") + " " + _("on startup") + "\n";
211211
strUsage += " -txindex " + _("Maintain a full transaction index (default: 0)") + "\n";
@@ -519,7 +519,7 @@ bool AppInit2(boost::thread_group& threadGroup)
519519
Checkpoints::fEnabled = GetBoolArg("-checkpoints", true);
520520

521521
// -par=0 means autodetect, but nScriptCheckThreads==0 means no concurrency
522-
nScriptCheckThreads = GetArg("-par", 0);
522+
nScriptCheckThreads = GetArg("-par", DEFAULT_SCRIPTCHECK_THREADS);
523523
if (nScriptCheckThreads <= 0)
524524
nScriptCheckThreads += boost::thread::hardware_concurrency();
525525
if (nScriptCheckThreads <= 1)

src/main.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ static const int COINBASE_MATURITY = 100;
6060
static const unsigned int LOCKTIME_THRESHOLD = 500000000; // Tue Nov 5 00:53:20 1985 UTC
6161
/** Maximum number of script-checking threads allowed */
6262
static const int MAX_SCRIPTCHECK_THREADS = 16;
63+
/** -par default (number of script-checking threads, 0 = auto) */
64+
static const int DEFAULT_SCRIPTCHECK_THREADS = 0;
6365
/** Number of blocks that can be requested at any given time from a single peer. */
6466
static const int MAX_BLOCKS_IN_TRANSIT_PER_PEER = 128;
6567
/** Timeout in seconds before considering a block download peer unresponsive. */

src/qt/forms/optionsdialog.ui

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,7 @@
9898
<item>
9999
<widget class="QSpinBox" name="threadsScriptVerif">
100100
<property name="toolTip">
101-
<string>Set the number of script verification threads (up to 16, 0 = auto, &lt;0 = leave that many cores free, default: 0)</string>
102-
</property>
103-
<property name="minimum">
104-
<number>-16</number>
105-
</property>
106-
<property name="maximum">
107-
<number>16</number>
101+
<string>(0 = auto, &lt;0 = leave that many cores free)</string>
108102
</property>
109103
</widget>
110104
</item>

src/qt/optionsdialog.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include "monitoreddatamapper.h"
1515
#include "optionsmodel.h"
1616

17-
#include "main.h" // for CTransaction::nMinTxFee
17+
#include "main.h" // for CTransaction::nMinTxFee and MAX_SCRIPTCHECK_THREADS
1818
#include "netbase.h"
1919
#include "txdb.h" // for -dbcache defaults
2020

@@ -37,6 +37,8 @@ OptionsDialog::OptionsDialog(QWidget *parent) :
3737
/* Main elements init */
3838
ui->databaseCache->setMinimum(nMinDbCache);
3939
ui->databaseCache->setMaximum(nMaxDbCache);
40+
ui->threadsScriptVerif->setMinimum(-(int)boost::thread::hardware_concurrency());
41+
ui->threadsScriptVerif->setMaximum(MAX_SCRIPTCHECK_THREADS);
4042

4143
/* Network elements init */
4244
#ifndef USE_UPNP

src/qt/optionsmodel.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,17 @@ void OptionsModel::Init()
7676
// by command-line and show this in the UI.
7777

7878
// Main
79+
if (!settings.contains("nDatabaseCache"))
80+
settings.setValue("nDatabaseCache", (qint64)nDefaultDbCache);
81+
if (!SoftSetArg("-dbcache", settings.value("nDatabaseCache").toString().toStdString()))
82+
addOverriddenOption("-dbcache");
83+
84+
if (!settings.contains("nThreadsScriptVerif"))
85+
settings.setValue("nThreadsScriptVerif", DEFAULT_SCRIPTCHECK_THREADS);
86+
if (!SoftSetArg("-par", settings.value("nThreadsScriptVerif").toString().toStdString()))
87+
addOverriddenOption("-par");
88+
89+
// Wallet
7990
#ifdef ENABLE_WALLET
8091
if (!settings.contains("nTransactionFee"))
8192
settings.setValue("nTransactionFee", 0);
@@ -89,16 +100,6 @@ void OptionsModel::Init()
89100
addOverriddenOption("-spendzeroconfchange");
90101
#endif
91102

92-
if (!settings.contains("nDatabaseCache"))
93-
settings.setValue("nDatabaseCache", (qint64)nDefaultDbCache);
94-
if (!SoftSetArg("-dbcache", settings.value("nDatabaseCache").toString().toStdString()))
95-
addOverriddenOption("-dbcache");
96-
97-
if (!settings.contains("nThreadsScriptVerif"))
98-
settings.setValue("nThreadsScriptVerif", 0);
99-
if (!SoftSetArg("-par", settings.value("nThreadsScriptVerif").toString().toStdString()))
100-
addOverriddenOption("-par");
101-
102103
// Network
103104
if (!settings.contains("fUseUPnP"))
104105
#ifdef USE_UPNP

0 commit comments

Comments
 (0)