mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 06:36:43 +00:00
core/state: add snapshot cache stats
Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
parent
29a87e4426
commit
8615149a4d
1 changed files with 19 additions and 0 deletions
|
|
@ -23,6 +23,7 @@ import (
|
|||
"fmt"
|
||||
"sync"
|
||||
|
||||
"github.com/VictoriaMetrics/fastcache"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/rawdb"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
|
|
@ -77,6 +78,14 @@ var (
|
|||
snapshotBloomStorageFalseHitMeter = metrics.NewRegisteredMeter("state/snapshot/bloom/storage/falsehit", nil)
|
||||
snapshotBloomStorageMissMeter = metrics.NewRegisteredMeter("state/snapshot/bloom/storage/miss", nil)
|
||||
|
||||
snapshotCacheGetGauge = metrics.NewRegisteredGauge("state/snapshot/cache/get", nil)
|
||||
snapshotCacheSetGauge = metrics.NewRegisteredGauge("state/snapshot/cache/set", nil)
|
||||
snapshotCacheMissGauge = metrics.NewRegisteredGauge("state/snapshot/cache/miss", nil)
|
||||
snapshotCacheSizeGauge = metrics.NewRegisteredGauge("state/snapshot/cache/size", nil)
|
||||
snapshotCacheCapacityGauge = metrics.NewRegisteredGauge("state/snapshot/cache/capacity", nil)
|
||||
snapshotCacheCollisionGauge = metrics.NewRegisteredGauge("state/snapshot/cache/collision", nil)
|
||||
snapshotCacheEntriesGauge = metrics.NewRegisteredGauge("state/snapshot/cache/entries", nil)
|
||||
|
||||
// ErrSnapshotStale is returned from data accessors if the underlying snapshot
|
||||
// layer had been invalidated due to the chain progressing forward far enough
|
||||
// to not maintain the layer's original state.
|
||||
|
|
@ -388,7 +397,17 @@ func (t *Tree) Cap(root common.Hash, layers int) error {
|
|||
|
||||
// Run the internal capping and discard all stale layers
|
||||
t.lock.Lock()
|
||||
|
||||
defer t.lock.Unlock()
|
||||
var stats fastcache.Stats
|
||||
diff.origin.cache.UpdateStats(&stats)
|
||||
snapshotCacheGetGauge.Update(int64(stats.GetCalls))
|
||||
snapshotCacheSetGauge.Update(int64(stats.SetCalls))
|
||||
snapshotCacheMissGauge.Update(int64(stats.Misses))
|
||||
snapshotCacheSizeGauge.Update(int64(stats.BytesSize))
|
||||
snapshotCacheCapacityGauge.Update(int64(stats.MaxBytesSize))
|
||||
snapshotCacheEntriesGauge.Update(int64(stats.EntriesCount))
|
||||
snapshotCacheCollisionGauge.Update(int64(stats.Collisions))
|
||||
|
||||
// Flattening the bottom-most diff layer requires special casing since there's
|
||||
// no child to rewire to the grandparent. In that case we can fake a temporary
|
||||
|
|
|
|||
Loading…
Reference in a new issue