What practical effect will different Ruby threading models (Ruby vs JRuby) have on your code as a developer?

后端 未结 3 697
傲寒
傲寒 2021-01-05 06:24

I\'m trying to understand the practical impact of different threading models between MRI Ruby 1.8 and JRuby.

What does this difference mean to me as a developer?

3条回答
  •  走了就别回头了
    2021-01-05 07:06

    JRuby's threads are native system threads, so they give you all the benefits of threaded programming (including the use of multiple processor cores, if applicable). However, Ruby has a Global Interpreter Lock (GIL), which prevents multiple threads from running simultaneously. So the only real performance difference is the fact that your MRI/YARV Ruby applications won't be able to utilize all of your processor cores, but your JRuby applications will happily do so.

    However, if that isn't an issue, MRI's threads are (theoretically, I haven't tested this) a little faster because they are green threads, which use fewer system resources. YARV (Ruby 1.9) uses native system threads.

提交回复
热议问题