Skip to content

Commit

Permalink
pathdb: delete test metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
VM committed Jun 20, 2024
1 parent 023bb3f commit 2a622db
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 53 deletions.
9 changes: 0 additions & 9 deletions trie/triedb/pathdb/disklayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,10 +322,6 @@ func (dl *diskLayer) commit(bottom *diffLayer, force bool) (*diskLayer, error) {
if !force && rawdb.ReadPersistentStateID(dl.db.diskdb) < oldest {
force = true
}
ancientNumber, _ := ndl.db.freezer.Ancients()
ancientTail, _ := ndl.db.freezer.Tail()
nblAncientSizeGauge.Update(int64(ancientNumber))
nblAncientTailGauge.Update(int64(ancientTail))

if err := ndl.buffer.flush(ndl.db.diskdb, ndl.cleans, ndl.id, force); err != nil {
return nil, err
Expand All @@ -346,11 +342,6 @@ func (dl *diskLayer) commit(bottom *diffLayer, force bool) (*diskLayer, error) {
}

pruned, err := truncateFromTail(ndl.db.diskdb, ndl.db.freezer, oldest-1)
ancientNumber, _ = ndl.db.freezer.Ancients()
ancientTail, _ = ndl.db.freezer.Tail()
nblAncientSizeGauge.Update(int64(ancientNumber))
nblAncientTailGauge.Update(int64(ancientTail))

if err != nil {
log.Error("Failed to truncate from tail", "ntail", oldest-1)
return nil, err
Expand Down
10 changes: 0 additions & 10 deletions trie/triedb/pathdb/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,4 @@ 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)
nblAncientSizeGauge = metrics.NewRegisteredGauge("pathdb/nbl/ancient/size", nil)
nblAncientTailGauge = metrics.NewRegisteredGauge("pathdb/nbl/ancient/tail", nil)
)
49 changes: 15 additions & 34 deletions trie/triedb/pathdb/nodebufferlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,6 @@ func (nf *nodebufferlist) flush(db ethdb.KeyValueStore, clean *fastcache.Cache,
return true
}
nf.traverseReverse(commitFunc)
// delete after testing
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 @@ -294,22 +291,6 @@ func (nf *nodebufferlist) flush(db ethdb.KeyValueStore, clean *fastcache.Cache,
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
// 2. nf.base.layers preBaseLayes => Guard type

// test:
// 1. setup private seq
// 2. 10 accounts, 1qps, native transfer
// 3. add metrics(above)
// 4. wait more 9w
return nil
}

Expand Down Expand Up @@ -355,11 +336,11 @@ func (nf *nodebufferlist) getAllNodes() map[common.Hash]map[string]*trienode.Nod

nc := newMultiDifflayer(nf.limit, 0, common.Hash{}, make(map[common.Hash]map[string]*trienode.Node), 0)
if err := nc.commit(nf.base.root, nf.base.id, nf.base.block, nf.layers, nf.base.nodes); err != nil {
log.Crit("Failed to commit nodes to node buffer", "error", err)
log.Crit("failed to commit nodes to node buffer", "error", err)
}
merge := func(buffer *multiDifflayer) bool {
if err := nc.commit(buffer.root, buffer.id, buffer.block, buffer.layers, buffer.nodes); err != nil {
log.Crit("Failed to commit nodes to node buffer", "error", err)
log.Crit("failed to commit nodes to node buffer", "error", err)
}
return true
}
Expand All @@ -384,7 +365,7 @@ func (nf *nodebufferlist) waitAndStopFlushing() {
nf.stopFlushing.Store(true)
for nf.isFlushing.Load() {
time.Sleep(time.Second)
log.Warn("Waiting background node buffer to be flushed to disk")
log.Warn("waiting background node buffer to be flushed to disk")
}
}

Expand Down Expand Up @@ -435,17 +416,17 @@ func (nf *nodebufferlist) popBack() *multiDifflayer {

nf.size -= tag.size
if nf.size < 0 {
log.Warn("Node buffer list size less 0", "old", nf.size, "dealt", tag.size)
log.Warn("node buffer list size less 0", "old", nf.size, "dealt", tag.size)
nf.size = 0
}
nf.layers -= tag.layers
if nf.layers < 0 {
log.Warn("Node buffer list layers less 0", "old", nf.layers, "dealt", tag.layers)
log.Warn("node buffer list layers less 0", "old", nf.layers, "dealt", tag.layers)
nf.layers = 0
}
nf.count--
if nf.count < 0 {
log.Warn("Node buffer list count less 0", "old", nf.count)
log.Warn("node buffer list count less 0", "old", nf.count)
nf.count = 0
}

Expand Down Expand Up @@ -490,15 +471,15 @@ func (nf *nodebufferlist) traverseReverse(cb func(*multiDifflayer) bool) {
func (nf *nodebufferlist) diffToBase() {
commitFunc := func(buffer *multiDifflayer) bool {
if nf.base.size >= nf.base.limit {
log.Debug("Base node buffer need write disk immediately")
log.Debug("base node buffer need write disk immediately")
return false
}
if nf.count <= nf.rsevMdNum {
log.Debug("Node buffer list less, waiting more difflayer to be committed")
log.Debug("node buffer list less, waiting more difflayer to be committed")
return false
}
if buffer.block%nf.dlInMd != 0 {
log.Crit("Committed block number misaligned", "block", buffer.block)
log.Crit("committed block number misaligned", "block", buffer.block)
}

if nf.keepFunc != nil { // keep in background flush stage
Expand All @@ -516,7 +497,7 @@ func (nf *nodebufferlist) diffToBase() {
err := nf.base.commit(buffer.root, buffer.id, buffer.block, buffer.layers, buffer.nodes)
nf.baseMux.Unlock()
if err != nil {
log.Error("Failed to commit nodes to base node buffer", "error", err)
log.Error("failed to commit nodes to base node buffer", "error", err)
return false
}

Expand Down Expand Up @@ -550,7 +531,7 @@ func (nf *nodebufferlist) backgroundFlush() {
nf.baseMux.RUnlock()
err := nf.base.flush(nf.db, nf.clean, persistID)
if err != nil {
log.Error("Failed to flush base node buffer to disk", "error", err)
log.Error("failed to flush base node buffer to disk", "error", err)
return
}
nf.baseMux.Lock()
Expand Down Expand Up @@ -645,7 +626,7 @@ func (nf *nodebufferlist) proposedBlockReader(blockRoot common.Hash) (layer, err
nf.traverse(find)
if diff == nil {
proposedBlockReaderMismatch.Mark(1)
log.Debug("Proposed block state is not available", context...)
log.Debug("proposed block state is not available", context...)
return nil, fmt.Errorf("proposed block proof state %#x is not available", blockRoot)
}
proposedBlockReaderSuccess.Mark(1)
Expand All @@ -662,7 +643,7 @@ func (nf *nodebufferlist) report() {
"stateid", nf.stateId, "persist", nf.persistID, "size", common.StorageSize(nf.size),
"basesize", common.StorageSize(nf.base.size), "baselayers", nf.base.layers,
}
log.Info("Node buffer list info", context...)
log.Info("node buffer list info", context...)
}

var _ layer = &proposedBlockReader{}
Expand Down Expand Up @@ -801,10 +782,10 @@ func (mf *multiDifflayer) node(owner common.Hash, path []byte, hash common.Hash)
// It will just hold the node references from the given map which are safe to copy.
func (mf *multiDifflayer) commit(root common.Hash, id uint64, block uint64, layers uint64, nodes map[common.Hash]map[string]*trienode.Node) error {
if mf.id != 0 && mf.id >= id {
log.Warn("State id out of order", "pre_stateId", mf.id, "capping_stateId", id)
log.Warn("state id out of order", "pre_stateId", mf.id, "capping_stateId", id)
}
if mf.block != 0 && mf.block >= block {
log.Warn("Block number out of order", "pre_block", mf.block, "capping_block", block)
log.Warn("block number out of order", "pre_block", mf.block, "capping_block", block)
}

mf.root = root
Expand Down

0 comments on commit 2a622db

Please sign in to comment.