-
Type:
Task
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Performance
-
None
Context
PYTHON-5672 eliminates three generator frames from the checkout path. The next bottleneck is lock granularity.
Topology lock: topology.select_server() holds a single coarse lock for the entire selection loop, serializing every concurrent checkout even when a suitable server is already cached. Replace it with a reader/writer pattern: reads of topology.description hold only a shared read lock; the write lock is acquired only during monitor updates (topology mutations). This is the same approach used in the Java and Go drivers.
Pool lock merging: _get_conn() }}acquires two back-to-back locks on the fast path ({{operation_count then active_sockets). Merge into one acquire to remove ~50–150 ns per checkout.
Definition of done
Locks are optimized, CMAP, SDAM, and unified-format spec tests pass, concurrent throughput under 10+ parallel checkouts improves measurably.
Pitfalls
Ensure we are not introducing undo complexity.
- depends on
-
PYTHON-5672 Refactor connection checkout to reduce layers
-
- Blocked
-