diff --git a/trie/database.go b/trie/database.go index 931918efb..b0fd78744 100644 --- a/trie/database.go +++ b/trie/database.go @@ -38,6 +38,11 @@ var ( memcacheCleanReadMeter = metrics.NewRegisteredMeter("trie/memcache/clean/read", nil) memcacheCleanWriteMeter = metrics.NewRegisteredMeter("trie/memcache/clean/write", nil) + memcacheDirtyHitMeter = metrics.NewRegisteredMeter("trie/memcache/dirty/hit", nil) + memcacheDirtyMissMeter = metrics.NewRegisteredMeter("trie/memcache/dirty/miss", nil) + memcacheDirtyReadMeter = metrics.NewRegisteredMeter("trie/memcache/dirty/read", nil) + memcacheDirtyWriteMeter = metrics.NewRegisteredMeter("trie/memcache/dirty/write", nil) + memcacheFlushTimeTimer = metrics.NewRegisteredResettingTimer("trie/memcache/flush/time", nil) memcacheFlushNodesMeter = metrics.NewRegisteredMeter("trie/memcache/flush/nodes", nil) memcacheFlushSizeMeter = metrics.NewRegisteredMeter("trie/memcache/flush/size", nil) @@ -321,6 +326,8 @@ func (db *Database) insert(hash common.Hash, blob []byte, node node) { if _, ok := db.dirties[hash]; ok { return } + memcacheDirtyWriteMeter.Mark(int64(len(blob))) + // Create the cached entry for this node entry := &cachedNode{ node: simplifyNode(node), @@ -372,8 +379,12 @@ func (db *Database) node(hash common.Hash) node { db.lock.RUnlock() if dirty != nil { + memcacheDirtyHitMeter.Mark(1) + memcacheDirtyReadMeter.Mark(int64(dirty.size)) return dirty.obj(hash) } + memcacheDirtyMissMeter.Mark(1) + // Content unavailable in memory, attempt to retrieve from disk enc, err := db.diskdb.Get(hash[:]) if err != nil || enc == nil { @@ -408,8 +419,12 @@ func (db *Database) Node(hash common.Hash) ([]byte, error) { db.lock.RUnlock() if dirty != nil { + memcacheDirtyHitMeter.Mark(1) + memcacheDirtyReadMeter.Mark(int64(dirty.size)) return dirty.rlp(), nil } + memcacheDirtyMissMeter.Mark(1) + // Content unavailable in memory, attempt to retrieve from disk enc, err := db.diskdb.Get(hash[:]) if err == nil && enc != nil { @@ -812,6 +827,7 @@ func (c *cleaner) Put(key []byte, rlp []byte) error { // Move the flushed node into the clean cache to prevent insta-reloads if c.db.cleans != nil { c.db.cleans.Set(hash[:], rlp) + memcacheCleanWriteMeter.Mark(int64(len(rlp))) } return nil }