diff --git a/eth/protocols/snap/metrics.go b/eth/protocols/snap/metrics.go index 83f553de19..26911e2cef 100644 --- a/eth/protocols/snap/metrics.go +++ b/eth/protocols/snap/metrics.go @@ -43,8 +43,8 @@ var ( // nodes in storage tries are met. boundaryStorageNodesGauge = metrics.NewRegisteredGauge("eth/protocols/snap/sync/boundary/storage", nil) - // smallStorageGauge is the metric to track how many storages are retrieved - // in a single request. + // smallStorageGauge is the metric to track how many storages are small enough + // to retrieved in one or two request. smallStorageGauge = metrics.NewRegisteredGauge("eth/protocols/snap/sync/storage/small", nil) // largeStorageGauge is the metric to track how many storages are large enough diff --git a/trie/sync.go b/trie/sync.go index dfb9f9fd7c..8eaed9f21a 100644 --- a/trie/sync.go +++ b/trie/sync.go @@ -52,9 +52,13 @@ var ( // performed to determine if node needs to be deleted. lookupGauge = metrics.NewRegisteredGauge("trie/sync/lookup", nil) - // nodeSyncedGauge is the metric to track how many trie node are written - // during the sync. - nodeSyncedGauge = metrics.NewRegisteredGauge("trie/sync/nodes", nil) + // accountNodeSyncedGauge is the metric to track how many account trie + // node are written during the sync. + accountNodeSyncedGauge = metrics.NewRegisteredGauge("trie/sync/nodes/account", nil) + + // storageNodeSyncedGauge is the metric to track how many account trie + // node are written during the sync. + storageNodeSyncedGauge = metrics.NewRegisteredGauge("trie/sync/nodes/storage", nil) // codeSyncedGauge is the metric to track how many contract codes are // written during the sync. @@ -370,11 +374,21 @@ func (s *Sync) ProcessNode(result NodeSyncResult) error { // storage, returning any occurred error. func (s *Sync) Commit(dbw ethdb.Batch) error { // Flush the pending node writes into database batch. + var ( + account int + storage int + ) for path, value := range s.membatch.nodes { owner, inner := ResolvePath([]byte(path)) + if owner == (common.Hash{}) { + account += 1 + } else { + storage += 1 + } rawdb.WriteTrieNode(dbw, owner, inner, s.membatch.hashes[path], value, s.scheme) } - nodeSyncedGauge.Inc(int64(len(s.membatch.nodes))) + accountNodeSyncedGauge.Inc(int64(account)) + storageNodeSyncedGauge.Inc(int64(storage)) // Flush the pending node deletes into the database batch. // Please note that each written and deleted node has a