tridb/pathdb: add fastcache metrics

Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
jsvisa 2025-04-09 11:16:26 +00:00
parent 8615149a4d
commit 121e36130d
2 changed files with 18 additions and 0 deletions

View file

@ -306,6 +306,16 @@ func (dl *diskLayer) update(root common.Hash, id uint64, block uint64, nodes *no
// and returns a newly constructed disk layer. Note the current disk // and returns a newly constructed disk layer. Note the current disk
// layer must be tagged as stale first to prevent re-access. // layer must be tagged as stale first to prevent re-access.
func (dl *diskLayer) commit(bottom *diffLayer, force bool) (*diskLayer, error) { func (dl *diskLayer) commit(bottom *diffLayer, force bool) (*diskLayer, error) {
var stats fastcache.Stats
dl.nodes.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))
dl.lock.Lock() dl.lock.Lock()
defer dl.lock.Unlock() defer dl.lock.Unlock()

View file

@ -72,6 +72,14 @@ var (
historyBuildTimeMeter = metrics.NewRegisteredResettingTimer("pathdb/history/time", nil) historyBuildTimeMeter = metrics.NewRegisteredResettingTimer("pathdb/history/time", nil)
historyDataBytesMeter = metrics.NewRegisteredMeter("pathdb/history/bytes/data", nil) historyDataBytesMeter = metrics.NewRegisteredMeter("pathdb/history/bytes/data", nil)
historyIndexBytesMeter = metrics.NewRegisteredMeter("pathdb/history/bytes/index", nil) historyIndexBytesMeter = metrics.NewRegisteredMeter("pathdb/history/bytes/index", nil)
snapshotCacheGetGauge = metrics.NewRegisteredGauge("pathdb/snapshot/cache/get", nil)
snapshotCacheSetGauge = metrics.NewRegisteredGauge("pathdb/snapshot/cache/set", nil)
snapshotCacheMissGauge = metrics.NewRegisteredGauge("pathdb/snapshot/cache/miss", nil)
snapshotCacheSizeGauge = metrics.NewRegisteredGauge("pathdb/snapshot/cache/size", nil)
snapshotCacheCapacityGauge = metrics.NewRegisteredGauge("pathdb/snapshot/cache/capacity", nil)
snapshotCacheCollisionGauge = metrics.NewRegisteredGauge("pathdb/snapshot/cache/collision", nil)
snapshotCacheEntriesGauge = metrics.NewRegisteredGauge("pathdb/snapshot/cache/entries", nil)
) )
// Metrics in generation // Metrics in generation