From f4735fd15a5f229450d3b462175efac0f4eea3ec Mon Sep 17 00:00:00 2001 From: Gary Rong Date: Thu, 16 Oct 2025 11:37:19 +0800 Subject: [PATCH] core: update --- core/blockchain_stats.go | 6 ++++-- core/state/reader.go | 46 ++-------------------------------------- 2 files changed, 6 insertions(+), 46 deletions(-) diff --git a/core/blockchain_stats.go b/core/blockchain_stats.go index 628ebc266e..368154067f 100644 --- a/core/blockchain_stats.go +++ b/core/blockchain_stats.go @@ -119,7 +119,6 @@ DB commit: %v Block write: %v Total: %v -%s %s ############################## `, block.Number(), block.Hash(), len(block.Transactions()), s.MgasPerSecond, @@ -128,8 +127,11 @@ Total: %v common.PrettyDuration(s.StorageReads), s.StorageLoaded, common.PrettyDuration(s.AccountHashes+s.AccountCommits+s.AccountUpdates+s.StorageCommits+s.StorageUpdates), common.PrettyDuration(s.TrieDBCommit+s.SnapshotCommit), common.PrettyDuration(s.BlockWrite), - common.PrettyDuration(s.TotalTime), s.StateReadCacheStats, s.StatePrefetchCacheStats) + common.PrettyDuration(s.TotalTime), s.StateReadCacheStats) for _, line := range strings.Split(msg, "\n") { + if line == "" { + continue + } log.Info(line) } } diff --git a/core/state/reader.go b/core/state/reader.go index e672f74b5c..2f67628039 100644 --- a/core/state/reader.go +++ b/core/state/reader.go @@ -92,12 +92,6 @@ type ReaderStats struct { AccountCacheMiss int64 StorageCacheHit int64 StorageCacheMiss int64 - - // Disk stats - AccountDiskHit int64 - AccountDiskMiss int64 - StorageDiskHit int64 - StorageDiskMiss int64 } // String implements fmt.Stringer, returning string format statistics. @@ -105,26 +99,16 @@ func (s ReaderStats) String() string { var ( accountCacheHitRate float64 storageCacheHitRate float64 - accountDiskHitRate float64 - storageDiskHitRate float64 ) if s.AccountCacheHit > 0 { accountCacheHitRate = float64(s.AccountCacheHit) / float64(s.AccountCacheHit+s.AccountCacheMiss) * 100 } - if s.AccountDiskHit > 0 { - accountDiskHitRate = float64(s.AccountDiskHit) / float64(s.AccountDiskHit+s.AccountDiskMiss) * 100 - } if s.StorageCacheHit > 0 { storageCacheHitRate = float64(s.StorageCacheHit) / float64(s.StorageCacheHit+s.StorageCacheMiss) * 100 } - if s.StorageDiskHit > 0 { - storageDiskHitRate = float64(s.StorageDiskHit) / float64(s.StorageDiskHit+s.StorageDiskMiss) * 100 - } msg := fmt.Sprintf("Reader statistics\n") - msg += fmt.Sprintf("account: cache (hit: %d, miss: %d, rate: %.2f)\n", s.AccountCacheHit, s.AccountCacheMiss, accountCacheHitRate) - msg += fmt.Sprintf("account: disk (hit: %d, miss: %d, rate: %.2f)\n", s.AccountDiskHit, s.AccountDiskMiss, accountDiskHitRate) - msg += fmt.Sprintf("storage: cache (hit: %d, miss: %d, rate: %.2f)\n", s.StorageCacheHit, s.StorageCacheMiss, storageCacheHitRate) - msg += fmt.Sprintf("storage: disk (hit: %d, miss: %d, rate: %.2f)\n", s.StorageDiskHit, s.StorageDiskMiss, storageDiskHitRate) + msg += fmt.Sprintf("account: hit: %d, miss: %d, rate: %.2f\n", s.AccountCacheHit, s.AccountCacheMiss, accountCacheHitRate) + msg += fmt.Sprintf("storage: hit: %d, miss: %d, rate: %.2f\n", s.StorageCacheHit, s.StorageCacheMiss, storageCacheHitRate) return msg } @@ -564,11 +548,6 @@ type readerWithCacheStats struct { accountCacheMiss atomic.Int64 storageCacheHit atomic.Int64 storageCacheMiss atomic.Int64 - - accountDiskHit atomic.Int64 - accountDiskMiss atomic.Int64 - storageDiskHit atomic.Int64 - storageDiskMiss atomic.Int64 } // newReaderWithCacheStats constructs the reader with additional statistics tracked. @@ -591,14 +570,6 @@ func (r *readerWithCacheStats) Account(addr common.Address) (*types.StateAccount r.accountCacheHit.Add(1) } else { r.accountCacheMiss.Add(1) - - // If the account was read from the underlying storage, count - // the presence statistics. - if account == nil { - r.accountDiskMiss.Add(1) - } else { - r.accountDiskHit.Add(1) - } } return account, nil } @@ -617,14 +588,6 @@ func (r *readerWithCacheStats) Storage(addr common.Address, slot common.Hash) (c r.storageCacheHit.Add(1) } else { r.storageCacheMiss.Add(1) - - // If the slot was read from the underlying storage, count - // the presence statistics. - if value == (common.Hash{}) { - r.storageDiskMiss.Add(1) - } else { - r.storageDiskHit.Add(1) - } } return value, nil } @@ -636,10 +599,5 @@ func (r *readerWithCacheStats) GetStats() ReaderStats { AccountCacheMiss: r.accountCacheMiss.Load(), StorageCacheHit: r.storageCacheHit.Load(), StorageCacheMiss: r.storageCacheMiss.Load(), - - AccountDiskHit: r.accountDiskHit.Load(), - AccountDiskMiss: r.accountDiskMiss.Load(), - StorageDiskHit: r.storageDiskHit.Load(), - StorageDiskMiss: r.storageDiskMiss.Load(), } }