Skip to content

Commit

Permalink
improve lock performance in used() method
Browse files Browse the repository at this point in the history
  • Loading branch information
andyzhang2023 committed Feb 21, 2024
1 parent 7bb7d16 commit df32a97
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions core/state/trie_prefetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,9 @@ func (p *triePrefetcher) trie(owner common.Hash, root common.Hash) Trie {
// used marks a batch of state items used to allow creating statistics as to
// how useful or wasteful the prefetcher is.
func (p *triePrefetcher) used(owner common.Hash, root common.Hash, used [][]byte) {
p.fetchersLock.Lock()
// keep lock until all data updated, make sure no concurrent read/write occurs
defer p.fetchersLock.Unlock()
p.fetchersLock.RLock()
fetcher := p.fetchers[p.trieID(owner, root)]
p.fetchersLock.RUnlock()
if fetcher != nil {
fetcher.used = used
}
Expand Down

0 comments on commit df32a97

Please sign in to comment.