mongodb/mongo-ruby-driver — pull request #309 by gjmurakami-10gen (2013-11-15 18:59:20+00:00)
Title: split #insert, refactor send_write, remove/delete with :limit

splitting #insert with single-document special case has a performance benefit, i.e., there's a measurable overhead directing a single-document through the batch execution path. Also, the new write commands execution path appears to be slower - note that measurements are for client CPU which is rate-limiting for Ruby, not wall clock.

secs:10.32, docs_per_sec:4983, max_wire_version:0, title:"insert_old huge single w:1"
secs:8.96, docs_per_sec:5740, max_wire_version:0, title:"insert_new huge single w:1"
secs:13.47, docs_per_sec:3818, max_wire_version:2, title:"insert_old huge single w:1"
secs:9.88, docs_per_sec:5205, max_wire_version:2, title:"insert_new huge single w:1"

The remove/delete :limit option was never previously implemented. It is a required field for the new "delete" write command. The bulk fluent API has *_one methods corresponding to :limit 1. The corresponding implementation with Collection#remove would be :limit => 1 with what is implemented here. The mongo shell uses justOne: true, but I think that the driver spec is different. If anyone has a quick reference at hand, that might save some lookup time.

RUBY-676