Prevent copying of in/outputs for SignSignature#13202
Closed
martinus wants to merge 1 commit intobitcoin:masterfrom
Closed
Prevent copying of in/outputs for SignSignature#13202martinus wants to merge 1 commit intobitcoin:masterfrom
martinus wants to merge 1 commit intobitcoin:masterfrom
Conversation
Instead of copying data from a CMutableTransaction into a CTransaction, the data is temporarily moved and then moved back after it's use. This speeds up the slowest unit test transaction_tests/test_big_witness_transaction. 24.351 sec for all unit tests before 21.187 sec for all unit tests after this change The change is somewhat ugly since a const_cast is necessary.
Member
|
I believe this is illegal C++. You cannot modify const variables unless you know other non-const references to those variables exist as well. That isn't the case for A better way to speed things up would be to create a |
Contributor
Author
|
That sounds much better than the ugly cast, I'll have a look at that |
laanwj
added a commit
that referenced
this pull request
May 31, 2018
6b8b63a Generic TransactionSignatureCreator works with both CTransaction and CMutableTransaction (Martin Ankerl) Pull request description: Refactored `TransactionSignatureCreator` into a templated `GenericTransactionSignatureCreator` that works with both `CMutableTransaction` and `CTransaction`. The advantage is that now in `SignSignature`, the `MutableTransactionSignatureCreator` can now operate directly with the `CMutableTransaction` without the need to copy the data into a `CTransaction`. Running all unit tests brings a very noticable speedup on my machine: 48.4 sec before this change 36.4 sec with this change -------- 12.0 seconds saved running only `--run_test=transaction_tests/test_big_witness_transaction`: 16.7 sec before this change 5.9 sec with this change -------- 10.8 seconds saved This relates to my first attempt with the const_cast hack #13202, and to the slow unit test issue #10026. Also see #13050 which modifies the tests but not the production code (like this PR) to get a speedup. Tree-SHA512: 2cff0e9699f484f26120a40e431a24c8bc8f9e780fd89cb0ecf20c5be3eab6c43f9c359cde244abd9f3620d06c7c354e3b9dd3da41fa2ca1ac1e09386fea25fb
UdjinM6
pushed a commit
to UdjinM6/dash
that referenced
this pull request
Jun 28, 2021
…nSignature 6b8b63a Generic TransactionSignatureCreator works with both CTransaction and CMutableTransaction (Martin Ankerl) Pull request description: Refactored `TransactionSignatureCreator` into a templated `GenericTransactionSignatureCreator` that works with both `CMutableTransaction` and `CTransaction`. The advantage is that now in `SignSignature`, the `MutableTransactionSignatureCreator` can now operate directly with the `CMutableTransaction` without the need to copy the data into a `CTransaction`. Running all unit tests brings a very noticable speedup on my machine: 48.4 sec before this change 36.4 sec with this change -------- 12.0 seconds saved running only `--run_test=transaction_tests/test_big_witness_transaction`: 16.7 sec before this change 5.9 sec with this change -------- 10.8 seconds saved This relates to my first attempt with the const_cast hack bitcoin#13202, and to the slow unit test issue bitcoin#10026. Also see bitcoin#13050 which modifies the tests but not the production code (like this PR) to get a speedup. Tree-SHA512: 2cff0e9699f484f26120a40e431a24c8bc8f9e780fd89cb0ecf20c5be3eab6c43f9c359cde244abd9f3620d06c7c354e3b9dd3da41fa2ca1ac1e09386fea25fb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Instead of copying data from a
CMutableTransactioninto aCTransaction,the data is temporarily moved and then moved back after it's use. This speeds up
the slowest unit test
transaction_tests/test_big_witness_transaction:24.351 sec for all unit tests before
21.187 sec for all unit tests after this change
The change is somewhat ugly since a
const_castis necessary.Relates to #10026. It should also speed up any use of
SignSignature, especially for machines where allocating memory is slow.