[CDRIVER-4113] Reduce contention on multithreaded session pool Created: 03/Aug/21 Updated: 28/Oct/23 Resolved: 13/Sep/21 |
|
| Status: | Closed |
| Project: | C Driver |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 1.20.0 |
| Type: | Improvement | Priority: | Unknown |
| Reporter: | Colby Pike | Assignee: | Colby Pike |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Epic Link: | Improve multi-threaded perf | ||||||||
| Description |
|
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. |
| Comments |
| Comment by Githook User [ 13/Sep/21 ] |
|
Author: {'name': 'vector-of-bool', 'email': 'vectorofbool@gmail.com', 'username': 'vector-of-bool'}Message:
|