Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make APCng updateGauge with set command lock-free in critical path
When setting a value on a gauge, first apcu_store is called in updateGauge and then apcu_add is called in storeMetadata. Both of these operations takes a write lock in APCu which can cause contention. - Change updateGauge to use a compare-and-swap algorithm instead of apcu_store, unless we're adding something for the first time(s) in which case we just set it with apcu_store. - Don't call updateMetadata and storeLabelKeys unless it's the first time we're setting a gauge (matches the behaviour of inc/dec). - For extra safety, make a cheap rlock-only check in storeMetadata if the key exists before calling apcu_add with a wlock.
- Loading branch information