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,6 +390,7 @@ func (t *Tree) Cap(root common.Hash, layers int) error {
} }
// Update the cache stats // Update the cache stats
if diff.origin != nil && diff.origin.cache != nil {
var stats fastcache.Stats var stats fastcache.Stats
diff.origin.cache.UpdateStats(&stats) diff.origin.cache.UpdateStats(&stats)
snapshotCacheGetGauge.Update(int64(stats.GetCalls)) snapshotCacheGetGauge.Update(int64(stats.GetCalls))
@ -399,6 +400,7 @@ func (t *Tree) Cap(root common.Hash, layers int) error {
snapshotCacheCapacityGauge.Update(int64(stats.MaxBytesSize)) snapshotCacheCapacityGauge.Update(int64(stats.MaxBytesSize))
snapshotCacheEntriesGauge.Update(int64(stats.EntriesCount)) snapshotCacheEntriesGauge.Update(int64(stats.EntriesCount))
snapshotCacheCollisionGauge.Update(int64(stats.Collisions)) 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,6 +306,7 @@ 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) {
if dl.nodes != nil {
var stats fastcache.Stats var stats fastcache.Stats
dl.nodes.UpdateStats(&stats) dl.nodes.UpdateStats(&stats)
snapshotCacheGetGauge.Update(int64(stats.GetCalls)) snapshotCacheGetGauge.Update(int64(stats.GetCalls))
@ -315,6 +316,7 @@ func (dl *diskLayer) commit(bottom *diffLayer, force bool) (*diskLayer, error) {
snapshotCacheCapacityGauge.Update(int64(stats.MaxBytesSize)) snapshotCacheCapacityGauge.Update(int64(stats.MaxBytesSize))
snapshotCacheEntriesGauge.Update(int64(stats.EntriesCount)) snapshotCacheEntriesGauge.Update(int64(stats.EntriesCount))
snapshotCacheCollisionGauge.Update(int64(stats.Collisions)) snapshotCacheCollisionGauge.Update(int64(stats.Collisions))
}
dl.lock.Lock() dl.lock.Lock()
defer dl.lock.Unlock() defer dl.lock.Unlock()