Skip to content

Conversation

@DeVil2O
Copy link
Contributor

@DeVil2O DeVil2O commented Sep 28, 2023

This PR fixes the bug for Trie Benchmarks Break invariant of trie. In the existing code, a key-value pair is constructed for use in the trie. However, the same key byte slice is reused for multiple update operations within a loop.

Bug: #28214

k := make([]byte, 32)
b.ReportAllocs()
for i := 0; i < b.N; i++ {
k := make([]byte, 32)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we don't have to allocate the key though, the trie needs to copy it anyway afaik.

@holiman holiman changed the title trie/trie_test: Fix Trie Benchmark Bug: Ensure Key Immutability in geth Benchmarks trie: fix benchmark by ensuring key immutability Oct 2, 2023
Copy link
Contributor

@holiman holiman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@holiman holiman added this to the 1.13.3 milestone Oct 2, 2023
@holiman holiman merged commit 2091ebd into ethereum:master Oct 3, 2023
hyunchel pushed a commit to hyunchel/go-ethereum that referenced this pull request Oct 6, 2023
This change fixes the bug in a benchmark, where the input to the trie is reused in a way which is not correct. 

---------

Co-authored-by: Martin Holst Swende <[email protected]>
ghost pushed a commit to blocknative/go-ethereum that referenced this pull request Oct 12, 2023
This change fixes the bug in a benchmark, where the input to the trie is reused in a way which is not correct. 

---------

Co-authored-by: Martin Holst Swende <[email protected]>
ghost pushed a commit to blocknative/go-ethereum that referenced this pull request Oct 16, 2023
This change fixes the bug in a benchmark, where the input to the trie is reused in a way which is not correct. 

---------

Co-authored-by: Martin Holst Swende <[email protected]>
devopsbo3 pushed a commit to HorizenOfficial/go-ethereum that referenced this pull request Nov 10, 2023
This change fixes the bug in a benchmark, where the input to the trie is reused in a way which is not correct. 

---------

Co-authored-by: Martin Holst Swende <[email protected]>
devopsbo3 added a commit to HorizenOfficial/go-ethereum that referenced this pull request Nov 10, 2023
devopsbo3 added a commit to HorizenOfficial/go-ethereum that referenced this pull request Nov 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants