[SERVER-78960] Investigate if CounterMetric can do increment using fetchAndAddRelaxed for better performance Created: 13/Jul/23  Updated: 14/Jul/23  Resolved: 14/Jul/23

Status: Closed
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: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-78959 Investigate if CounterMetric can do i... Open
Assigned Teams:
Service Arch
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.