mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 14:46:42 +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"
|
"fmt"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"github.com/VictoriaMetrics/fastcache"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/core/rawdb"
|
"github.com/ethereum/go-ethereum/core/rawdb"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
|
|
@ -77,6 +78,14 @@ var (
|
||||||
snapshotBloomStorageFalseHitMeter = metrics.NewRegisteredMeter("state/snapshot/bloom/storage/falsehit", nil)
|
snapshotBloomStorageFalseHitMeter = metrics.NewRegisteredMeter("state/snapshot/bloom/storage/falsehit", nil)
|
||||||
snapshotBloomStorageMissMeter = metrics.NewRegisteredMeter("state/snapshot/bloom/storage/miss", 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
|
// ErrSnapshotStale is returned from data accessors if the underlying snapshot
|
||||||
// layer had been invalidated due to the chain progressing forward far enough
|
// layer had been invalidated due to the chain progressing forward far enough
|
||||||
// to not maintain the layer's original state.
|
// 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
|
// Run the internal capping and discard all stale layers
|
||||||
t.lock.Lock()
|
t.lock.Lock()
|
||||||
|
|
||||||
defer t.lock.Unlock()
|
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
|
// 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
|
// no child to rewire to the grandparent. In that case we can fake a temporary
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue