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

Major performance regressions from Moped 2 to mongo-ruby-driver 2.2

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Blocker - P1 Blocker - P1
    • 2.2.0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      Running on Macbook Pro Retina, 2.3 GHz i7 with 16gb RAM on OSX 10.10.5 against a local MongoDB 2.6.5 instance.

      Performance seems much worse in mongo-ruby-driver than Moped 2.

      Using localhost with a single mongod behind a mongos. Collection is sharded on {_id: hashed}, testing against the same document in both scenarios.

      Update one:

      Here's Moped 2:
      2.2.1 :049 > puts(Benchmark.measure do
      2.2.1 :050 > 1000.times do
      2.2.1 :051 > User.collection.find(:_id => u.id).update(:$set => {:foo => "bar"})
      2.2.1 :052?> end
      2.2.1 :053?> end)
      0.340000 0.040000 0.380000 ( 0.608091)
      => nil
      2.2.1 :054 > puts(Benchmark.measure do
      2.2.1 :055 > 1000.times do
      2.2.1 :056 > User.collection.find(:_id => u.id).update(:$set => {:foo => "bar"})
      2.2.1 :057?> end
      2.2.1 :058?> end)
      0.390000 0.040000 0.430000 ( 0.660600)
      => nil
      2.2.1 :059 > puts(Benchmark.measure do
      2.2.1 :060 > 1000.times do
      2.2.1 :061 > User.collection.find(:_id => u.id).update(:$set => {:foo => "bar"})
      2.2.1 :062?> end
      2.2.1 :063?> end)
      0.340000 0.040000 0.380000 ( 0.619269)
      <code>

      Here's mongo-ruby-driver 2.2:

      <code>
      2.2.1 :002 > puts(Benchmark.measure do
      2.2.1 :003 > 1000.times do
      2.2.1 :004 > User.collection.find(:_id => u.id).update_one(:$set => {:foo => "bar"})
      2.2.1 :005?> end
      2.2.1 :006?> end)
      0.580000 0.080000 0.660000 ( 0.882487)
      => nil
      2.2.1 :007 > puts(Benchmark.measure do
      2.2.1 :008 > 1000.times do
      2.2.1 :009 > User.collection.find(:_id => u.id).update_one(:$set => {:foo => "bar"})
      2.2.1 :010?> end
      2.2.1 :011?> end)
      0.560000 0.070000 0.630000 ( 0.834886)
      => nil
      2.2.1 :012 > puts(Benchmark.measure do
      2.2.1 :013 > 1000.times do
      2.2.1 :014 > User.collection.find(:_id => u.id).update_one(:$set => {:foo => "bar"})
      2.2.1 :015?> end
      2.2.1 :016?> end)
      0.540000 0.070000 0.610000 ( 0.794423)
      <code>

      Just a simple find one:

      Moped 2:

      <code>
      2.2.1 :064 > puts(Benchmark.measure do
      2.2.1 :065 > 1000.times do
      2.2.1 :066 > User.collection.find(:_id => u.id).limit(1).entries.first
      2.2.1 :067?> end
      2.2.1 :068?> end)
      0.360000 0.030000 0.390000 ( 0.494093)
      => nil
      2.2.1 :069 > puts(Benchmark.measure do
      2.2.1 :070 > 1000.times do
      2.2.1 :071 > User.collection.find(:_id => u.id).limit(1).entries.first
      2.2.1 :072?> end
      2.2.1 :073?> end)
      0.320000 0.040000 0.360000 ( 0.443336)
      => nil
      2.2.1 :074 > puts(Benchmark.measure do
      2.2.1 :075 > 1000.times do
      2.2.1 :076 > User.collection.find(:_id => u.id).limit(1).entries.first
      2.2.1 :077?> end
      2.2.1 :078?> end)
      0.360000 0.040000 0.400000 ( 0.488459)
      => nil
      <code>

      mongo-ruby-driver 2.2:

      <code>
      2.2.1 :012 > puts(Benchmark.measure do
      2.2.1 :013 > 1000.times do
      2.2.1 :014 > User.collection.find(:_id => u.id).update_one(:$set => {:foo => "bar"})
      2.2.1 :015?> end
      2.2.1 :016?> end)
      0.540000 0.070000 0.610000 ( 0.794423)
      => nil
      2.2.1 :017 > puts(Benchmark.measure do
      2.2.1 :018 > 1000.times do
      2.2.1 :019 > User.collection.find(:_id => u.id).limit(1).entries.first
      2.2.1 :020?> end
      2.2.1 :021?> end)
      0.530000 0.060000 0.590000 ( 0.692157)
      => nil
      2.2.1 :022 > puts(Benchmark.measure do
      2.2.1 :023 > 1000.times do
      2.2.1 :024 > User.collection.find(:_id => u.id).limit(1).entries.first
      2.2.1 :025?> end
      2.2.1 :026?> end)
      0.580000 0.070000 0.650000 ( 0.763661)
      => nil
      2.2.1 :027 > puts(Benchmark.measure do
      2.2.1 :028 > 1000.times do
      2.2.1 :029 > User.collection.find(:_id => u.id).limit(1).entries.first
      2.2.1 :030?> end
      2.2.1 :031?> end)
      0.580000 0.060000 0.640000 ( 0.762495)
      <code>

            Assignee:
            durran.jordan@mongodb.com Durran Jordan
            Reporter:
            jonhyman Jon Hyman
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: