-
Notifications
You must be signed in to change notification settings - Fork 37.8k
test: Removed implicit CTransaction constructor calls from tests and benchmarks. #14908
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: Removed implicit CTransaction constructor calls from tests and benchmarks. #14908
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
src/bench/ccoins_caching.cpp
Outdated
@@ -76,10 +76,11 @@ static void CCoinsCaching(benchmark::State& state) | |||
t1.vout[0].scriptPubKey << OP_1; | |||
|
|||
// Benchmark. | |||
CTransaction cTx(t1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be const and shout be snake case? tx_1
?
src/bench/mempool_eviction.cpp
Outdated
@@ -127,7 +128,7 @@ static void MempoolEviction(benchmark::State& state) | |||
AddTx(tx6_r, 1100LL, pool); | |||
AddTx(tx7_r, 9000LL, pool); | |||
pool.TrimToSize(pool.DynamicMemoryUsage() * 3 / 4); | |||
pool.TrimToSize(GetVirtualTransactionSize(tx1)); | |||
pool.TrimToSize(GetVirtualTransactionSize(cTx)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't this just use tx1_r
?
Concept ACK Explicit is better than implicit – especially when it comes to conversions. |
explicit utACK 8db0c3d |
…rom tests and benchmarks. 8db0c3d Removed implicit CTransaction conversion from benchmaks (lucash-dev) ed61abe Removed implicit CTransaction constructor from tests (lucash-dev) Pull request description: This PR was split from #14906 and is a prerequisite for it. It updates tests and benchmarks, removing all implicit calls to `CTransaction(CMutableTransaction&)` constructors. This will make possible making the constructor explicit in the next PR. The original rationale for making the constructor explicit: - Conversion constructors should not be explicit unless there's a strong reason for it (in the opinion of, for example, https://google.github.io/styleguide/cppguide.html, and https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Ro-conversion. Let me know your take on this). - This particular conversion is very costly -- it implies a serialization plus hash of the transaction. - Even though `CTransaction` and `CMutableTransaction` represent the same data, they have very different use cases and performance properties. - Making it explicit allows for easier reasoning of performance trade-offs. - There has been previous performance issues caused by unneeded use of this implicit conversion. - This PR creates a map for places to look for possible refactoring and performance gains (this benefit still holds if the PR is not merged). Tree-SHA512: de8073aa6ff8a3153bcbe10818616677ecf9598e4978d8a0b4c39a262e71c36be5679cec08554c760d1f011ba6d37350318248eef15f6d9b86f9e4462b2de0d2
This PR was split from #14906 and is a prerequisite for it.
It updates tests and benchmarks, removing all implicit calls to
CTransaction(CMutableTransaction&)
constructors. This will make possible making the constructor explicit in the next PR.The original rationale for making the constructor explicit:
CTransaction
andCMutableTransaction
represent the same data, they have very different use cases and performance properties.