From 2a622db413b0ca790a7504fd0821a740397dbfec Mon Sep 17 00:00:00 2001 From: VM Date: Thu, 20 Jun 2024 10:12:52 +0800 Subject: [PATCH] pathdb: delete test metrics --- trie/triedb/pathdb/disklayer.go | 9 ----- trie/triedb/pathdb/metrics.go | 10 ------ trie/triedb/pathdb/nodebufferlist.go | 49 +++++++++------------------- 3 files changed, 15 insertions(+), 53 deletions(-) diff --git a/trie/triedb/pathdb/disklayer.go b/trie/triedb/pathdb/disklayer.go index 468aec29b2..7d6ae8599d 100644 --- a/trie/triedb/pathdb/disklayer.go +++ b/trie/triedb/pathdb/disklayer.go @@ -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 @@ -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 diff --git a/trie/triedb/pathdb/metrics.go b/trie/triedb/pathdb/metrics.go index 8d193a4974..ee91e5dc20 100644 --- a/trie/triedb/pathdb/metrics.go +++ b/trie/triedb/pathdb/metrics.go @@ -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) ) diff --git a/trie/triedb/pathdb/nodebufferlist.go b/trie/triedb/pathdb/nodebufferlist.go index 0dcc428b23..b0666b8d9e 100644 --- a/trie/triedb/pathdb/nodebufferlist.go +++ b/trie/triedb/pathdb/nodebufferlist.go @@ -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 { @@ -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 } @@ -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 } @@ -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") } } @@ -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 } @@ -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 @@ -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 } @@ -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() @@ -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) @@ -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{} @@ -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