Skip to content

Commit

Permalink
fix: add nodebufferlist test metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
VM committed Jun 12, 2024
1 parent 50534f8 commit a405a93
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
8 changes: 8 additions & 0 deletions trie/triedb/pathdb/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,12 @@ var (
baseNodeBufferDifflayerAvgSize = metrics.NewRegisteredGauge("pathdb/basenodebuffer/difflayeravgsize", nil)
proposedBlockReaderSuccess = metrics.NewRegisteredMeter("pathdb/nodebufferlist/proposedblockreader/success", nil)
proposedBlockReaderMismatch = metrics.NewRegisteredMeter("pathdb/nodebufferlist/proposedblockreader/mismatch", nil)

// temp metrics for test purpose
nblCountGauge = metrics.NewRegisteredGauge("pathdb/nbl/count", nil)
nblLayersGauge = metrics.NewRegisteredGauge("pathdb/nbl/layers", nil)
nblPersistIDGauge = metrics.NewRegisteredGauge("pathdb/nbl/persistid", nil)
nblPrePersistIDGauge = metrics.NewRegisteredGauge("pathdb/nbl/prepersistid", nil)
nblBaseLayersGauge = metrics.NewRegisteredGauge("pathdb/nbl/baselayers", nil)
nblPreBaseLayersGauge = metrics.NewRegisteredGauge("pathdb/nbl/prebaselayers", nil)
)
11 changes: 9 additions & 2 deletions trie/triedb/pathdb/nodebufferlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,8 @@ func (nf *nodebufferlist) flush(db ethdb.KeyValueStore, clean *fastcache.Cache,
}
nf.traverseReverse(commitFunc)
// delete after testing
//prePersistID := nf.persistID
//preBaseLayes := nf.base.layers
prePersistID := nf.persistID
preBaseLayers := nf.base.layers
persistID := nf.persistID + nf.base.layers
err := nf.base.flush(nf.db, nf.clean, persistID)
if err != nil {
Expand All @@ -291,6 +291,13 @@ func (nf *nodebufferlist) flush(db ethdb.KeyValueStore, clean *fastcache.Cache,
nf.isFlushing.Store(false)
nf.base.reset()
nf.persistID = persistID

nblCountGauge.Update(int64(nf.count))
nblLayersGauge.Update(int64(nf.layers))
nblPersistIDGauge.Update(int64(nf.persistID))
nblPrePersistIDGauge.Update(int64(prePersistID))
nblBaseLayersGauge.Update(int64(nf.base.layers))
nblPreBaseLayersGauge.Update(int64(preBaseLayers))
// add metrics, delete after testing
// 1. nf.count nf.layers => Guard type
// 2. nf.persistID prePersistID => Guard type
Expand Down

0 comments on commit a405a93

Please sign in to comment.