I have a choice to develop an app which will rely heavily on threading (up to to 200). I know I can use other Ruby interpreters for threading such as JRuby. But there are 2 things:
我可以选择开发一个严重依赖线程的应用程序(最多200个)。我知道我可以使用其他Ruby解释器来处理线程,例如JRuby。但有两件事:
1) Jruby doesn't support 1.9 yet, so that is a no. Is there any other non-green thread interpreter that supports at least 1.9 as that is a prerequisite for me if I use Ruby.
1)Jruby尚不支持1.9,所以这是一个不。是否有任何其他非绿色线程解释器支持至少1.9,因为如果我使用Ruby,这是我的先决条件。
2) Even using an interpreter such as Jruby, would I really get decent thread perfomance that I can get in Java? Perhaps I should just use Java for this application.
2)即使使用像Jruby这样的解释器,我是否真的能获得可以用Java获得的不错的线程性能?也许我应该只为这个应用程序使用Java。
Note: this isn't an attempt at subjective discussion. It is for advice regarding thread performance only. Also, this isn't Java vs Ruby or anything of that nature. I am newer to Ruby and hoping to clear this up for my own benefit, thanks.
注意:这不是主观讨论的尝试。它仅用于有关线程性能的建议。此外,这不是Java vs Ruby或其他任何性质。我是Ruby的新手,希望为了自己的利益清除它,谢谢。
1 个解决方案
#1
6
You should really benchmark it.
你应该对它进行基准测试。
Are your threads going to be doing a lot of simultaneous computation? Then you'd probably need native threads. But if you are going to be waiting for IO all the time, then maybe Ruby's green threads are fine.
您的线程是否会进行大量的同步计算?那么你可能需要原生线程。但是如果你要一直等待IO,那么Ruby的绿色线程可能就好了。
Even with this advice, you should cook up a small test program and see if the straightforward way (just using Ruby 1.9) will work.
即使有了这个建议,你也应该做一个小的测试程序,看看直接的方式(只使用Ruby 1.9)是否有效。
#1
6
You should really benchmark it.
你应该对它进行基准测试。
Are your threads going to be doing a lot of simultaneous computation? Then you'd probably need native threads. But if you are going to be waiting for IO all the time, then maybe Ruby's green threads are fine.
您的线程是否会进行大量的同步计算?那么你可能需要原生线程。但是如果你要一直等待IO,那么Ruby的绿色线程可能就好了。
Even with this advice, you should cook up a small test program and see if the straightforward way (just using Ruby 1.9) will work.
即使有了这个建议,你也应该做一个小的测试程序,看看直接的方式(只使用Ruby 1.9)是否有效。