-
Notifications
You must be signed in to change notification settings - Fork 539
Reduce lock contention in SyncMetricStorage for concurrent metric recording #3927
Copy link
Copy link
Open
Labels
bugSomething isn't workingSomething isn't workingtriage/acceptedIndicates an issue or PR is ready to be actively worked on.Indicates an issue or PR is ready to be actively worked on.
Description
SyncMetricStorage guards every RecordLong/RecordDouble call with a single SpinLockMutex over the entire AttributesHashMap. When multiple threads share one instrument, all measurements serialize on this lock — including the heavy MetricAttributes construction from KeyValueIterable.
The BM_MeasurementsThreadsShareCounterTest benchmark confirms this: shared-counter throughput is significantly worse than per-thread counters.
The lock granularity could be improved.
References
- Lock site:
sync_metric_storage.h AttributesHashMap:attributes_hashmap.hSpinLockMutex:spin_lock_mutex.h
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingtriage/acceptedIndicates an issue or PR is ready to be actively worked on.Indicates an issue or PR is ready to be actively worked on.