rlp, trie: faster trie node encoding (#24126)
This change speeds up trie hashing and all other activities that require RLP encoding of trie nodes by approximately 20%. The speedup is achieved by avoiding reflection overhead during node encoding. The interface type trie.node now contains a method 'encode' that works with rlp.EncoderBuffer. Management of EncoderBuffers is left to calling code. trie.hasher, which is pooled to avoid allocations, now maintains an EncoderBuffer. This means memory resources related to trie node encoding are tied to the hasher pool. Co-authored-by: Felix Lange <fjl@twurst.com>
This commit is contained in:
@@ -44,7 +44,6 @@ type leaf struct {
|
||||
// By 'some level' of parallelism, it's still the case that all leaves will be
|
||||
// processed sequentially - onleaf will never be called in parallel or out of order.
|
||||
type committer struct {
|
||||
tmp sliceBuffer
|
||||
sha crypto.KeccakState
|
||||
|
||||
onleaf LeafCallback
|
||||
@@ -55,7 +54,6 @@ type committer struct {
|
||||
var committerPool = sync.Pool{
|
||||
New: func() interface{} {
|
||||
return &committer{
|
||||
tmp: make(sliceBuffer, 0, 550), // cap is as large as a full fullNode.
|
||||
sha: sha3.NewLegacyKeccak256().(crypto.KeccakState),
|
||||
}
|
||||
},
|
||||
|
Reference in New Issue
Block a user