grafana / alloy

OpenTelemetry Collector distribution with programmable pipelines
https://grafana.com/oss/alloy
Apache License 2.0
1.45k stars 214 forks source link

Reduce resource consumption of discovery components #1999

Open mattdurham opened 3 weeks ago

mattdurham commented 3 weeks ago

Reduce resource consumption of discovery components

Address high allocs in creation of targets lists

Targets/Discovery are represented as list(map[string]), with discovery running every 5 seconds in very large clusters the garbage collector can spike due to creating these labels. The names especially are repeated. The hard part is implementing the capsule value so hard coded targets still work. This is because in the alloy runtime there is a bug where you cannot convert from list/map to a capsule value.

In reviewing profiles this code was by far the largest allocator.

https://github.com/grafana/alloy/blob/5845b2ccacf65532b920406f5acae539dbfa8e00/internal/component/discovery/discovery.go#L212

Use case

Reduce memory and cpu consumption

thampiotr commented 3 days ago

@mattdurham I've re-purposed this issue for the work we've planned earlier this week.