Skip to content

Reduce lock contention in SyncMetricStorage for concurrent metric recording #3927

@ThomsonTan

Description

@ThomsonTan

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingtriage/acceptedIndicates an issue or PR is ready to be actively worked on.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions