Improve the locking in ProfilerFilter::getDefault

XMLWordPrintableJSON

    • Query Execution
    • Fully Compatible
    • QE 2023-11-27, QE 2023-12-11
    • None
    • 0
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      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

              Assignee:
              Zixuan Zhuang
              Reporter:
              Mark Benvenuto
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Created:
                Updated:
                Resolved: