-
Notifications
You must be signed in to change notification settings - Fork 38.7k
refactor: Make explicit CMutableTransaction -> CTransaction conversion. #14906
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
refactor: Make explicit CMutableTransaction -> CTransaction conversion. #14906
Conversation
|
The part referring to tests and benchmark changes has now a separate PR #14908 |
|
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. |
promag
left a comment
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.
Looks like you are missing a rebase.
…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
|
Rebased |
|
Strong support for making constructors explicit wherever possible. This looks like a fairly minimal change in terms of total amount of stuff touched, and definitely in a positive direction. Would love to see this get in. (Consider this a utACK from me, for what my vote is worth. I'm not sure what's up with Travis but the failure doesn't look legitimate.) (EDIT: Looks like I missed some comments / context due to the reopening as a new PR, and indeed there was already plenty of support for this to go in soon. Yay. :-) ) |
…action conversion. This commit makes the minimal changes necessary to fix compilation once CTransaction(const CMutableTransaction &tx) is made explicit. In each case an explicit call `CTransaction(...)` was added. Shouldn't affect behaviour or performance.
This makes the above constructor explicit. The rationale is that this conversion has very significant performance effects. Making it explicit makes it easier to reason about these performance trade-offs, and helps identify possible functions that need a CMutableTransaction version.
|
Rebased on latest master. Everything worked locally. Let's see how Travis behaves. |
|
utACK b301950 |
1 similar comment
|
utACK b301950 |
|
utACK b301950, agree with the rationale |
…tion conversion. b301950 Made expicit constructor CTransaction(const CMutableTransaction &tx). (lucash-dev) faf29dd Minimal changes to comply with explicit CMutableTransaction -> CTranaction conversion. (lucash-dev) Pull request description: This PR is re-submission of #14156, which was automatically closed by github (glitch?) Original description: This PR makes explicit the now implicit conversion constructor `CTransaction(const CMutableTransaction&)` in `transaction.h`. Minimal changes were made elsewhere to make the code compilable. I'll follow up with other PRs to address individually refactoring functions that should have a `CMutableTransaction` version, or where a `CTransaction` should be reused. The rationale for this change is: - 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: 2427462e7211b5ffc7299dae17339d27f8c43266e0895690fda49a83c72751bd2489d4471b3993075a18f3fef25d741243e5010b2f49aeef4a9688b30b6d0631
…n improve performance. Reference: bitcoin#14906
…saction conversion. Summary: This PR is re-submission of #14156, which was automatically closed by github (glitch?) Original description: This PR makes explicit the now implicit conversion constructor CTransaction(const CMutableTransaction&) in transaction.h. Minimal changes were made elsewhere to make the code compilable. I'll follow up with other PRs to address individually refactoring functions that should have a CMutableTransaction version, or where a CTransaction should be reused. The rationale for this change is: 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). --- Depends on D6072 This is a backport of Core [[bitcoin/bitcoin#14906 | PR14906]] Test Plan: ninja check-all Reviewers: #bitcoin_abc, nakihito Reviewed By: nakihito Subscribers: nakihito Differential Revision: https://reviews.bitcoinabc.org/D6073
merge bitcoin bitcoin#13013, bitcoin#14908, bitcoin#14906: Make explicit CMutableTransaction -> CTransaction conversion
This PR is re-submission of #14156, which was automatically closed by github (glitch?)
Original description:
This PR makes explicit the now implicit conversion constructor
CTransaction(const CMutableTransaction&)intransaction.h.Minimal changes were made elsewhere to make the code compilable. I'll follow up with other PRs to address individually refactoring functions that should have a
CMutableTransactionversion, or where aCTransactionshould be reused.The rationale for this change is:
CTransactionandCMutableTransactionrepresent the same data, they have very different use cases and performance properties.