digitalocean / prometheus-client-c

A Prometheus Client in C
Other
160 stars 82 forks source link

Performance bottleneck on prom_map_get_index_internal #59

Open bjornleffler opened 3 years ago

bjornleffler commented 3 years ago

I used the Prometheus C client in a high performance network server application. Each server request increments a few prometheus counters (request count, bytes transferred, etc) and observes a few prometheus histograms (latency, request size, etc).

When I ran the cpu profiling from gperftools, I discovered that 24% of all cpu was spent inside the prom_map_get_index_internal function. See the attached screenshot for more details.

I've switched to another library, but wanted to let you know of my findings. Screen Shot 2021-08-27 at 10 40 29 am

bjornleffler commented 3 years ago

This bottleneck was noticeable from the monitoring. As the server load (requests / second) increased, overall performance flat lined or even decreased.

When I switched libraries, the server performance improved. It could serve a much higher number of requests / second.

Hello71 commented 2 years ago

@bjornleffler which library did you switch to?

bjornleffler commented 2 years ago

I'm now using https://github.com/jupp0r/prometheus-cpp