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
This commit is contained in:
Philip Kaufmann 2014-02-18 12:48:16 +01:00
parent 77eaa6fc45
commit 5409404d75
5 changed files with 19 additions and 20 deletions

View file

@ -205,7 +205,7 @@ std::string HelpMessage(HelpMessageMode hmm)
strUsage += " -dbcache=<n> " + strprintf(_("Set database cache size in megabytes (%d to %d, default: %d)"), nMinDbCache, nMaxDbCache, nDefaultDbCache) + "\n"; strUsage += " -dbcache=<n> " + strprintf(_("Set database cache size in megabytes (%d to %d, default: %d)"), nMinDbCache, nMaxDbCache, nDefaultDbCache) + "\n";
strUsage += " -keypool=<n> " + _("Set key pool size to <n> (default: 100)") + "\n"; strUsage += " -keypool=<n> " + _("Set key pool size to <n> (default: 100)") + "\n";
strUsage += " -loadblock=<file> " + _("Imports blocks from external blk000??.dat file") + " " + _("on startup") + "\n"; strUsage += " -loadblock=<file> " + _("Imports blocks from external blk000??.dat file") + " " + _("on startup") + "\n";
strUsage += " -par=<n> " + _("Set the number of script verification threads (up to 16, 0 = auto, <0 = leave that many cores free, default: 0)") + "\n"; 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";
strUsage += " -pid=<file> " + _("Specify pid file (default: bitcoind.pid)") + "\n"; strUsage += " -pid=<file> " + _("Specify pid file (default: bitcoind.pid)") + "\n";
strUsage += " -reindex " + _("Rebuild block chain index from current blk000??.dat files") + " " + _("on startup") + "\n"; strUsage += " -reindex " + _("Rebuild block chain index from current blk000??.dat files") + " " + _("on startup") + "\n";
strUsage += " -txindex " + _("Maintain a full transaction index (default: 0)") + "\n"; strUsage += " -txindex " + _("Maintain a full transaction index (default: 0)") + "\n";
@ -519,7 +519,7 @@ bool AppInit2(boost::thread_group& threadGroup)
Checkpoints::fEnabled = GetBoolArg("-checkpoints", true); Checkpoints::fEnabled = GetBoolArg("-checkpoints", true);
// -par=0 means autodetect, but nScriptCheckThreads==0 means no concurrency // -par=0 means autodetect, but nScriptCheckThreads==0 means no concurrency
nScriptCheckThreads = GetArg("-par", 0); nScriptCheckThreads = GetArg("-par", DEFAULT_SCRIPTCHECK_THREADS);
if (nScriptCheckThreads <= 0) if (nScriptCheckThreads <= 0)
nScriptCheckThreads += boost::thread::hardware_concurrency(); nScriptCheckThreads += boost::thread::hardware_concurrency();
if (nScriptCheckThreads <= 1) if (nScriptCheckThreads <= 1)

View file

@ -60,6 +60,8 @@ static const int COINBASE_MATURITY = 100;
static const unsigned int LOCKTIME_THRESHOLD = 500000000; // Tue Nov 5 00:53:20 1985 UTC static const unsigned int LOCKTIME_THRESHOLD = 500000000; // Tue Nov 5 00:53:20 1985 UTC
/** Maximum number of script-checking threads allowed */ /** Maximum number of script-checking threads allowed */
static const int MAX_SCRIPTCHECK_THREADS = 16; static const int MAX_SCRIPTCHECK_THREADS = 16;
/** -par default (number of script-checking threads, 0 = auto) */
static const int DEFAULT_SCRIPTCHECK_THREADS = 0;
/** Number of blocks that can be requested at any given time from a single peer. */ /** Number of blocks that can be requested at any given time from a single peer. */
static const int MAX_BLOCKS_IN_TRANSIT_PER_PEER = 128; static const int MAX_BLOCKS_IN_TRANSIT_PER_PEER = 128;
/** Timeout in seconds before considering a block download peer unresponsive. */ /** Timeout in seconds before considering a block download peer unresponsive. */

View file

@ -98,13 +98,7 @@
<item> <item>
<widget class="QSpinBox" name="threadsScriptVerif"> <widget class="QSpinBox" name="threadsScriptVerif">
<property name="toolTip"> <property name="toolTip">
<string>Set the number of script verification threads (up to 16, 0 = auto, &lt;0 = leave that many cores free, default: 0)</string> <string>(0 = auto, &lt;0 = leave that many cores free)</string>
</property>
<property name="minimum">
<number>-16</number>
</property>
<property name="maximum">
<number>16</number>
</property> </property>
</widget> </widget>
</item> </item>

View file

@ -14,7 +14,7 @@
#include "monitoreddatamapper.h" #include "monitoreddatamapper.h"
#include "optionsmodel.h" #include "optionsmodel.h"
#include "main.h" // for CTransaction::nMinTxFee #include "main.h" // for CTransaction::nMinTxFee and MAX_SCRIPTCHECK_THREADS
#include "netbase.h" #include "netbase.h"
#include "txdb.h" // for -dbcache defaults #include "txdb.h" // for -dbcache defaults
@ -37,6 +37,8 @@ OptionsDialog::OptionsDialog(QWidget *parent) :
/* Main elements init */ /* Main elements init */
ui->databaseCache->setMinimum(nMinDbCache); ui->databaseCache->setMinimum(nMinDbCache);
ui->databaseCache->setMaximum(nMaxDbCache); ui->databaseCache->setMaximum(nMaxDbCache);
ui->threadsScriptVerif->setMinimum(-(int)boost::thread::hardware_concurrency());
ui->threadsScriptVerif->setMaximum(MAX_SCRIPTCHECK_THREADS);
/* Network elements init */ /* Network elements init */
#ifndef USE_UPNP #ifndef USE_UPNP

View file

@ -76,6 +76,17 @@ void OptionsModel::Init()
// by command-line and show this in the UI. // by command-line and show this in the UI.
// Main // Main
if (!settings.contains("nDatabaseCache"))
settings.setValue("nDatabaseCache", (qint64)nDefaultDbCache);
if (!SoftSetArg("-dbcache", settings.value("nDatabaseCache").toString().toStdString()))
addOverriddenOption("-dbcache");
if (!settings.contains("nThreadsScriptVerif"))
settings.setValue("nThreadsScriptVerif", DEFAULT_SCRIPTCHECK_THREADS);
if (!SoftSetArg("-par", settings.value("nThreadsScriptVerif").toString().toStdString()))
addOverriddenOption("-par");
// Wallet
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
if (!settings.contains("nTransactionFee")) if (!settings.contains("nTransactionFee"))
settings.setValue("nTransactionFee", 0); settings.setValue("nTransactionFee", 0);
@ -89,16 +100,6 @@ void OptionsModel::Init()
addOverriddenOption("-spendzeroconfchange"); addOverriddenOption("-spendzeroconfchange");
#endif #endif
if (!settings.contains("nDatabaseCache"))
settings.setValue("nDatabaseCache", (qint64)nDefaultDbCache);
if (!SoftSetArg("-dbcache", settings.value("nDatabaseCache").toString().toStdString()))
addOverriddenOption("-dbcache");
if (!settings.contains("nThreadsScriptVerif"))
settings.setValue("nThreadsScriptVerif", 0);
if (!SoftSetArg("-par", settings.value("nThreadsScriptVerif").toString().toStdString()))
addOverriddenOption("-par");
// Network // Network
if (!settings.contains("fUseUPnP")) if (!settings.contains("fUseUPnP"))
#ifdef USE_UPNP #ifdef USE_UPNP