Merge #15163: Correct units for "-dbcache" and "-prune"
6f6514a080
Correct units for "-dbcache" and "-prune" (Hennadii Stepanov) Pull request description: Actually, all `dbcache`-related values in the code are measured in MiB (not in megabytes, MB) or in bytes (e.g., `nTotalCache`). See: https://github.com/bitcoin/bitcoin/blob/master/src/txdb.hba8c8b2227/src/init.cpp (L1405-L1424)
Also, "-prune" is fixed: 1. The GUI values in GB are translated to the node values in MiB correctly. 2. The maximum of the "prune" `QSpinBox` is not limited by default value of 99 (GB). Fix: #15106 Tree-SHA512: 151ec43b31b1074db8b345fedb1dcc10bde225899a5296bfc183f57e1553d13ac27db8db100226646769ad03c9fcab29d88763065a471757c6c41ac51108459d
This commit is contained in:
commit
77339e5c24
8 changed files with 24 additions and 19 deletions
12
src/init.cpp
12
src/init.cpp
|
@ -352,7 +352,7 @@ void SetupServerArgs()
|
|||
gArgs.AddArg("-conf=<file>", strprintf("Specify configuration file. Relative paths will be prefixed by datadir location. (default: %s)", BITCOIN_CONF_FILENAME), false, OptionsCategory::OPTIONS);
|
||||
gArgs.AddArg("-datadir=<dir>", "Specify data directory", false, OptionsCategory::OPTIONS);
|
||||
gArgs.AddArg("-dbbatchsize", strprintf("Maximum database write batch size in bytes (default: %u)", nDefaultDbBatchSize), true, OptionsCategory::OPTIONS);
|
||||
gArgs.AddArg("-dbcache=<n>", strprintf("Set database cache size in megabytes (%d to %d, default: %d)", nMinDbCache, nMaxDbCache, nDefaultDbCache), false, OptionsCategory::OPTIONS);
|
||||
gArgs.AddArg("-dbcache=<n>", strprintf("Set database cache size in MiB (%d to %d, default: %d)", nMinDbCache, nMaxDbCache, nDefaultDbCache), false, OptionsCategory::OPTIONS);
|
||||
gArgs.AddArg("-debuglogfile=<file>", strprintf("Specify location of debug log file. Relative paths will be prefixed by a net-specific datadir location. (-nodebuglogfile to disable; default: %s)", DEFAULT_DEBUGLOGFILE), false, OptionsCategory::OPTIONS);
|
||||
gArgs.AddArg("-feefilter", strprintf("Tell other nodes to filter invs to us by our mempool min fee (default: %u)", DEFAULT_FEEFILTER), true, OptionsCategory::OPTIONS);
|
||||
gArgs.AddArg("-includeconf=<file>", "Specify additional configuration file, relative to the -datadir path (only useable from configuration file, not command line)", false, OptionsCategory::OPTIONS);
|
||||
|
@ -1061,7 +1061,7 @@ bool AppInitParameterInteraction()
|
|||
if (nPruneTarget < MIN_DISK_SPACE_FOR_BLOCK_FILES) {
|
||||
return InitError(strprintf(_("Prune configured below the minimum of %d MiB. Please use a higher number."), MIN_DISK_SPACE_FOR_BLOCK_FILES / 1024 / 1024));
|
||||
}
|
||||
LogPrintf("Prune configured to target %uMiB on disk for block and undo files.\n", nPruneTarget / 1024 / 1024);
|
||||
LogPrintf("Prune configured to target %u MiB on disk for block and undo files.\n", nPruneTarget / 1024 / 1024);
|
||||
fPruneMode = true;
|
||||
}
|
||||
|
||||
|
@ -1423,12 +1423,12 @@ bool AppInitMain(InitInterfaces& interfaces)
|
|||
nCoinCacheUsage = nTotalCache; // the rest goes to in-memory cache
|
||||
int64_t nMempoolSizeMax = gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000;
|
||||
LogPrintf("Cache configuration:\n");
|
||||
LogPrintf("* Using %.1fMiB for block index database\n", nBlockTreeDBCache * (1.0 / 1024 / 1024));
|
||||
LogPrintf("* Using %.1f MiB for block index database\n", nBlockTreeDBCache * (1.0 / 1024 / 1024));
|
||||
if (gArgs.GetBoolArg("-txindex", DEFAULT_TXINDEX)) {
|
||||
LogPrintf("* Using %.1fMiB for transaction index database\n", nTxIndexCache * (1.0 / 1024 / 1024));
|
||||
LogPrintf("* Using %.1f MiB for transaction index database\n", nTxIndexCache * (1.0 / 1024 / 1024));
|
||||
}
|
||||
LogPrintf("* Using %.1fMiB for chain state database\n", nCoinDBCache * (1.0 / 1024 / 1024));
|
||||
LogPrintf("* Using %.1fMiB for in-memory UTXO set (plus up to %.1fMiB of unused mempool space)\n", nCoinCacheUsage * (1.0 / 1024 / 1024), nMempoolSizeMax * (1.0 / 1024 / 1024));
|
||||
LogPrintf("* Using %.1f MiB for chain state database\n", nCoinDBCache * (1.0 / 1024 / 1024));
|
||||
LogPrintf("* Using %.1f MiB for in-memory UTXO set (plus up to %.1f MiB of unused mempool space)\n", nCoinCacheUsage * (1.0 / 1024 / 1024), nMempoolSizeMax * (1.0 / 1024 / 1024));
|
||||
|
||||
bool fLoaded = false;
|
||||
while (!fLoaded && !ShutdownRequested()) {
|
||||
|
|
|
@ -121,7 +121,7 @@
|
|||
<item>
|
||||
<widget class="QLabel" name="databaseCacheUnitLabel">
|
||||
<property name="text">
|
||||
<string>MB</string>
|
||||
<string>MiB</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::PlainText</enum>
|
||||
|
|
|
@ -52,4 +52,7 @@ static const int MAX_URI_LENGTH = 255;
|
|||
#define QAPP_APP_NAME_TESTNET "Bitcoin-Qt-testnet"
|
||||
#define QAPP_APP_NAME_REGTEST "Bitcoin-Qt-regtest"
|
||||
|
||||
/* One gigabyte (GB) in bytes */
|
||||
static constexpr uint64_t GB_BYTES{1000000000};
|
||||
|
||||
#endif // BITCOIN_QT_GUICONSTANTS_H
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <qt/intro.h>
|
||||
#include <qt/forms/ui_intro.h>
|
||||
|
||||
#include <qt/guiconstants.h>
|
||||
#include <qt/guiutil.h>
|
||||
|
||||
#include <interfaces/node.h>
|
||||
|
@ -21,7 +22,6 @@
|
|||
|
||||
#include <cmath>
|
||||
|
||||
static const uint64_t GB_BYTES = 1000000000LL;
|
||||
/* Total required space (in GB) depending on user choice (prune, not prune) */
|
||||
static uint64_t requiredSpace;
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <qt/forms/ui_optionsdialog.h>
|
||||
|
||||
#include <qt/bitcoinunits.h>
|
||||
#include <qt/guiconstants.h>
|
||||
#include <qt/guiutil.h>
|
||||
#include <qt/optionsmodel.h>
|
||||
|
||||
|
@ -37,10 +38,6 @@ OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) :
|
|||
/* Main elements init */
|
||||
ui->databaseCache->setMinimum(nMinDbCache);
|
||||
ui->databaseCache->setMaximum(nMaxDbCache);
|
||||
static const uint64_t GiB = 1024 * 1024 * 1024;
|
||||
static const uint64_t nMinDiskSpace = MIN_DISK_SPACE_FOR_BLOCK_FILES / GiB +
|
||||
(MIN_DISK_SPACE_FOR_BLOCK_FILES % GiB) ? 1 : 0;
|
||||
ui->pruneSize->setMinimum(nMinDiskSpace);
|
||||
ui->threadsScriptVerif->setMinimum(-GetNumCores());
|
||||
ui->threadsScriptVerif->setMaximum(MAX_SCRIPTCHECK_THREADS);
|
||||
ui->pruneWarning->setVisible(false);
|
||||
|
@ -167,6 +164,10 @@ void OptionsDialog::setModel(OptionsModel *_model)
|
|||
mapper->toFirst();
|
||||
|
||||
updateDefaultProxyNets();
|
||||
|
||||
// Prune values are in GB to be consistent with intro.cpp
|
||||
static constexpr uint64_t nMinDiskSpace = (MIN_DISK_SPACE_FOR_BLOCK_FILES / GB_BYTES) + (MIN_DISK_SPACE_FOR_BLOCK_FILES % GB_BYTES) ? 1 : 0;
|
||||
ui->pruneSize->setRange(nMinDiskSpace, _model->node().getAssumedBlockchainSize());
|
||||
}
|
||||
|
||||
/* warn when one of the following settings changes by user action (placed here so init via mapper doesn't trigger them) */
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <qt/optionsmodel.h>
|
||||
|
||||
#include <qt/bitcoinunits.h>
|
||||
#include <qt/guiconstants.h>
|
||||
#include <qt/guiutil.h>
|
||||
|
||||
#include <interfaces/node.h>
|
||||
|
@ -92,9 +93,9 @@ void OptionsModel::Init(bool resetSettings)
|
|||
settings.setValue("bPrune", false);
|
||||
if (!settings.contains("nPruneSize"))
|
||||
settings.setValue("nPruneSize", 2);
|
||||
// Convert prune size to MB:
|
||||
const uint64_t nPruneSizeMB = settings.value("nPruneSize").toInt() * 1000;
|
||||
if (!m_node.softSetArg("-prune", settings.value("bPrune").toBool() ? std::to_string(nPruneSizeMB) : "0")) {
|
||||
// Convert prune size from GB to MiB:
|
||||
const uint64_t nPruneSizeMiB = (settings.value("nPruneSize").toInt() * GB_BYTES) >> 20;
|
||||
if (!m_node.softSetArg("-prune", settings.value("bPrune").toBool() ? std::to_string(nPruneSizeMiB) : "0")) {
|
||||
addOverriddenOption("-prune");
|
||||
}
|
||||
|
||||
|
|
|
@ -201,14 +201,14 @@ static const unsigned int NODE_NETWORK_LIMITED_MIN_BLOCKS = 288;
|
|||
static const signed int DEFAULT_CHECKBLOCKS = 6;
|
||||
static const unsigned int DEFAULT_CHECKLEVEL = 3;
|
||||
|
||||
// Require that user allocate at least 550MB for block & undo files (blk???.dat and rev???.dat)
|
||||
// Require that user allocate at least 550 MiB for block & undo files (blk???.dat and rev???.dat)
|
||||
// At 1MB per block, 288 blocks = 288MB.
|
||||
// Add 15% for Undo data = 331MB
|
||||
// Add 20% for Orphan block rate = 397MB
|
||||
// We want the low water mark after pruning to be at least 397 MB and since we prune in
|
||||
// full block file chunks, we need the high water mark which triggers the prune to be
|
||||
// one 128MB block file + added 15% undo data = 147MB greater for a total of 545MB
|
||||
// Setting the target to > than 550MB will make it likely we can respect the target.
|
||||
// Setting the target to >= 550 MiB will make it likely we can respect the target.
|
||||
static const uint64_t MIN_DISK_SPACE_FOR_BLOCK_FILES = 550 * 1024 * 1024;
|
||||
|
||||
/**
|
||||
|
|
|
@ -320,7 +320,7 @@ class PruneTest(BitcoinTestFramework):
|
|||
if has_block(3):
|
||||
raise AssertionError("blk00003.dat is still there, should be pruned by now")
|
||||
|
||||
# stop node, start back up with auto-prune at 550MB, make sure still runs
|
||||
# stop node, start back up with auto-prune at 550 MiB, make sure still runs
|
||||
self.stop_node(node_number)
|
||||
self.start_node(node_number, extra_args=["-prune=550"])
|
||||
|
||||
|
|
Loading…
Reference in a new issue