Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

feat: instrument cache hit and misses #208

Merged
merged 6 commits into from
Nov 9, 2021

Conversation

Dexterp37
Copy link
Contributor

Note: this is based on #205 and will need to be rebased after that gets merged.

This additionally adds a metric to track the number of items in the in-memory cache. Note that this does not add the same count of items for the Redis cache, as it's slightly more involved there and I'd take it as a separate, specific PR.

This contributes toward #207 , but follow-up work is required to fix it.

@Dexterp37 Dexterp37 requested a review from a team as a code owner November 9, 2021 11:33
@Dexterp37 Dexterp37 self-assigned this Nov 9, 2021
merino-cache/src/memory.rs Outdated Show resolved Hide resolved
merino-cache/src/memory.rs Outdated Show resolved Hide resolved
this additionally adds a metric to track the number
of items in the in-memory cache.
@mythmon mythmon mentioned this pull request Nov 9, 2021
22 tasks
mythmon
mythmon previously requested changes Nov 9, 2021
@@ -174,6 +176,13 @@ impl Suggester {
?removed_storage,
"finished removing expired entries from cache"
);

metrics_client
.count("cache.memory.storage_len", items.len_storage() as i64)
Copy link
Contributor

Choose a reason for hiding this comment

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

I missed this the first time, but this needs to be metrics_client.gauge, not .count. That's because count is equivalent to incr, but with a larger step. (more specifically, incr is count with n = 1). With count we'd end up with a graph of the integral of the cache size overtime, which definitely isn't what we want.

.take(2)
.map(|x| String::from_utf8(x).unwrap())
.collect();
assert!(collected_data.contains(&"merino-test.cache.memory.storage_len:1|c".to_string()));
Copy link
Member

Choose a reason for hiding this comment

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

needs updating per the gauge type

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, right. thanks.

docs/data.md Outdated
Comment on lines 120 to 124
- `cache.memory.pointers-len` - A counter representing the number of entries in
the first level of hashing in the in-memory deduped hashmap.

- `cache.memory.storage-len` - A counter representing the number of entries in
the second level of hashing in the in-memory deduped hashmap.
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
- `cache.memory.pointers-len` - A counter representing the number of entries in
the first level of hashing in the in-memory deduped hashmap.
- `cache.memory.storage-len` - A counter representing the number of entries in
the second level of hashing in the in-memory deduped hashmap.
- `cache.memory.pointers-len` - A gauge representing the number of entries in
the first level of hashing in the in-memory deduped hashmap.
- `cache.memory.storage-len` - A gauge representing the number of entries in
the second level of hashing in the in-memory deduped hashmap.

@mythmon mythmon dismissed their stale review November 9, 2021 19:45

passing review to phil

@mythmon mythmon enabled auto-merge (squash) November 9, 2021 19:45
@mythmon mythmon merged commit 3df72ed into mozilla-services:main Nov 9, 2021
@Dexterp37 Dexterp37 deleted the consvc-1354 branch November 10, 2021 08:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants