Skip to content

Commit

Permalink
eth, trie: add more metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
rjl493456442 committed Oct 20, 2023
1 parent a155a06 commit 10e4305
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
4 changes: 2 additions & 2 deletions eth/protocols/snap/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 18 additions & 4 deletions trie/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 10e4305

Please sign in to comment.