Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
jsvisa 2025-05-23 12:30:50 +08:00
parent d18eddad72
commit fd2dd39f70
2 changed files with 22 additions and 18 deletions

View file

@ -390,15 +390,17 @@ func (t *Tree) Cap(root common.Hash, layers int) error {
}
// Update the cache stats
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))
if diff.origin != nil && diff.origin.cache != nil {
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))
}
// If the generator is still running, use a more aggressive cap
diff.origin.lock.RLock()

View file

@ -306,15 +306,17 @@ func (dl *diskLayer) update(root common.Hash, id uint64, block uint64, nodes *no
// and returns a newly constructed disk layer. Note the current disk
// layer must be tagged as stale first to prevent re-access.
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))
if dl.nodes != nil {
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()
defer dl.lock.Unlock()