mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-08 07:58:40 +00:00
core: wait for prefetcher before reading PrefetchReadTimes
Forward prefetchStateReader.Wait() through *reader.WaitPrefetch and call it before reading the read-time atomics. Eliminates the edge-case where prefetcher goroutines outlast block execution + commit. For slow blocks (the metric's target audience) this is a no-op; for fast blocks it ensures the metric is complete rather than slightly under.
This commit is contained in:
parent
16e98f5d93
commit
cd8ce62b40
2 changed files with 11 additions and 0 deletions
|
|
@ -683,6 +683,9 @@ func (bc *BlockChain) processBlockWithAccessList(parentRoot common.Hash, block *
|
|||
|
||||
// Sum read times across per-tx execution, BAL state-transition, and
|
||||
// prefetcher async fetches. Sum-of-CPU-time, not wall-clock.
|
||||
if w, ok := prefetchReader.(interface{ WaitPrefetch() }); ok {
|
||||
w.WaitPrefetch() // ensure all prefetcher reads are accounted for
|
||||
}
|
||||
var prefetchAccountReads, prefetchStorageReads time.Duration
|
||||
if pr, ok := prefetchReader.(interface {
|
||||
PrefetchReadTimes() (time.Duration, time.Duration)
|
||||
|
|
|
|||
|
|
@ -576,3 +576,11 @@ func (r *reader) PrefetchReadTimes() (account, storage time.Duration) {
|
|||
}
|
||||
return 0, 0
|
||||
}
|
||||
|
||||
// WaitPrefetch blocks until the wrapped prefetcher (if any) finishes its
|
||||
// task list. No-op for non-prefetch readers.
|
||||
func (r *reader) WaitPrefetch() {
|
||||
if pr, ok := r.StateReader.(interface{ Wait() error }); ok {
|
||||
_ = pr.Wait()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue