Skip to content
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

Closed
wants to merge 3 commits into from

Conversation

firatNEAR
Copy link
Contributor

Part 1 of cache metrics for monitoring.
Related issue #7375

@firatNEAR firatNEAR requested a review from a team as a code owner August 18, 2022 16:19
@firatNEAR firatNEAR requested a review from matklad August 18, 2022 16:19
@firatNEAR firatNEAR changed the title Introduce Cache related metrics for prometheus feat/introduce cache related metrics for prometheus Aug 18, 2022
@firatNEAR firatNEAR linked an issue Aug 18, 2022 that may be closed by this pull request
@@ -43,10 +46,20 @@ impl TrieCache {
guard.put(hash, value.into());
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
} 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) {
Copy link
Member

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

pub static SHARD_CACHE_TOO_LARGE: Lazy<IntCounterVec> = Lazy::new(|| {
try_create_int_counter_vec(
"near_shard_cache_too_large",
"Shard cache too large",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"Shard cache too large",
"Number of too large values to be inserted into shard cache",

Comment on lines 255 to 265
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);
}
Copy link
Member

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

Copy link
Member

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

@Longarithm
Copy link
Member

We decided to merge it with #7429, after finishing it we just close this one

@matklad
Copy link
Contributor

matklad commented Aug 29, 2022

#742 is merged, should we close this?

@Longarithm Longarithm closed this Aug 29, 2022
@Ekleog-NEAR Ekleog-NEAR deleted the feat/add_storage_metrics branch March 29, 2024 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create metrics for shard/chunk cache part1
3 participants