Closed tammofreese closed 6 years ago
I don't think benchmarking sync and async operations in the same event loop is a great idea, but I don't see why that would be throwing off the results here. My guess at first glance is this is probably a bug.
Found it! The problem is in connection.rb:
if @buffer.more?
remaining_bytes= @buffer.size-@buffer.position
@buffer = BSON::ByteBuffer.new(@buffer.to_s[@buffer.position,remaining_bytes])
@buffer.rewind
else
@buffer.clear
end
If there is more data available, the buffer is always recreated, even if the position in the buffer is 0 and the recreation is not needed. For bigger data, this problem gets worse by n*2. I just pushed a fix and will send you a pull request next.
Done with #42
When trying to switch from mongo to em-mongo, I think I discovered a performance issue when handling documents that contain field bigger than 1 kilobyte. The script below takes a size in bytes as argument, inserts 1000 documents with a data field that has the given size, and logs the time loading these documents takes with mongo and em-mongo.
Here are the results I get on my MacBook Air (Core 2 Duo 1.6 Ghz):
As you can see, em-mongo needs quite a lot of time when the documents get bigger. Is this a bug, or have I done something wrong in the code?