trie: track dirty cache metrics, track clean writes on commit
This commit is contained in:
parent
7ce7c3967c
commit
13ccf6016e
@ -38,6 +38,11 @@ var (
|
|||||||
memcacheCleanReadMeter = metrics.NewRegisteredMeter("trie/memcache/clean/read", nil)
|
memcacheCleanReadMeter = metrics.NewRegisteredMeter("trie/memcache/clean/read", nil)
|
||||||
memcacheCleanWriteMeter = metrics.NewRegisteredMeter("trie/memcache/clean/write", 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)
|
memcacheFlushTimeTimer = metrics.NewRegisteredResettingTimer("trie/memcache/flush/time", nil)
|
||||||
memcacheFlushNodesMeter = metrics.NewRegisteredMeter("trie/memcache/flush/nodes", nil)
|
memcacheFlushNodesMeter = metrics.NewRegisteredMeter("trie/memcache/flush/nodes", nil)
|
||||||
memcacheFlushSizeMeter = metrics.NewRegisteredMeter("trie/memcache/flush/size", 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 {
|
if _, ok := db.dirties[hash]; ok {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
memcacheDirtyWriteMeter.Mark(int64(len(blob)))
|
||||||
|
|
||||||
// Create the cached entry for this node
|
// Create the cached entry for this node
|
||||||
entry := &cachedNode{
|
entry := &cachedNode{
|
||||||
node: simplifyNode(node),
|
node: simplifyNode(node),
|
||||||
@ -372,8 +379,12 @@ func (db *Database) node(hash common.Hash) node {
|
|||||||
db.lock.RUnlock()
|
db.lock.RUnlock()
|
||||||
|
|
||||||
if dirty != nil {
|
if dirty != nil {
|
||||||
|
memcacheDirtyHitMeter.Mark(1)
|
||||||
|
memcacheDirtyReadMeter.Mark(int64(dirty.size))
|
||||||
return dirty.obj(hash)
|
return dirty.obj(hash)
|
||||||
}
|
}
|
||||||
|
memcacheDirtyMissMeter.Mark(1)
|
||||||
|
|
||||||
// Content unavailable in memory, attempt to retrieve from disk
|
// Content unavailable in memory, attempt to retrieve from disk
|
||||||
enc, err := db.diskdb.Get(hash[:])
|
enc, err := db.diskdb.Get(hash[:])
|
||||||
if err != nil || enc == nil {
|
if err != nil || enc == nil {
|
||||||
@ -408,8 +419,12 @@ func (db *Database) Node(hash common.Hash) ([]byte, error) {
|
|||||||
db.lock.RUnlock()
|
db.lock.RUnlock()
|
||||||
|
|
||||||
if dirty != nil {
|
if dirty != nil {
|
||||||
|
memcacheDirtyHitMeter.Mark(1)
|
||||||
|
memcacheDirtyReadMeter.Mark(int64(dirty.size))
|
||||||
return dirty.rlp(), nil
|
return dirty.rlp(), nil
|
||||||
}
|
}
|
||||||
|
memcacheDirtyMissMeter.Mark(1)
|
||||||
|
|
||||||
// Content unavailable in memory, attempt to retrieve from disk
|
// Content unavailable in memory, attempt to retrieve from disk
|
||||||
enc, err := db.diskdb.Get(hash[:])
|
enc, err := db.diskdb.Get(hash[:])
|
||||||
if err == nil && enc != nil {
|
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
|
// Move the flushed node into the clean cache to prevent insta-reloads
|
||||||
if c.db.cleans != nil {
|
if c.db.cleans != nil {
|
||||||
c.db.cleans.Set(hash[:], rlp)
|
c.db.cleans.Set(hash[:], rlp)
|
||||||
|
memcacheCleanWriteMeter.Mark(int64(len(rlp)))
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user