mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-08 11:44:14 +01:00
Moved the repeated -printpriority fetching out of AddToBlock
AddToBlock was called repeatedly from `addPackageTxs` where the constant value of `printpriority` is recalculated every time.
Since its behavior was changed in 400b151, I've named the variable accordingly.
This showed up during profiling of AssembleBlock, fetching it once in the constructor results in a measurable speed increase for many iterations.
> ./src/bench/bench_bitcoin --filter='AssembleBlock' --min-time=1000
before:
| ns/op | op/s | err% | total | benchmark
|--------------------:|--------------------:|--------:|----------:|:----------
| 155,558.97 | 6,428.43 | 0.1% | 1.10 | `AssembleBlock`
after:
| ns/op | op/s | err% | total | benchmark
|--------------------:|--------------------:|--------:|----------:|:----------
| 148,083.68 | 6,752.94 | 0.1% | 1.10 | `AssembleBlock`
Co-authored-by: furszy <mfurszy@protonmail.com>
This commit is contained in:
@@ -79,6 +79,7 @@ void ApplyArgsManOptions(const ArgsManager& args, BlockAssembler::Options& optio
|
||||
if (const auto blockmintxfee{args.GetArg("-blockmintxfee")}) {
|
||||
if (const auto parsed{ParseMoney(*blockmintxfee)}) options.blockMinFeeRate = CFeeRate{*parsed};
|
||||
}
|
||||
options.print_modified_fee = args.GetBoolArg("-printpriority", options.print_modified_fee);
|
||||
}
|
||||
|
||||
void BlockAssembler::resetBlock()
|
||||
@@ -222,8 +223,7 @@ void BlockAssembler::AddToBlock(CTxMemPool::txiter iter)
|
||||
nFees += iter->GetFee();
|
||||
inBlock.insert(iter->GetSharedTx()->GetHash());
|
||||
|
||||
bool fPrintPriority = gArgs.GetBoolArg("-printpriority", DEFAULT_PRINTPRIORITY);
|
||||
if (fPrintPriority) {
|
||||
if (m_options.print_modified_fee) {
|
||||
LogPrintf("fee rate %s txid %s\n",
|
||||
CFeeRate(iter->GetModifiedFee(), iter->GetTxSize()).ToString(),
|
||||
iter->GetTx().GetHash().ToString());
|
||||
|
||||
@@ -30,7 +30,7 @@ class ChainstateManager;
|
||||
namespace Consensus { struct Params; };
|
||||
|
||||
namespace node {
|
||||
static const bool DEFAULT_PRINTPRIORITY = false;
|
||||
static const bool DEFAULT_PRINT_MODIFIED_FEE = false;
|
||||
|
||||
struct CBlockTemplate
|
||||
{
|
||||
@@ -159,6 +159,7 @@ public:
|
||||
CFeeRate blockMinFeeRate{DEFAULT_BLOCK_MIN_TX_FEE};
|
||||
// Whether to call TestBlockValidity() at the end of CreateNewBlock().
|
||||
bool test_block_validity{true};
|
||||
bool print_modified_fee{DEFAULT_PRINT_MODIFIED_FEE};
|
||||
};
|
||||
|
||||
explicit BlockAssembler(Chainstate& chainstate, const CTxMemPool* mempool, const Options& options);
|
||||
|
||||
Reference in New Issue
Block a user