-
Notifications
You must be signed in to change notification settings - Fork 20.1k
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
core/state/snapshot: use AddHash/ContainHash instead of Hasher interface #28849
Conversation
Reduces the allocations quite significantly, before: 26666581 26666581 243: dl.diffed.Add(storageBloomHasher{accountHash, storageHash})
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.
LGTM (with minor nit)
core/state/pruner/bloom.go
Outdated
func (f stateBloomHasher) BlockSize() int { panic("not implemented") } | ||
func (f stateBloomHasher) Size() int { return 8 } | ||
func (f stateBloomHasher) Sum64() uint64 { return binary.BigEndian.Uint64(f) } | ||
// stateBloomHasher is used to convert a trie hash or contract code hash into a 64 bit mini hash. |
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.
Now that these no longer are types (objects), but rather functions (verbs), perhaps they should be renamed from stateBloomHasher
into stateBloomHash
?
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.
fixed
…ace (ethereum#28849) This change switches from using the `Hasher` interface to add/query the bloomfilter to implementing it as methods. This significantly reduces the allocations for Search and Rebloom.
This PR switches from using the Hasher interface to add/query the bloomfilter to implementing it as methods.
This significantly reduces the allocations for Search and Rebloom.
The allocations for the storageBloom alone was ~7% of all allocations (in a quite contrived scenario)
26666581 26666581 243: dl.diffed.Add(storageBloomHasher{accountHash, storageHash})
14812039 14812039 375: hit := dl.diffed.Contains(storageBloomHasher{accountHash, storageHash})
14828423 14849723 (flat, cum) 2.50% of Total
26666581 26672121 (flat, cum) 4.49% of Total
The added benefit of reduced allocations also surfaces in the benchmark: