mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 14:16:44 +00:00
core/state: update stats before lock
Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
parent
121e36130d
commit
3bd5c37c3b
1 changed files with 12 additions and 10 deletions
|
|
@ -388,17 +388,8 @@ func (t *Tree) Cap(root common.Hash, layers int) error {
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("snapshot [%#x] is disk layer", root)
|
return fmt.Errorf("snapshot [%#x] is disk layer", root)
|
||||||
}
|
}
|
||||||
// If the generator is still running, use a more aggressive cap
|
|
||||||
diff.origin.lock.RLock()
|
|
||||||
if diff.origin.genMarker != nil && layers > 8 {
|
|
||||||
layers = 8
|
|
||||||
}
|
|
||||||
diff.origin.lock.RUnlock()
|
|
||||||
|
|
||||||
// Run the internal capping and discard all stale layers
|
// Update the cache stats
|
||||||
t.lock.Lock()
|
|
||||||
|
|
||||||
defer t.lock.Unlock()
|
|
||||||
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))
|
||||||
|
|
@ -409,6 +400,17 @@ func (t *Tree) Cap(root common.Hash, layers int) error {
|
||||||
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
|
||||||
|
diff.origin.lock.RLock()
|
||||||
|
if diff.origin.genMarker != nil && layers > 8 {
|
||||||
|
layers = 8
|
||||||
|
}
|
||||||
|
diff.origin.lock.RUnlock()
|
||||||
|
|
||||||
|
// Run the internal capping and discard all stale layers
|
||||||
|
t.lock.Lock()
|
||||||
|
defer t.lock.Unlock()
|
||||||
|
|
||||||
// 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
|
||||||
// child for the capping and then remove it.
|
// child for the capping and then remove it.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue