-
Notifications
You must be signed in to change notification settings - Fork 632
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
feat/introduce cache related metrics for prometheus #7439
Conversation
@@ -43,10 +46,20 @@ impl TrieCache { | |||
guard.put(hash, value.into()); | |||
} |
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.
} | |
} else { | |
metrics::SHARD_CACHE_TOO_LARGE.with_label_values(&labels).inc(); | |
} |
We need to inc this metric here as well - this is my bug from the first impl
@@ -34,7 +34,10 @@ impl TrieCache { | |||
self.0.lock().expect(POISONED_LOCK_ERR).clear() | |||
} | |||
|
|||
pub fn update_cache(&self, ops: Vec<(CryptoHash, Option<&Vec<u8>>)>) { | |||
pub fn update_cache(&self, ops: Vec<(CryptoHash, Option<&Vec<u8>>)>, shard_uid: ShardUId) { |
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.
Now I think that TrieCache
should hold shard_uid
, so we could avoid passing it here. Let's fix it in a separate PR
core/store/src/metrics.rs
Outdated
pub static SHARD_CACHE_TOO_LARGE: Lazy<IntCounterVec> = Lazy::new(|| { | ||
try_create_int_counter_vec( | ||
"near_shard_cache_too_large", | ||
"Shard cache too large", |
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.
"Shard cache too large", | |
"Number of too large values to be inserted into shard cache", |
core/store/src/trie/trie_storage.rs
Outdated
let shard_id_str = format!("{}", self.shard_uid.shard_id); | ||
let is_view_str = format!("{}", self.is_view as u8); | ||
let labels: [&str; 2] = [&shard_id_str, &is_view_str]; | ||
{ | ||
metrics::CHUNK_CACHE_SIZE | ||
.with_label_values(&labels) | ||
.set(self.chunk_cache.borrow().len() as i64); | ||
metrics::SHARD_CACHE_SIZE | ||
.with_label_values(&labels) | ||
.set(self.shard_cache.0.lock().expect(POISONED_LOCK_ERR).len() as i64); | ||
} |
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.
Let's separate it to fn update_cache_size_metrics()
for TrieCachingStorage
and drop extra curly braces
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.
Sorry, I forgot that we use labels
in this method below. Then the original code makes more sense
We decided to merge it with #7429, after finishing it we just close this one |
#742 is merged, should we close this? |
Part 1 of cache metrics for monitoring.
Related issue #7375