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.
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