Conversation
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.
use stackTrie when committing genesis storage trie nodes
stackTrie only traverse mpt once while trie performs one traverse to hash first and then perform one commit; therefore, trie allocs more memory in saving the direty nodes. below is the bench result
stackTrie
// BenchmarkStackTrieInsertion/Size_1000
// BenchmarkStackTrieInsertion/Size_1000-12 739 1617923 ns/op 582738 B/op 9122 allocs/op
// BenchmarkStackTrieInsertion/Size_10000
// BenchmarkStackTrieInsertion/Size_10000-12 70 16953160 ns/op 5805821 B/op 92059 allocs/op
// BenchmarkStackTrieInsertion/Size_100000
// BenchmarkStackTrieInsertion/Size_100000-12 6 177203236 ns/op 61306298 B/op 917144 allocs/op
// BenchmarkStackTrieInsertion/Size_1000000
// BenchmarkStackTrieInsertion/Size_1000000-12 1 1964037625 ns/op 582744808 B/op 9085699 allocs/op
regular trie
// BenchmarkRegularTrieInsertion/Size_1000
// BenchmarkRegularTrieInsertion/Size_1000-12 482 2429196 ns/op 2080139 B/op 27682 allocs/op
// BenchmarkRegularTrieInsertion/Size_10000
// BenchmarkRegularTrieInsertion/Size_10000-12 70 16680217 ns/op 20157853 B/op 275211 allocs/op
// BenchmarkRegularTrieInsertion/Size_100000
// BenchmarkRegularTrieInsertion/Size_100000-12 6 180554403 ns/op 207196216 B/op 2741910 allocs/op
// BenchmarkRegularTrieInsertion/Size_1000000
// BenchmarkRegularTrieInsertion/Size_1000000-12 1 2423703250 ns/op 2099059016 B/op 27041567 allocs/op
alloc: stackTrie allocs 582744808 bytes per op, while regular trie alloc 2099059016 bytes per op, which is 3.6x less
speed: stackTrie takes 1964037625 ns per op, while regular trie takes 2423703250 ns, which is 23% faster