aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cmd/geth/chaincmd.go3
-rw-r--r--core/state/statedb.go2
-rw-r--r--trie/trie.go7
3 files changed, 11 insertions, 1 deletions
diff --git a/cmd/geth/chaincmd.go b/cmd/geth/chaincmd.go
index c41375c4d..20c7dc74c 100644
--- a/cmd/geth/chaincmd.go
+++ b/cmd/geth/chaincmd.go
@@ -99,7 +99,8 @@ func importChain(ctx *cli.Context) error {
utils.Fatalf("Failed to read database stats: %v", err)
}
fmt.Println(stats)
- fmt.Printf("Trie cache misses: %d\n\n", trie.CacheMisses())
+ fmt.Printf("Trie cache misses: %d\n", trie.CacheMisses())
+ fmt.Printf("Trie cache unloads: %d\n\n", trie.CacheUnloads())
// Compact the entire database to more accurately measure disk io and print the stats
start = time.Now()
diff --git a/core/state/statedb.go b/core/state/statedb.go
index 6a24d2865..ae106e03b 100644
--- a/core/state/statedb.go
+++ b/core/state/statedb.go
@@ -564,6 +564,8 @@ func (s *StateDB) Commit() (root common.Hash, err error) {
func (s *StateDB) CommitBatch() (root common.Hash, batch ethdb.Batch) {
batch = s.db.NewBatch()
root, _ = s.commit(batch)
+
+ glog.V(logger.Debug).Infof("Trie cache stats: %d misses, %d unloads", trie.CacheMisses(), trie.CacheUnloads())
return root, batch
}
diff --git a/trie/trie.go b/trie/trie.go
index 2a7bc16e4..035a80e74 100644
--- a/trie/trie.go
+++ b/trie/trie.go
@@ -47,6 +47,13 @@ func CacheMisses() int64 {
return cacheMissCounter.Count()
}
+// CacheUnloads retrieves a global counter measuring the number of cache unloads
+// the trie did since process startup. This isn't useful for anything apart from
+// trie debugging purposes.
+func CacheUnloads() int64 {
+ return cacheUnloadCounter.Count()
+}
+
func init() {
sha3.NewKeccak256().Sum(emptyState[:0])
}