From 9dc20080d595da153e48e91204285bab3d6ff8a5 Mon Sep 17 00:00:00 2001 From: Jared Wasinger Date: Wed, 20 Dec 2023 08:03:28 +0800 Subject: [PATCH] re-enable prefetcher in miner. make prefetcher schedule async notify --- core/state/trie_prefetcher.go | 5 ++++- miner/worker.go | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/core/state/trie_prefetcher.go b/core/state/trie_prefetcher.go index 21c9f1a27f..cdc03c606f 100644 --- a/core/state/trie_prefetcher.go +++ b/core/state/trie_prefetcher.go @@ -245,7 +245,10 @@ func (sf *subfetcher) schedule(keys [][]byte) { sf.tasks = append(sf.tasks, keys...) sf.lock.Unlock() // Notify the prefetcher. The wake-chan is buffered, so this is async. - sf.wake <- true + select { + case sf.wake <- true: + default: + } } // wait waits for the subfetcher to finish it's task. It is safe to call wait multiple diff --git a/miner/worker.go b/miner/worker.go index a642d46b6f..f680702814 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -125,7 +125,7 @@ func (env *environment) discard() { if env.state == nil { return } - //env.state.StopPrefetcher() + env.state.StopPrefetcher() } // task contains all information for consensus engine sealing and result submitting. @@ -711,7 +711,7 @@ func (w *worker) makeEnv(parent *types.Header, header *types.Header, coinbase co if err != nil { return nil, err } - //state.StartPrefetcher("miner") + state.StartPrefetcher("miner") // Note the passed coinbase may be different with header.Coinbase. env := &environment{