[SERVER-78959] Investigate if CounterMetric can do increment using fetchAndAddRelaxed for better performance Created: 13/Jul/23  Updated: 31/Aug/23

Status: Open
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Wenbin Zhu Assignee: Backlog - Service Architecture
Resolution: Unresolved Votes: 0
Labels: perf
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by SERVER-78972 Increment the global writeConflict co... Blocked
Duplicate
is duplicated by SERVER-78960 Investigate if CounterMetric can do i... Closed
Assigned Teams:
Service Arch
Sprint: Service Arch Prioritized List
Participants:

 Description   

We record a lot of metrics in serverStatus that are of type CounterMetric. The increment() function of CounterMetric uses atomic fetch_add() which by default uses memory order std::memory_order_seq_cst that is expensive since it needs to synchronize cpu cores with memory fences. Since they are for metrics, it seems we can use fetchAndAddRelaxed instead which uses a relaxed memory ordering, to reduce the synchronization overheads.


Generated at Thu Feb 08 06:39:43 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.