Skip to content

Commit 12a1a85

Browse files
committed
core/state/snapshot: revert timers to counters to track total time
1 parent 3a54830 commit 12a1a85

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

core/state/snapshot/generate.go

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -74,22 +74,22 @@ var (
7474
snapSuccessfulRangeProofMeter = metrics.NewRegisteredMeter("state/snapshot/generation/proof/success", nil)
7575
snapFailedRangeProofMeter = metrics.NewRegisteredMeter("state/snapshot/generation/proof/failure", nil)
7676

77-
// snapAccountProveTimer measures time spent on the account proving
78-
snapAccountProveTimer = metrics.NewRegisteredTimer("state/snapshot/generation/duration/account/prove", nil)
79-
// snapAccountTrieReadTimer measures time spent on the account trie iteration
80-
snapAccountTrieReadTimer = metrics.NewRegisteredTimer("state/snapshot/generation/duration/account/trieread", nil)
81-
// snapAccountSnapReadTimer measues time spent on the snapshot account iteration
82-
snapAccountSnapReadTimer = metrics.NewRegisteredTimer("state/snapshot/generation/duration/account/snapread", nil)
83-
// snapAccountWriteTimer measures time spent on writing/updating/deleting accounts
84-
snapAccountWriteTimer = metrics.NewRegisteredTimer("state/snapshot/generation/duration/account/write", nil)
85-
// snapStorageProveTimer measures time spent on storage proving
86-
snapStorageProveTimer = metrics.NewRegisteredTimer("state/snapshot/generation/duration/storage/prove", nil)
87-
// snapStorageTrieReadTimer measures time spent on the storage trie iteration
88-
snapStorageTrieReadTimer = metrics.NewRegisteredTimer("state/snapshot/generation/duration/storage/trieread", nil)
89-
// snapStorageSnapReadTimer measures time spent on the snapshot storage iteration
90-
snapStorageSnapReadTimer = metrics.NewRegisteredTimer("state/snapshot/generation/duration/storage/snapread", nil)
91-
// snapStorageWriteTimer measures time spent on writing/updating/deleting storages
92-
snapStorageWriteTimer = metrics.NewRegisteredTimer("state/snapshot/generation/duration/storage/write", nil)
77+
// snapAccountProveCounter measures time spent on the account proving
78+
snapAccountProveCounter = metrics.NewRegisteredCounter("state/snapshot/generation/duration/account/prove", nil)
79+
// snapAccountTrieReadCounter measures time spent on the account trie iteration
80+
snapAccountTrieReadCounter = metrics.NewRegisteredCounter("state/snapshot/generation/duration/account/trieread", nil)
81+
// snapAccountSnapReadCounter measues time spent on the snapshot account iteration
82+
snapAccountSnapReadCounter = metrics.NewRegisteredCounter("state/snapshot/generation/duration/account/snapread", nil)
83+
// snapAccountWriteCounter measures time spent on writing/updating/deleting accounts
84+
snapAccountWriteCounter = metrics.NewRegisteredCounter("state/snapshot/generation/duration/account/write", nil)
85+
// snapStorageProveCounter measures time spent on storage proving
86+
snapStorageProveCounter = metrics.NewRegisteredCounter("state/snapshot/generation/duration/storage/prove", nil)
87+
// snapStorageTrieReadCounter measures time spent on the storage trie iteration
88+
snapStorageTrieReadCounter = metrics.NewRegisteredCounter("state/snapshot/generation/duration/storage/trieread", nil)
89+
// snapStorageSnapReadCounter measures time spent on the snapshot storage iteration
90+
snapStorageSnapReadCounter = metrics.NewRegisteredCounter("state/snapshot/generation/duration/storage/snapread", nil)
91+
// snapStorageWriteCounter measures time spent on writing/updating/deleting storages
92+
snapStorageWriteCounter = metrics.NewRegisteredCounter("state/snapshot/generation/duration/storage/write", nil)
9393
)
9494

9595
// generatorStats is a collection of statistics gathered by the snapshot generator
@@ -301,15 +301,15 @@ func (dl *diskLayer) proveRange(stats *generatorStats, root common.Hash, prefix
301301
}
302302
// Update metrics for database iteration and merkle proving
303303
if kind == "storage" {
304-
snapStorageSnapReadTimer.Update(time.Since(start))
304+
snapStorageSnapReadCounter.Inc(time.Since(start).Nanoseconds())
305305
} else {
306-
snapAccountSnapReadTimer.Update(time.Since(start))
306+
snapAccountSnapReadCounter.Inc(time.Since(start).Nanoseconds())
307307
}
308308
defer func(start time.Time) {
309309
if kind == "storage" {
310-
snapStorageProveTimer.Update(time.Since(start))
310+
snapStorageProveCounter.Inc(time.Since(start).Nanoseconds())
311311
} else {
312-
snapAccountProveTimer.Update(time.Since(start))
312+
snapAccountProveCounter.Inc(time.Since(start).Nanoseconds())
313313
}
314314
}(time.Now())
315315

@@ -512,9 +512,9 @@ func (dl *diskLayer) generateRange(root common.Hash, prefix []byte, kind string,
512512

513513
// Update metrics for counting trie iteration
514514
if kind == "storage" {
515-
snapStorageTrieReadTimer.Update(time.Since(start) - internal)
515+
snapStorageTrieReadCounter.Inc((time.Since(start) - internal).Nanoseconds())
516516
} else {
517-
snapAccountTrieReadTimer.Update(time.Since(start) - internal)
517+
snapAccountTrieReadCounter.Inc((time.Since(start) - internal).Nanoseconds())
518518
}
519519
logger.Debug("Regenerated state range", "root", root, "last", hexutil.Encode(last),
520520
"count", count, "created", created, "updated", updated, "untouched", untouched, "deleted", deleted)
@@ -593,7 +593,7 @@ func (dl *diskLayer) generate(stats *generatorStats) {
593593
if err := wipeKeyRange(dl.diskdb, "storage", prefix, nil, nil, keyLen, snapWipedStorageMeter, false); err != nil {
594594
return err
595595
}
596-
snapAccountWriteTimer.Update(time.Since(start))
596+
snapAccountWriteCounter.Inc(time.Since(start).Nanoseconds())
597597
return nil
598598
}
599599
// Retrieve the current account and flatten it into the internal format
@@ -643,17 +643,17 @@ func (dl *diskLayer) generate(stats *generatorStats) {
643643
if err := wipeKeyRange(dl.diskdb, "storage", prefix, nil, nil, keyLen, snapWipedStorageMeter, false); err != nil {
644644
return err
645645
}
646-
snapAccountWriteTimer.Update(time.Since(start))
646+
snapAccountWriteCounter.Inc(time.Since(start).Nanoseconds())
647647
} else {
648-
snapAccountWriteTimer.Update(time.Since(start))
648+
snapAccountWriteCounter.Inc(time.Since(start).Nanoseconds())
649649

650650
var storeMarker []byte
651651
if accMarker != nil && bytes.Equal(accountHash[:], accMarker) && len(dl.genMarker) > common.HashLength {
652652
storeMarker = dl.genMarker[common.HashLength:]
653653
}
654654
onStorage := func(key []byte, val []byte, write bool, delete bool) error {
655655
defer func(start time.Time) {
656-
snapStorageWriteTimer.Update(time.Since(start))
656+
snapStorageWriteCounter.Inc(time.Since(start).Nanoseconds())
657657
}(time.Now())
658658

659659
if delete {

0 commit comments

Comments
 (0)