refactor: sampling optimalizations - #5167
Closed
nugaon wants to merge 11 commits into
Closed
Conversation
This reverts commit 8c62607.
martinconic
reviewed
Jul 26, 2025
| }() | ||
|
|
||
| sampleItems := make([]SampleItem, 0, SampleSize) | ||
| sampleItems := make([]SampleItem, 0, SampleSize+1) |
Member
Author
There was a problem hiding this comment.
lower there is a condition when if len(sampleItems) > SampleSize it cuts from the end. so sampleItems used length is SampleSize+1.
martinconic
reviewed
Sep 10, 2025
|
|
||
| // NewPrefixHasher returns new hasher which is Keccak-256 hasher | ||
| // with prefix value added as initial data. | ||
| func NewPrefixHasher(prefix []byte) hash.Hash { |
Contributor
There was a problem hiding this comment.
This also called in proof.go. Do we want that one to use the stateful hasher?
Member
Author
There was a problem hiding this comment.
yeah, it is used in the sample creation as well and both should do the same calculation.
| } | ||
|
|
||
| // NewHasher returns new Keccak-256 hasher. | ||
| func NewStatefulHasher(state []byte) (sha3.StatefulHash, error) { |
Contributor
There was a problem hiding this comment.
Should new tests be added in hasher_test for this new stateful hasher?
martinconic
approved these changes
Sep 12, 2025
Contributor
|
closing this as we are cleaning up the open pull requests, and other changes are inbound for this topic. if there are any improvements here, we will implement them in subsequent PRs. |
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.
This PR optimizes the
ReserveSamplefunction to improve performance during sampling operations. The key optimizations include addingChunkTypeto theSampleItemstruct to avoid redundant parsing, reusing hashers in worker goroutines instead of creating new ones for each SOC chunk and using new optimized hasher function for transformed address calculations. These changes reduce memory allocations, GC pressure, and CPU usage without altering the functional behavior of the sampling process.Checklist
Description
Open API Spec Version Changes (if applicable)
Motivation and Context (Optional)
Related Issue (Optional)
Screenshots (if appropriate):