Repository navigation
Commit ff63b21
committed
perf(ingester): invalidate head postings cache per-label instead of per-metric
The head expanded postings cache previously keyed a per-metric "seed" into
the cache key, so creating or deleting any series for a metric invalidated
every cached entry for that metric name, even entries whose result could not
have changed.
Replace the seed with a per-(tenant, label) write counter. On series
create/delete each of the series' label counts is incremented. On creation, a cache entry
snapshots the counts of its matched labels and stays valid as
long as at least one tracked count is unchanged. Creating or deleting a series which matches
all of the tracked labels expires the cache entries.
Matchers that can match an absent label (e.g. foo!="x", foo=~".*") are
excluded from the snapshot since a matching series need not carry the label,
so they cannot vouch for an entry. Name-only queries fall back to the old
whole-metric behaviour via the __name__ count.
The counter array is shared across tenants and namespaced by userId; it is
uint32 (8MB) and read under the existing stripe locks. Adds a
reason="stale" value to the cache miss metric to distinguish count
invalidation from TTL expiry.
Signed-off-by: Kyle Stang <kylestng@amazon.com>1 parent b162b32 commit ff63b21
4 files changed
Lines changed: 405 additions & 105 deletions
File tree
- pkg
- ingester
- storage/tsdb
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6424 | 6424 | | |
6425 | 6425 | | |
6426 | 6426 | | |
6427 | | - | |
| 6427 | + | |
6428 | 6428 | | |
6429 | 6429 | | |
6430 | 6430 | | |
| |||
6925 | 6925 | | |
6926 | 6926 | | |
6927 | 6927 | | |
6928 | | - | |
| 6928 | + | |
6929 | 6929 | | |
6930 | | - | |
| 6930 | + | |
6931 | 6931 | | |
6932 | 6932 | | |
6933 | 6933 | | |
| |||
0 commit comments