So, I have a few questions that I have to ask, I did browse the internet, but there weren't too many reliable answers. Mostly blog posts that would cancel each-other out because they both praised different things and had benchmarks to "prove their viewpoint" (I have never seen so many contradicting benchmarks in my life).
所以,我有几个问题要问,我确实浏览了互联网,但是没有太多可靠的答案。大多数的博客文章会取消彼此之间的联系,因为他们都称赞不同的东西,并且有基准来“证明他们的观点”(我这辈子还没见过这么多自相矛盾的基准)。
Anyway, my questions are:
不管怎样,我的问题是:
- Is Rubinius really faster? I was pretty impressed by this apparently honest pro-Rubinius presentation. Another thing that confuses me a little is that a lot of Rubinius is written in Ruby itself, yet somehow it is faster than C-Ruby? It must be a pretty damn good implementation of the language, then!
- Rubinius真的快吗?我对这个明显诚实的亲鲁宾派演讲印象深刻。另一件让我困惑的事情是,很多Rubinius都是用Ruby编写的,但是它的速度比C-Ruby快吗?那一定是语言的一个很好的实现,然后!
- Does EventMachine work with Ruinius? As far as I know, EventMachine partially relies on Fibers (correct me if I'm wrong) which weren't implemented until 1.9. I know Rubinius will eventually support 1.9, too; I don't mind waiting a little.
- EventMachine是否与Ruinius兼容?据我所知,EventMachine部分依赖于纤程(如果我错了请纠正我),而纤程直到1.9才实现。我知道Rubinius最终也会支持1.9;我不介意等一会儿。
- Do C extensions work in Rubinius? I have written a C extension which "serializes" binary messages received from a TCP stream into Ruby Objects and vice-versa (I suppose the details are not important, but if it helps answer this question I will update the post). This can be a lot of messages! I managed to write the same code in Ruby (although, it made little sense after a month), but it proved to be a real bottle-neck in the application. So, I had to use C as a "solution" to my problem. EDIT: I just remembered, I use C for another task, it is a hit-test method for Arrays. Basically it just checks if a "point" is inside an a polygon, it was impossibly slow in CRuby.
- C扩展在Rubinius是否有效?我编写了一个C扩展,它将从TCP流接收的二进制消息“序列化”到Ruby对象,反之亦然(我认为细节并不重要,但如果它有助于回答这个问题,我将更新本文)。这可以是很多信息!我设法用Ruby编写了相同的代码(虽然,一个月后它没有什么意义),但它在应用程序中被证明是真正的瓶颈。所以,我必须用C作为我的问题的“解决方案”。编辑:我刚想起,我用C做另一个任务,它是数组的命中测试方法。基本上,它只是检查一个“点”是否在一个多边形内,它在CRuby是不可能的慢。
- If the previous answer was a "No," is there then an alternative for C extensions in Rubinus? I gather the VM is written in C++, so that then.
- 如果之前的答案是“不”,那么在Rubinus中有C扩展的替代方案吗?我估计VM是用c++写的,所以。
A few "bonus" questions:
几个“奖金”的问题:
- Will C-Ruby (2.0+, YARV) ever get rid of GIL? Or at least modify it so CRuby supports true parallelism?
- C-Ruby (2.0+, YARV)会摆脱GIL吗?或者至少修改一下,让CRuby支持真正的并行性?
- What is exactly mruby? I see matz is working on it, and as far as the description goes it seems pretty awesome. How different is it from CRuby (performance-wise)?
- mruby到底是什么?我看到matz正在研究它,就描述而言,它看起来非常棒。它与CRuby(性能方面的)有何不同?
I apologize for this text-storm I unleashed upon you! ♥
我为我对你的短信风暴道歉!♥
2 个解决方案
#1
21
Is Rubinius really faster?
Rubinius真的快吗?
In most benchmarks, yes.
在大多数基准,是的。
But benchmarks are... dumb. Apps are what we really care about. So the best thing to do is benchmark your app & see how well it performs. The 2 areas where Rubinius will real shine over MRI are parallelism & memory usage. Rubinius has no GIL, so you can utilize all available threads. It also has a much more sophisticated GC, so in general it could perform better with respect to GC.
但基准…愚蠢的。应用是我们真正关心的。所以最好的办法就是给你的应用做基准测试,看看它的表现如何。Rubinius在核磁共振成像中真正闪耀的两个区域是并行性和内存使用。Rubinius没有GIL,所以你可以利用所有可用的线程。它还有一个更复杂的GC,所以总的来说,它可以在GC方面表现得更好。
I did those benchmarks back in Oct '11 for my talk on MagLev at RubyConf
10月11日,我在RubyConf的MagLev上做了这些基准测试。
Does EventMachine work with Rubinius?
EventMachine与Rubinius合作吗?
Yes, and if there are parts that don't work, then the issue should be reported. With that said, currently the EM tests don't pass on any Ruby implementation.
是的,如果有些部件不能正常工作,那么就应该报告这个问题。尽管如此,目前EM测试并没有通过任何Ruby实现。
Do C extensions work in Rubinius?
C扩展在Rubinius是否有效?
Yes. I maintain the compatibility issue for C-exts, so if there is one you have that is tested on Travis, Rubinius would like to see it pass against rbx. Rubinius has historically had good support for the C-api and C-exts, though it would be nice if someday Rubinius could run Ruby so fast one would not need C-exts or the C-api.
是的。我维护了C-exts的兼容性问题,所以如果您有一个在Travis上测试过的,Rubinius希望看到它通过rbx。Rubinius在历史上对C-api和C-exts有很好的支持,但是如果有一天Rubinius能够运行Ruby那么快,那么它就不需要C-exts或C-api了。
Will C-Ruby (2.0+, YARV) ever get rid of GIL? Or at least modify it so CRuby supports true parallelism?
C-Ruby (2.0+, YARV)会摆脱GIL吗?或者至少修改一下,让CRuby支持真正的并行性?
No, most likely not. Jesse Storimer has a succinct writeup of Matz's opinion (or lack thereof) on threads from RubyConf 2012. Koichi Sasada tried to remove the GIL once and MRI perf just tanked. Evan Phoenix also tried once, before he created Rubinius, but didn't have good results.
不,很可能不是。杰西·斯多雷默(Jesse Storimer)对《RubyConf 2012》中马茨的观点(或缺乏这些观点)进行了简洁的评述。小佐田光一试着摘除GIL,而核磁共振检查结果刚刚好。埃文·菲尼克斯在创造Rubinius之前也试过一次,但结果并不好。
What is exactly mruby?
mruby到底是什么?
An embeddable Ruby interpreter, akin to Lua. Matt Aimonetti has a few articles that might shed some light for you.
一个可嵌入的Ruby解释器,类似于Lua。Matt Aimonetti有几篇文章可能会对你有所启发。
#2
4
I am not too much into Ruby but I might be able to answer the first question.
我不太喜欢Ruby,但我可能可以回答第一个问题。
Is Rubinius really faster?
Rubinius真的快吗?
I've seen different Benchmarks telling different things. However, the fact that Rubinius is partially written in Ruby does not have to mean that it is slower. I thought the same about PyPy which is Python in Python. After some research and the right classes in college I knew why.
我看到不同的基准测试不同的东西。然而,Rubinius是部分用Ruby编写的这一事实并不意味着它会更慢。我对PyPy也有同样的想法,PyPy是Python中的Python。在大学里做了一些研究,上了合适的课之后,我知道了原因。
- As far as I know both are written in a subset of their language which should be much simpler. An (e.g. C) interpreter can be be optimized much easier for such a subset than the whole language.
- 据我所知,这两种语言都是用他们语言的一个子集写成的,应该要简单得多。一个(例如C)解释器对于这样的子集比整个语言更容易优化。
- Writing the Ruby/Python interpreter in its own language allows much more flexibility and quicker prototyping of new interpretation algorithms. The whole point of the existence of Ruby and Python are among others that algorithms can be implemented much quicker than in e.g. C or even assembler. A faster algorithm outweighs the little overhead of an interpreter a lot of the time.
- 用自己的语言编写Ruby/Python解释器可以使新的解释算法更灵活、更快地原型化。Ruby和Python的存在的全部意义在于,算法的实现速度要比例如C、甚至汇编语言快得多。在很多情况下,更快的算法比解释器的开销更大。
Btw. writing an interpreter for a language in the same language is also a common academic practice to show how mighty the language is. In one class we've written Lisp in Lisp in Lisp.
顺便说一句。在同一种语言中为一种语言编写翻译也是一种常见的学术实践,以显示语言的强大。在一个类中,我们用Lisp写Lisp。
#1
21
Is Rubinius really faster?
Rubinius真的快吗?
In most benchmarks, yes.
在大多数基准,是的。
But benchmarks are... dumb. Apps are what we really care about. So the best thing to do is benchmark your app & see how well it performs. The 2 areas where Rubinius will real shine over MRI are parallelism & memory usage. Rubinius has no GIL, so you can utilize all available threads. It also has a much more sophisticated GC, so in general it could perform better with respect to GC.
但基准…愚蠢的。应用是我们真正关心的。所以最好的办法就是给你的应用做基准测试,看看它的表现如何。Rubinius在核磁共振成像中真正闪耀的两个区域是并行性和内存使用。Rubinius没有GIL,所以你可以利用所有可用的线程。它还有一个更复杂的GC,所以总的来说,它可以在GC方面表现得更好。
I did those benchmarks back in Oct '11 for my talk on MagLev at RubyConf
10月11日,我在RubyConf的MagLev上做了这些基准测试。
Does EventMachine work with Rubinius?
EventMachine与Rubinius合作吗?
Yes, and if there are parts that don't work, then the issue should be reported. With that said, currently the EM tests don't pass on any Ruby implementation.
是的,如果有些部件不能正常工作,那么就应该报告这个问题。尽管如此,目前EM测试并没有通过任何Ruby实现。
Do C extensions work in Rubinius?
C扩展在Rubinius是否有效?
Yes. I maintain the compatibility issue for C-exts, so if there is one you have that is tested on Travis, Rubinius would like to see it pass against rbx. Rubinius has historically had good support for the C-api and C-exts, though it would be nice if someday Rubinius could run Ruby so fast one would not need C-exts or the C-api.
是的。我维护了C-exts的兼容性问题,所以如果您有一个在Travis上测试过的,Rubinius希望看到它通过rbx。Rubinius在历史上对C-api和C-exts有很好的支持,但是如果有一天Rubinius能够运行Ruby那么快,那么它就不需要C-exts或C-api了。
Will C-Ruby (2.0+, YARV) ever get rid of GIL? Or at least modify it so CRuby supports true parallelism?
C-Ruby (2.0+, YARV)会摆脱GIL吗?或者至少修改一下,让CRuby支持真正的并行性?
No, most likely not. Jesse Storimer has a succinct writeup of Matz's opinion (or lack thereof) on threads from RubyConf 2012. Koichi Sasada tried to remove the GIL once and MRI perf just tanked. Evan Phoenix also tried once, before he created Rubinius, but didn't have good results.
不,很可能不是。杰西·斯多雷默(Jesse Storimer)对《RubyConf 2012》中马茨的观点(或缺乏这些观点)进行了简洁的评述。小佐田光一试着摘除GIL,而核磁共振检查结果刚刚好。埃文·菲尼克斯在创造Rubinius之前也试过一次,但结果并不好。
What is exactly mruby?
mruby到底是什么?
An embeddable Ruby interpreter, akin to Lua. Matt Aimonetti has a few articles that might shed some light for you.
一个可嵌入的Ruby解释器,类似于Lua。Matt Aimonetti有几篇文章可能会对你有所启发。
#2
4
I am not too much into Ruby but I might be able to answer the first question.
我不太喜欢Ruby,但我可能可以回答第一个问题。
Is Rubinius really faster?
Rubinius真的快吗?
I've seen different Benchmarks telling different things. However, the fact that Rubinius is partially written in Ruby does not have to mean that it is slower. I thought the same about PyPy which is Python in Python. After some research and the right classes in college I knew why.
我看到不同的基准测试不同的东西。然而,Rubinius是部分用Ruby编写的这一事实并不意味着它会更慢。我对PyPy也有同样的想法,PyPy是Python中的Python。在大学里做了一些研究,上了合适的课之后,我知道了原因。
- As far as I know both are written in a subset of their language which should be much simpler. An (e.g. C) interpreter can be be optimized much easier for such a subset than the whole language.
- 据我所知,这两种语言都是用他们语言的一个子集写成的,应该要简单得多。一个(例如C)解释器对于这样的子集比整个语言更容易优化。
- Writing the Ruby/Python interpreter in its own language allows much more flexibility and quicker prototyping of new interpretation algorithms. The whole point of the existence of Ruby and Python are among others that algorithms can be implemented much quicker than in e.g. C or even assembler. A faster algorithm outweighs the little overhead of an interpreter a lot of the time.
- 用自己的语言编写Ruby/Python解释器可以使新的解释算法更灵活、更快地原型化。Ruby和Python的存在的全部意义在于,算法的实现速度要比例如C、甚至汇编语言快得多。在很多情况下,更快的算法比解释器的开销更大。
Btw. writing an interpreter for a language in the same language is also a common academic practice to show how mighty the language is. In one class we've written Lisp in Lisp in Lisp.
顺便说一句。在同一种语言中为一种语言编写翻译也是一种常见的学术实践,以显示语言的强大。在一个类中,我们用Lisp写Lisp。