perf: add db metrics
This commit is contained in:
parent
3082da4e86
commit
8a3d62e756
@ -19,6 +19,7 @@ package snapshot
|
||||
import (
|
||||
"bytes"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/VictoriaMetrics/fastcache"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
@ -136,7 +137,12 @@ func (dl *diskLayer) AccountRLP(hash common.Hash) ([]byte, error) {
|
||||
return blob, nil
|
||||
}
|
||||
// Cache doesn't contain account, pull from disk and cache for later
|
||||
// TODO:
|
||||
snapNodeQPS.Mark(1)
|
||||
startLoadSnapNode := time.Now()
|
||||
blob := rawdb.ReadAccountSnapshot(dl.diskdb, hash)
|
||||
snapNodeTime.Mark(time.Since(startLoadSnapNode).Nanoseconds())
|
||||
|
||||
dl.cache.Set(hash[:], blob)
|
||||
|
||||
snapshotCleanAccountMissMeter.Mark(1)
|
||||
@ -176,7 +182,11 @@ func (dl *diskLayer) Storage(accountHash, storageHash common.Hash) ([]byte, erro
|
||||
return blob, nil
|
||||
}
|
||||
// Cache doesn't contain storage slot, pull from disk and cache for later
|
||||
// TODO:
|
||||
snapNodeQPS.Mark(1)
|
||||
startLoadSnapNode := time.Now()
|
||||
blob := rawdb.ReadStorageSnapshot(dl.diskdb, accountHash, storageHash)
|
||||
snapNodeTime.Mark(time.Since(startLoadSnapNode).Nanoseconds())
|
||||
dl.cache.Set(key, blob)
|
||||
|
||||
snapshotCleanStorageMissMeter.Mark(1)
|
||||
|
@ -50,4 +50,7 @@ var (
|
||||
snapStorageWriteCounter = metrics.NewRegisteredCounter("state/snapshot/generation/duration/storage/write", nil)
|
||||
// snapStorageCleanCounter measures time spent on deleting storages
|
||||
snapStorageCleanCounter = metrics.NewRegisteredCounter("state/snapshot/generation/duration/storage/clean", nil)
|
||||
|
||||
snapNodeQPS = metrics.NewRegisteredMeter("pbss/snap/node/qps", nil)
|
||||
snapNodeTime = metrics.NewRegisteredMeter("pbss/snap/node/time", nil)
|
||||
)
|
||||
|
@ -20,6 +20,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/VictoriaMetrics/fastcache"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
@ -197,11 +198,15 @@ func (dl *diskLayer) Node(owner common.Hash, path []byte, hash common.Hash) ([]b
|
||||
nBlob []byte
|
||||
nHash common.Hash
|
||||
)
|
||||
// TODO:
|
||||
trieNodeQPS.Mark(1)
|
||||
startLoadTrieNode := time.Now()
|
||||
if owner == (common.Hash{}) {
|
||||
nBlob, nHash = rawdb.ReadAccountTrieNode(dl.db.diskdb, path)
|
||||
} else {
|
||||
nBlob, nHash = rawdb.ReadStorageTrieNode(dl.db.diskdb, owner, path)
|
||||
}
|
||||
trieNodeTime.Mark(time.Since(startLoadTrieNode).Nanoseconds())
|
||||
if nHash != hash {
|
||||
diskFalseMeter.Mark(1)
|
||||
log.Error("Unexpected trie node in disk", "owner", owner, "path", path, "expect", hash, "got", nHash)
|
||||
|
@ -56,4 +56,7 @@ var (
|
||||
|
||||
PbssUpdateDiffQPS = metrics.NewRegisteredMeter("pbss/difflayer/update/qps", nil)
|
||||
PbssUpdateDiffTime = metrics.NewRegisteredTimer("pbss/difflayer/update/time", nil)
|
||||
|
||||
trieNodeQPS = metrics.NewRegisteredMeter("pbss/trie/node/qps", nil)
|
||||
trieNodeTime = metrics.NewRegisteredMeter("pbss/trie/node/time", nil)
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user