Skip to content
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: trie-prefetcher nitpick #23198

Merged
merged 1 commit into from
Jul 12, 2021

Conversation

MariusVanDerWijden
Copy link
Member

Might reduce memory consumption a bit.
We don't need to declare a new variable here, casting to string twice might be a bit slower but less memory intensive

OUTINE ======================== github.com/ethereum/go-ethereum/core/state.(*subfetcher).loop in github.com/ethereum/go-ethereum/core/state/trie_prefetcher.go
  823.72MB    63.55GB (flat, cum) 13.25% of Total
         .          .    277:func (sf *subfetcher) loop() {
 [...]
         .   638.60MB    282:    trie, err := sf.db.OpenTrie(sf.root)
         .          .    283:    if err != nil {
         .          .    284:        log.Warn("Trie prefetcher failed opening trie", "root", 
[...]
         .          .    289:    // Trie opened successfully, keep prefetching items
         .          .    290:    for {
      10MB       10MB    291:        select {
         .          .    292:        case <-sf.wake:
  [...]
         .          .    304:                    sf.lock.Lock()
    3.06MB     3.06MB    305:                    sf.tasks = append(sf.tasks, tasks[i:]...)
         .          .    306:                    sf.lock.Unlock()
         .          .    307:                    return
         .          .    308:
         .          .    309:                case ch := <-sf.copy:
         .          .    310:                    // Somebody wants a copy of the current trie, grant them
         .          .    311:                    ch <- sf.db.CopyTrie(sf.trie)
         .          .    312:
         .          .    313:                default:
         .          .    314:                    // No termination request yet, prefetch the next entry
  308.01MB   308.01MB    315:                    taskid := string(task)
         .          .    316:                    if _, ok := sf.seen[taskid]; ok {
         .          .    317:                        sf.dups++
         .          .    318:                    } else {
         .    62.05GB    319:                        sf.trie.TryGet(task)
  502.65MB   502.65MB    320:                        sf.seen[taskid] = struct{}{}

@fjl fjl changed the title state: trie-prefetcher nitpick core/state: trie-prefetcher nitpick Jul 12, 2021
Copy link
Contributor

@fjl fjl left a comment

Choose a reason for hiding this comment

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

Doubt this will fix the memory issues, but good change nonetheless.

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.10.5 milestone Jul 12, 2021
@holiman holiman merged commit 8fe47b0 into ethereum:master Jul 12, 2021
sidhujag pushed a commit to sidhujag/go-ethereum that referenced this pull request Jul 28, 2021
atif-konasl pushed a commit to frozeman/pandora-execution-engine that referenced this pull request Oct 15, 2021
@MariusVanDerWijden MariusVanDerWijden deleted the trie-prefetch-nit branch November 30, 2021 15:26
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.

3 participants