Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-5007

Investigate ways to improve performance of small read operations

    • Type: Icon: Task Task
    • Resolution: Unresolved
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Python Drivers
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      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.

            Assignee:
            Unassigned Unassigned
            Reporter:
            steve.silvester@mongodb.com Steve Silvester
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: