-
Type: Task
-
Resolution: Unresolved
-
Priority: Unknown
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
Context
Running a simple command like database.command('ping') shows that about 35% of the time is spent in acquiring a server and a connection. This limits the ability to use the driver for things like throughput tests.
I created this gist to demonstrate the overhead.
Before patching client._select_server, I see the following times for 10000 pings:
command: 1.12
_command: 0.77
After patching client._select_server, I see:
command: 0.86
_command: 0.77
I then ran cProfile against 100000 iterations of the non-patched command call to verify where the time was spent. _select_server took 15% of the runtime and checking out a connection took about 20% of the runtime, while db._command was 65% of the runtime.
We could consider adding an API to get a connection object and then provide it to calls for cases where there is a known topology and a single thread.
Definition of done
Investigate whether improvements could be made to idle time for small reads, or if we can/should create an API to use an explicit connection object.
Pitfalls
We want to ensure that we remain spec-compliant and thread safe.
- related to
-
PYTHON-4779 Use slots for Selection and TopologyDescription
- Backlog
-
PYTHON-4780 Implement fast path for server selection with Primary()
- Backlog