txscript: Reduce checkmultisig allocs.#2890
Merged
davecgh merged 1 commit intodecred:masterfrom Mar 17, 2022
Merged
Conversation
40583b0 to
67c54d3
Compare
dajohi
approved these changes
Mar 5, 2022
67c54d3 to
2b97fc8
Compare
rstaudt2
reviewed
Mar 11, 2022
2b97fc8 to
d18fe80
Compare
rstaudt2
approved these changes
Mar 11, 2022
JoeGruffins
approved these changes
Mar 17, 2022
| var pubKeys [][]byte | ||
| if numPubKeys <= numPubKeysHint { | ||
| var pubKeysArr [numPubKeysHint][]byte | ||
| pubKeys = pubKeysArr[0:0:numPubKeys] |
Member
There was a problem hiding this comment.
I had forgotten this syntax to set the capacity from an existing array. Just confirming: https://go.dev/play/p/rW_AkOcMhSg
Profiling allocations during an initial chain sync shows that a large portion of the allocations due to the CHECKMULTISIG opcode are the result of generating the list of public keys and signatures. This eliminates those allocations as follows: - Use slices into fixed-size stack-based backing arrays for the typical number of public keys and signatures - Make the slice of signature info contiguous instead of pointers which not only eliminates the associated allocations, but also provides better cache locality
d18fe80 to
bf841fe
Compare
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Profiling allocations during an initial chain sync shows that a large portion of the allocations due to the CHECKMULTISIG opcode are the result of generating the list of public keys and signatures.
This eliminates those allocations as follows: