-
Notifications
You must be signed in to change notification settings - Fork 295
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
primitives: Add core merkle tree root calcs. #2826
Merged
Merged
Conversation
This file contains 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
davecgh
changed the title
primitives: Add merkle root benchmarks.
primitives: Add core merkle tree root calcs.
Nov 20, 2021
19 tasks
davecgh
commented
Nov 20, 2021
davecgh
force-pushed
the
primitives_merkle
branch
from
November 20, 2021 22:16
7eff3ba
to
4918b82
Compare
rstaudt2
approved these changes
Nov 23, 2021
dnldd
approved these changes
Nov 24, 2021
JoeGruffins
approved these changes
Nov 25, 2021
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.
benchmarks
goos: linux
goarch: amd64
pkg: github.com/decred/dcrd/internal/staging/primitives
cpu: AMD Ryzen 9 3900XT 12-Core Processor
BenchmarkCalcMerkleRootInPlace/20_leaves-24 140908 9020 ns/op 0 B/op 0 allocs/op
BenchmarkCalcMerkleRootInPlace/1000_leaves-24 2755 409990 ns/op 0 B/op 0 allocs/op
BenchmarkCalcMerkleRootInPlace/2000_leaves-24 1438 869987 ns/op 0 B/op 0 allocs/op
BenchmarkCalcMerkleRootInPlace/4000_leaves-24 741 1642815 ns/op 0 B/op 0 allocs/op
BenchmarkCalcMerkleRootInPlace/8000_leaves-24 338 3413965 ns/op 0 B/op 0 allocs/op
BenchmarkCalcMerkleRootInPlace/16000_leaves-24 177 6479413 ns/op 0 B/op 0 allocs/op
BenchmarkCalcMerkleRootInPlace/32000_leaves-24 91 13891543 ns/op 0 B/op 0 allocs/op
BenchmarkCalcMerkleRoot/20_leaves-24 94971 15375 ns/op 640 B/op 1 allocs/op
BenchmarkCalcMerkleRoot/1000_leaves-24 1644 718782 ns/op 32768 B/op 1 allocs/op
BenchmarkCalcMerkleRoot/2000_leaves-24 776 1392608 ns/op 65538 B/op 1 allocs/op
BenchmarkCalcMerkleRoot/4000_leaves-24 410 2634010 ns/op 131072 B/op 1 allocs/op
BenchmarkCalcMerkleRoot/8000_leaves-24 261 5422578 ns/op 262144 B/op 1 allocs/op
BenchmarkCalcMerkleRoot/16000_leaves-24 120 9022608 ns/op 516096 B/op 1 allocs/op
BenchmarkCalcMerkleRoot/32000_leaves-24 62 17837654 ns/op 1024004 B/op 1 allocs/op
davecgh
force-pushed
the
primitives_merkle
branch
from
December 4, 2021 19:12
4918b82
to
9833473
Compare
This implements functions to calculate a Merkle tree root for a given set of leaves along with associated tests. The functions are direct ports of the functions of the same names from blockchain/standalone. Note that this does not include the other functions in blockchain/standalone related to merkle root calculations from transaction trees since the primitives package does not yet implement a transaction type. Those will be implemented later after a transaction type is introduced.
BenchmarkCalcMerkleRootInPlace ------------------------------ 20_leaves 95551 12436 ns/op 0 B/op 0 allocs/op 1000_leaves 2047 591660 ns/op 0 B/op 0 allocs/op 2000_leaves 1018 1179846 ns/op 0 B/op 0 allocs/op 4000_leaves 507 2357246 ns/op 0 B/op 0 allocs/op 8000_leaves 254 4710341 ns/op 0 B/op 0 allocs/op 16000_leaves 127 9499098 ns/op 0 B/op 0 allocs/op 32000_leaves 62 18876558 ns/op 0 B/op 0 allocs/op BenchmarkCalcMerkleRoot ----------------------- 20_leaves 92455 12840 ns/op 640 B/op 1 allocs/op 1000_leaves 1965 608127 ns/op 32769 B/op 1 allocs/op 2000_leaves 969 1261865 ns/op 65536 B/op 1 allocs/op 4000_leaves 493 2439323 ns/op 131073 B/op 1 allocs/op 8000_leaves 246 4850361 ns/op 262144 B/op 1 allocs/op 16000_leaves 122 9826700 ns/op 516101 B/op 1 allocs/op 32000_leaves 63 19420881 ns/op 1024008 B/op 1 allocs/op
davecgh
force-pushed
the
primitives_merkle
branch
from
December 4, 2021 21:55
9833473
to
a4526b4
Compare
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.
This requires #2788.This implements functions to calculate a Merkle tree root for a given set of leaves along with associated tests.
The functions are direct ports of the functions of the same names from
blockchain/standalone
.Specifically, the following functions are updated and added along with their associated tests and benchmarks:
CalcMerkleRootInPlace
(equiv tostandalone.CalcMerkleRootInPlace
)CalcMerkleRoot
(equiv tostandalone.CalcMerkleRoot
)Note that this does not include the other functions in blockchain/standalone related to merkle root calculations from transaction trees since the primitives package does not yet implement a transaction type. Those will be implemented later after a type is introduced.
This is work towards #2786.