Skip to content

Commit 4de1fa7

Browse files
perf(metrics): restore IndexMap for unbounded MetricSet to fix CPU regression
1 parent c5959d7 commit 4de1fa7

2 files changed

Lines changed: 201 additions & 71 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Fixed a CPU regression introduced in 0.50.0 affecting all sinks that use metric normalization (e.g. `prometheus_remote_write`, `aws_cloudwatch_metrics`, `statsd`). The `MetricSet` used to normalize metrics was changed from `IndexMap` to `LruCache` to support the new `incremental_to_absolute` transform's capacity eviction feature. However, `LruCache::get_mut` unconditionally updates LRU bookkeeping (pointer manipulation in a doubly-linked list) on every metric lookup, even when no capacity eviction policy is configured. For high-throughput metrics pipelines this overhead accumulates on the hot path for every metric event.
2+
3+
`MetricSet` now uses `IndexMap` internally when no capacity policy is configured (the common case), and only switches to `LruCache` when `max_bytes` or `max_events` limits are set. This restores pre-0.50.0 performance for all sinks using the default unbounded metric state while preserving correct LRU eviction ordering for the `incremental_to_absolute` transform.
4+
5+
authors: thomasqueirozb

0 commit comments

Comments
 (0)