Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-4113

Reduce contention on multithreaded session pool

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 1.20.0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      The session_pool in mongoc_topology_t is shared between threads and guarded by mongoc_topology_t::mutex, which is also locked by numerous other operations.

      When a session is requested from the pool, the requesting thread will lock the mutex and loop through every entry in the pool and remove sessions that are alive past their timeout. This can extremely produce latency as the pool grows. Because the same mutex is shared by multiple (some unrelated) operations, this operation blocks almost all clients.

      The process of dropping expired sessions need not be performed every single time we want a session from the pool, and holding the lock while performing this garbage collection is extremely detrimental.

            Assignee:
            colby.pike@mongodb.com Colby Pike
            Reporter:
            colby.pike@mongodb.com Colby Pike
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: