PromPHP / prometheus_client_php

Prometheus instrumentation library for PHP applications
https://prometheus.io/docs/concepts/metric_types/
Apache License 2.0
415 stars 91 forks source link

Eliminate wlocks when updating existing histograms, gauges #116

Closed TobiasBengtsson closed 1 year ago

TobiasBengtsson commented 1 year ago

apcu_add always takes a wlock in the current version 5.1.22, which leads to lots of lock contention in high concurrency scenarios. Since the most common operation ought to be updating an already existing key, wrap apcu_add in an apcu_exists that only takes a rlock.

LKaemmerling commented 1 year ago

Thank you! Good catch