coinstats: avoid unnecessary Coin copy in ApplyHash #33410
pull sashass1315 wants to merge 1 commits into bitcoin:master from sashass1315:master changing 1 files +1 −1-
sashass1315 commented at 8:47 am on September 17, 2025: noneReplace local Coin coin = it->second; with const Coin& coin = it->second; when iterating outputs in ApplyHash. The hash serialization path only reads from the Coin, and outputs remains valid for the loop’s duration, so copying is unnecessary. This reduces potential allocations (due to CTxOut/CScript) and improves performance without changing behavior.
-
coinstats: avoid unnecessary Coin copy in ApplyHash 5a56203f4e
-
DrahtBot commented at 8:47 am on September 17, 2025: contributor
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Code Coverage & Benchmarks
For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/33410.
Reviews
See the guideline for information on the review process.
Type Reviewers Concept ACK Raimo33 If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.
-
in src/kernel/coinstats.cpp:96 in 5a56203f4e
92@@ -93,7 +93,7 @@ static void ApplyHash(T& hash_obj, const Txid& hash, const std::map<uint32_t, Co 93 { 94 for (auto it = outputs.begin(); it != outputs.end(); ++it) { 95 COutPoint outpoint = COutPoint(hash, it->first); 96- Coin coin = it->second;
l0rinc commented at 4:18 pm on September 17, 2025:given the above warning, can you create a godbolt reproducer to check if the compiler can already deduce this or not?Raimo33 commented at 5:33 pm on September 17, 2025: noneConcept ACK, I want to expand on l0rinc suggestion by saying that, given the above warning, I think this should only be merged if it results in a significant performance improvement. @sashass1315 are you able to run some before/after benchmarks?
github-metadata-mirror
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-09-26 15:13 UTC
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-09-26 15:13 UTC
This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me
More mirrored repositories can be found on mirror.b10c.me