Uploaded image for project: 'Ruby Driver'
  1. Ruby Driver
  2. RUBY-1212

Count performance degrades 2x starting in 2.3 driver

      When switching from 2.2.1 driver to 2.4.1 certain queries started to take significantly longer.
      I narrowed the problem down to the count method.

      In configuration with a replica set, calls to .count take twice as long to process as they did pre-2.3 driver.
      In tests with only one server, the problem was not presented. Due to this observation I believe the issue occurs somewhere in the server selection during count.
      Other operations, find, where, do not exhibit the same behaviour.

      I have attahed a file with two scripts, 2.2_test.sh and 2.3_test.sh.
      Extract the archive on a ruby 2.2.4 environment with Bundler and you should be able to run the shell scripts to reproduce similar results as below:

      This simple test, in an environment with 3 servers and an arbiter highlight the issue:
      The only change in these two tests is modifying the Gemfile.lock mongo driver between 2.2.7 and 2.30:

      (from the bundle console using the 2.2.7 driver)
      > cli = Mongo::Client.new('mongodb://user:pass@server:11701/database')
      => #<Mongo::Client:0x70176662644920 cluster=server:11701, server2:10987, server3:11015, server4:11701>
      > Benchmark.measure { 1.upto(100) { cli.command(

      {"count":"foo"}

      ) } }
      => #<Benchmark::Tms:0x007fa69591d5a0
      @cstime=0.0,
      @cutime=0.0,
      @label="",
      @real=1.6692429999820888,
      @stime=0.010000000000000009,
      @total=0.05999999999999983,
      @utime=0.04999999999999982>

      (from bundle console using the 2.3.0 driver)
      > cli = Mongo::Client.new('mongodb://user:pass@server:11701/database')
      => #<Mongo::Client:0x70327742040800 cluster=server:11701, server2:10987, server3:11015, server4:11701>
      production prod_demosphere@db-mongo-61[4] (main)> Benchmark.measure { 1.upto(100) { cli.command(

      {"count":"foo"}

      ) } }
      => #<Benchmark::Tms:0x007fecdcca6810
      @cstime=0.0,
      @cutime=0.0,
      @label="",
      @real=3.175779999990482,
      @stime=0.010000000000000009,
      @total=0.0700000000000005,
      @utime=0.0600000000000005>

        1. mongo_test_2.2vs2.3.tar.gz
          0.7 kB
          Nathaniel Muller

            Assignee:
            emily.stolfo Emily Stolfo
            Reporter:
            nmuller Nathaniel Muller
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: