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 // Update the cache stats
var stats fastcache.Stats if diff.origin != nil && diff.origin.cache != nil {
diff.origin.cache.UpdateStats(&stats) var stats fastcache.Stats
snapshotCacheGetGauge.Update(int64(stats.GetCalls)) diff.origin.cache.UpdateStats(&stats)
snapshotCacheSetGauge.Update(int64(stats.SetCalls)) snapshotCacheGetGauge.Update(int64(stats.GetCalls))
snapshotCacheMissGauge.Update(int64(stats.Misses)) snapshotCacheSetGauge.Update(int64(stats.SetCalls))
snapshotCacheSizeGauge.Update(int64(stats.BytesSize)) snapshotCacheMissGauge.Update(int64(stats.Misses))
snapshotCacheCapacityGauge.Update(int64(stats.MaxBytesSize)) snapshotCacheSizeGauge.Update(int64(stats.BytesSize))
snapshotCacheEntriesGauge.Update(int64(stats.EntriesCount)) snapshotCacheCapacityGauge.Update(int64(stats.MaxBytesSize))
snapshotCacheCollisionGauge.Update(int64(stats.Collisions)) snapshotCacheEntriesGauge.Update(int64(stats.EntriesCount))
snapshotCacheCollisionGauge.Update(int64(stats.Collisions))
}
// If the generator is still running, use a more aggressive cap // If the generator is still running, use a more aggressive cap
diff.origin.lock.RLock() 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 // 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 if dl.nodes != nil {
dl.nodes.UpdateStats(&stats) var stats fastcache.Stats
snapshotCacheGetGauge.Update(int64(stats.GetCalls)) dl.nodes.UpdateStats(&stats)
snapshotCacheSetGauge.Update(int64(stats.SetCalls)) snapshotCacheGetGauge.Update(int64(stats.GetCalls))
snapshotCacheMissGauge.Update(int64(stats.Misses)) snapshotCacheSetGauge.Update(int64(stats.SetCalls))
snapshotCacheSizeGauge.Update(int64(stats.BytesSize)) snapshotCacheMissGauge.Update(int64(stats.Misses))
snapshotCacheCapacityGauge.Update(int64(stats.MaxBytesSize)) snapshotCacheSizeGauge.Update(int64(stats.BytesSize))
snapshotCacheEntriesGauge.Update(int64(stats.EntriesCount)) snapshotCacheCapacityGauge.Update(int64(stats.MaxBytesSize))
snapshotCacheCollisionGauge.Update(int64(stats.Collisions)) snapshotCacheEntriesGauge.Update(int64(stats.EntriesCount))
snapshotCacheCollisionGauge.Update(int64(stats.Collisions))
}
dl.lock.Lock() dl.lock.Lock()
defer dl.lock.Unlock() defer dl.lock.Unlock()