[SERVER-82725] Improve the locking in ProfilerFilter::getDefault Created: 02/Nov/23  Updated: 24/Jan/24  Resolved: 08/Dec/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 7.3.0-rc0

Type: Task Priority: Critical - P2
Reporter: Mark Benvenuto Assignee: Zixuan Zhuang
Resolution: Fixed Votes: 0
Labels: perf-8.0, perf-tiger, perf-tiger-handoff, perf-tiger-poc, perf-tiger-q4, query-perf-q4
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Query Execution
Backwards Compatibility: Fully Compatible
Sprint: QE 2023-11-27, QE 2023-12-11
Participants:

 Description   

ProfilerFilter::getDefault/setDefault uses a global mutex to protect a shared pointer. C++20 adds support for atomic shared_ptr's but our toolchain v4 compilers do not yet support it. ProfilerFilter is rarely set. It is accessed during a findOne() twice: once in FindCommand::run() and HandleRequest::onSuccess

Ideally, a cheap memory reclamation technology like hazard pointers could be used to protect writes to this shared pointer. But since that does not exist in the code base, an alternative is to use a partitioned reader/writer lock so that all the readers do not have to touch the same cache line for taking the reader/writer lock.

POC: https://github.com/10gen/mongo/commit/3c3d7ae8ec93db1ebbb3da3f97f57235c71f5f1e#diff-f0fe17da91208fde2e16908d4a000ed3e3ca11d0dc2036036e37680b91ff5af6



 Comments   
Comment by Githook User [ 08/Dec/23 ]

Author:

{'name': 'zixuan zhuang', 'email': 'zixuan.zhuang@mongodb.com', 'username': 'leozzx'}

Message: SERVER-82725 Use RWLock in ProfilerFilter

GitOrigin-RevId: 512c4489d747dfcdf997d71f7c162370c22fe5b6
Branch: master
https://github.com/mongodb/mongo/commit/3a8f627603464b184b7bd77b7ef027c87383180f

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