Skip to content

High memory allocation in prometheus.MakeLabelPair #1702

Open
@jkroepke

Description

@jkroepke

While investigate memory leak with windows_exporter, I figure out that there is a decent memory allocation rate in prometheus.MakeLabelPairs.

windows_exporter (like node_exporter) generate a high amount of ConstMetrics on each scrape call. The process collector expose around 6200 metrics on each call, resulting in 6200 MustNewConstMetric calls on each scrape.

I ask myself, if this can be optimized somehow. The heap dump is generate after 1 days of runtime, with 5 seconds scrape interval (to simulate a long running scenario)

the dto.LabelPair struct contains other struct related to protobuf. Not sure, if they needed. Prometheus 2.0 does not support protobuf metris scrape, it feels like an expensive leftover.


Flame Graph:
2024-12-25 18_49_20-20 101 113 87_3389 - Remotedesktopverbindung

Source View:
2024-12-25 18_51_46-20 101 113 87_3389 - Remotedesktopverbindung

Heap Dump via pprof: memory_profile_windows.pb.gz

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions