aboutsummaryrefslogtreecommitdiffstats
path: root/trie
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2016-10-19 21:22:37 +0800
committerFelix Lange <fjl@twurst.com>2016-10-19 21:22:37 +0800
commitd48e6ae66f09b1061e2e7e54c750b20e14a1e45a (patch)
tree16ddc2493c2a89f3d753c325a6d9f873a4b96632 /trie
parentca49510e6dd40e78e3e6827c6c4d7b2a3ec8ef5b (diff)
downloadgo-tangerine-d48e6ae66f09b1061e2e7e54c750b20e14a1e45a.tar.gz
go-tangerine-d48e6ae66f09b1061e2e7e54c750b20e14a1e45a.tar.zst
go-tangerine-d48e6ae66f09b1061e2e7e54c750b20e14a1e45a.zip
trie: make the cache miss counter a real metric
Diffstat (limited to 'trie')
-rw-r--r--trie/trie.go12
1 files changed, 5 insertions, 7 deletions
diff --git a/trie/trie.go b/trie/trie.go
index 914bf20fa..632060543 100644
--- a/trie/trie.go
+++ b/trie/trie.go
@@ -20,12 +20,12 @@ package trie
import (
"bytes"
"fmt"
- "sync/atomic"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto/sha3"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
+ "github.com/rcrowley/go-metrics"
)
var (
@@ -35,15 +35,13 @@ var (
emptyState common.Hash
)
-// cacheMisses maintains the number of times a trie node was loaded from disk.
-// Always use atomic operations when accessing this global variable.
-var cacheMisses uint64
+var cacheMissCounter = metrics.NewRegisteredCounter("trie/cachemiss", nil)
// CacheMisses retrieves a global counter measuring the number of cache misses
// the trie did since process startup. This isn't useful for anything apart from
// trie debugging purposes.
-func CacheMisses() uint64 {
- return atomic.LoadUint64(&cacheMisses)
+func CacheMisses() int64 {
+ return cacheMissCounter.Count()
}
func init() {
@@ -432,7 +430,7 @@ func (t *Trie) resolve(n node, prefix, suffix []byte) (node, error) {
}
func (t *Trie) resolveHash(n hashNode, prefix, suffix []byte) (node, error) {
- atomic.AddUint64(&cacheMisses, 1)
+ cacheMissCounter.Inc(1)
enc, err := t.db.Get(n)
if err != nil || enc == nil {