免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 5590 | 回复: 1
打印 上一主题 下一主题

[MongoDB] MongoDB Ruby 客户端升级,性能大幅提升 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-02-22 18:39 |只看该作者 |倒序浏览
MongoDB Ruby 客户端升级,性能大幅提升




最近MongoDB的Ruby客户端进行了一次升级,主打性能增强,官方的benchmark显示速度达原来的2倍左右。下面是其官方原文及benchmark:

原地址:http://github.com/mongodb/mongo-ruby-driver/pull/3

The Ruby driver was quite inefficient with handling data. Strings (read from the network or passed by the user) were being unpacked into arrays all over the place and vice versa. We’ve modified the driver to work with strings instead of byte arrays as much as possible. Most notably: ByteBuffer has been rewritten to use a binary string as underlying storage object instead of an array.

The Ruby 1.8 implementation of BSON::OrderedHash was inefficient: it uses a Set even though it’s not necessary. We removed the dependency on Set and greatly improved OrderedHash’s 1.8 performance.

The end result is a driver that’s 274% faster on Ruby 1.8 and 204% faster on Ruby 1.9. We used the following benchmark:

requests = Mongo::Connection.new.db('foobar').collection('requests')
query = { :_id => "6d61bbc7e32795e7ace8b98e8e83961cb8e3ee53" }
40000.times do
    requests.find(query, :limit => -1) do |cursor|
        cursor.next_document
    end
endOriginal runtime: 74.0s (Ruby 1. / 33.9s (Ruby 1.9)
New runtime: 25.8s (Ruby 1. / 16.7s (Ruby 1.9)


论坛徽章:
0
2 [报告]
发表于 2012-02-24 17:27 |只看该作者
谢谢分享
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP