You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Previously, we were persisting label value slice at each child metrics of
aggregated metric type. This was inadequate because it will create redundant
memory allocations for same label value slice across difference metrics. To
address this, this patch introduces `LabelSliceCache` which would persist the
label values at registry level and metrics would reference them through the
key. The LabelSliceCache is referenced in metrics through `PrometheusEvictable`
interface. The LabelSliceCache contains 2 critical methods:
1. Upsert: This method implements the "add reference" part of the
reference counting mechanism. This method increments the reference count for
label values by 1, if already exists. Otherwise, It will create a new entry for
the label values with default value as 1.
2. DecrementAndDeleteIfZero: This method decrements the reference
counter for the given label values by 1. If the count is reached to zero then
it means that no metrics are relying on the particular label values. In that
case, it deletes the entry from cache.
These methods ensure that the cache tracks how many metrics are currently using
each label combination, enabling proper cleanup when metrics are no longer
needed.
Epic: CRDB-53398
Part of: CRDB-53830
Release note: None
0 commit comments