aboutsummaryrefslogtreecommitdiff
path: root/src/node
diff options
context:
space:
mode:
authorAva Chow <github@achow101.com>2024-07-02 16:43:45 -0400
committerAva Chow <github@achow101.com>2024-07-02 16:43:45 -0400
commitbe63674c182ed007c902d3004d0a17f34f8b2ece (patch)
treed23f27022194c7654695ea0666108aedbc8fa805 /src/node
parent1e16b10cfa238d80a6f8b3bbbc809a8586f8c26d (diff)
parent323ce303086d42292ed9fe7c98e8b459bdf6d1a6 (diff)
Merge bitcoin/bitcoin#30324: optimization: Moved repeated `-printpriority` fetching out of AddToBlock
323ce303086d42292ed9fe7c98e8b459bdf6d1a6 Moved the repeated -printpriority fetching out of AddToBlock (LÅ‘rinc) Pull request description: `AddToBlock` was called repeatedly from `addPackageTxs` where the constant value of `printpriority` is recalculated every time. <img src="https://github.com/bitcoin/bitcoin/assets/1841944/6fd89647-7b6c-4f44-bd04-98d16cd2a938"> This showed up during profiling of AssembleBlock, fetching it once in the constructor results in a small speed increase for many iterations. > ./src/bench/bench_bitcoin --filter='AssembleBlock' --min-time=10000 before: | ns/op | op/s | err% | total | benchmark |--------------------:|--------------------:|--------:|----------:|:---------- | 156,460.15 | 6,391.40 | 0.1% | 11.03 | `AssembleBlock` after: | ns/op | op/s | err% | total | benchmark |--------------------:|--------------------:|--------:|----------:|:---------- | 149,289.55 | 6,698.39 | 0.3% | 10.97 | `AssembleBlock` --- The slight speedup shows up in CI as well: <img src="https://github.com/bitcoin/bitcoin/assets/1841944/3be779c9-2dce-4a96-ae5f-cab5435bd72f"> ACKs for top commit: maflcko: ACK 323ce303086d42292ed9fe7c98e8b459bdf6d1a6 achow101: ACK 323ce303086d42292ed9fe7c98e8b459bdf6d1a6 tdb3: re ACK 323ce303086d42292ed9fe7c98e8b459bdf6d1a6 furszy: utACK 323ce303086 Tree-SHA512: c2a0aab429646453ad0470956529f1cac8c38778c4c53f82c92c6cbaaaeb69f3d3603c0014ff097844b151e9da7caa2371a4676244caea96527cb540e66825a3
Diffstat (limited to 'src/node')
-rw-r--r--src/node/miner.cpp4
-rw-r--r--src/node/miner.h3
2 files changed, 4 insertions, 3 deletions
diff --git a/src/node/miner.cpp b/src/node/miner.cpp
index 03c6d74deb..291f1d5fc7 100644
--- a/src/node/miner.cpp
+++ b/src/node/miner.cpp
@@ -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());
diff --git a/src/node/miner.h b/src/node/miner.h
index c3178a7532..622ca16c8f 100644
--- a/src/node/miner.h
+++ b/src/node/miner.h
@@ -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);