-
Notifications
You must be signed in to change notification settings - Fork 20.9k
core,triedb: add fastcache metrics #31883
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: jsvisa <delweng@gmail.com>
Signed-off-by: jsvisa <delweng@gmail.com>
Signed-off-by: jsvisa <delweng@gmail.com>
Signed-off-by: jsvisa <delweng@gmail.com>
@@ -379,6 +388,20 @@ func (t *Tree) Cap(root common.Hash, layers int) error { | |||
if !ok { | |||
return fmt.Errorf("snapshot [%#x] is disk layer", root) | |||
} | |||
|
|||
// Update the cache stats | |||
if diff.origin != nil && diff.origin.cache != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's very weird to upload the cache stats here.
The associated disk layer will only be modified if the size bottom-most diff layer reaches the threshold, it's not always be updated...
if diff.origin != nil && diff.origin.cache != nil { | ||
var stats fastcache.Stats | ||
diff.origin.cache.UpdateStats(&stats) | ||
snapshotCacheGetGauge.Update(int64(stats.GetCalls)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we already have the similar metrics
snapshotCleanStorageHitMeter = metrics.NewRegisteredMeter("state/snapshot/clean/storage/hit", nil)
snapshotCleanStorageMissMeter = metrics.NewRegisteredMeter("state/snapshot/clean/storage/miss", nil)
snapshotCleanStorageInexMeter = metrics.NewRegisteredMeter("state/snapshot/clean/storage/inex", nil)
snapshotCleanStorageReadMeter = metrics.NewRegisteredMeter("state/snapshot/clean/storage/read", nil)
snapshotCleanStorageWriteMeter = metrics.NewRegisteredMeter("state/snapshot/clean/storage/write", nil)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's probably unnecessary to add more duplicated ones.
It seems a bit useless to graph the total usage of the cache, since it will always be full by definition. We do not evict items from the cache manually, so the cache will fill up and then stay at the configured limit. The more interesting metric is the hit/miss rate but we already have a metric for that. |
Add more metrics about the fastcache, so the users have a clear understanding of the use of cache and know how to configure the size of each cache.
I'm running with
This is the metrics in grafana dashboard:
I can see that the disk layer cache(
--cache.snapshot
) is not used much, given 6*0.2=1.2GB, but only 30% was in use; and for the trie cache(--cache.trie
) is fully used, so in my case, I now know I need to reduce the cache used for snapshot, and increase it for trie.