瀏覽代碼

trie: add metric to track cache unloading (#3175)

Felix Lange 9 年之前
父節點
當前提交
5d9bb0a050
共有 2 個文件被更改,包括 5 次插入1 次删除
  1. 1 0
      trie/hasher.go
  2. 4 1
      trie/trie.go

+ 1 - 0
trie/hasher.go

@@ -60,6 +60,7 @@ func (h *hasher) hash(n node, db DatabaseWriter, force bool) (node, node, error)
 		if n.canUnload(h.cachegen, h.cachelimit) {
 		if n.canUnload(h.cachegen, h.cachelimit) {
 			// Unload the node from cache. All of its subnodes will have a lower or equal
 			// Unload the node from cache. All of its subnodes will have a lower or equal
 			// cache generation number.
 			// cache generation number.
+			cacheUnloadCounter.Inc(1)
 			return hash, hash, nil
 			return hash, hash, nil
 		}
 		}
 		if !dirty {
 		if !dirty {

+ 4 - 1
trie/trie.go

@@ -35,7 +35,10 @@ var (
 	emptyState common.Hash
 	emptyState common.Hash
 )
 )
 
 
-var cacheMissCounter = metrics.NewRegisteredCounter("trie/cachemiss", nil)
+var (
+	cacheMissCounter   = metrics.NewRegisteredCounter("trie/cachemiss", nil)
+	cacheUnloadCounter = metrics.NewRegisteredCounter("trie/cacheunload", nil)
+)
 
 
 // CacheMisses retrieves a global counter measuring the number of cache misses
 // 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
 // the trie did since process startup. This isn't useful for anything apart from