I have a rails project that runs on MRI 1.9.2 implementation.
- MRI is implements Ruby in C. And JRuby implements Ruby specification
in
Java. If C is faster than java, it means MRI is faster than JRuby. Am I
Right?
- Also, regarding memory leaks, MRI leaks memory a lot. It takes my
server
box’s memory very quickly. Does replacing MRI with JRuby in the server
help?
Hello there! Answers below.
On Sat, Aug 20, 2011 at 12:27 PM, Anand M.
[email protected] wrote:
I have a rails project that runs on MRI 1.9.2 implementation.
- MRI is implements Ruby in C. And JRuby implements Ruby specification in
Java. If C is faster than java, it means MRI is faster than JRuby. Am I
Right?
C is often faster than Java, but not by a great deal. JRuby’s core
classes, written in Java, often outperform MRI’s C code because of
better memory management and the JVM’s excellent optimizing JIT
compilers.
In general, Ruby code should run faster on JRuby, since JRuby compiles
Ruby code to JVM bytecode, and the JVM compiles that bytecode to
native machine code, while MRI always interprets. Ruby core classes
may or may not be faster on JRuby depending on how well we’ve
written/optimized them compared to MRI, but in most cases they should
be faster too. So JRuby should be faster than MRI (faster than 1.8.7
for sure, faster than 1.9.2 most of the time).
- Also, regarding memory leaks, MRI leaks memory a lot. It takes my server
box’s memory very quickly. Does replacing MRI with JRuby in the server help?
If it’s actually a leak stemming from MRI itself, then switching to
JRuby would fix it. If it’s a third-party library that’s leaking, then
it could either be a problem with the library (in which case switching
to JRuby wouldn’t help) or a problem with how MRI runs the library
(where JRuby would theoretically run it better).
If you decide to attempt a move to JRuby, let us know! We like to help
and hear about successful migrations
ok … now I understand why JRuby will give me more performance.
I would like to move my project to JRuby. But there is a C extension I
use -
gbarcode, for generating barcodes. If there is a ruby alternative to
that
and all the other dependent gems work well in JRuby, I will switch.
Although I will try JRuby first in staging server for sometime
On Sat, Aug 20, 2011 at 11:05 PM, Charles Oliver N.
<[email protected]
2011/8/20 Anand M. [email protected]
- MRI is implements Ruby in C. And JRuby implements Ruby specification in
Java. If C is faster than java, it means MRI is faster than JRuby. Am I
Right?
Code execution speed depends on many factors and JVM can optimize and
deoptimize it at runtime. This sometimes yields better performance than
static C compilers can get (but usually only for long running
processes).
One of the biggest factors in Ruby Web application performance is
garbage
collection time. To put it politely, MRI garbage collector is known to
be
mediocre. JVM has multiple garbage collectors to choose from and some of
them are really advanced and tunable.
Instead of guessing, profile your application on both implementations
and
see for yourself (and do not just profile for 10 seconds, try 5-10
minutes).
- Also, regarding memory leaks, MRI leaks memory a lot. It takes my server
box’s memory very quickly. Does replacing MRI with JRuby in the server help?
What you are seeing is likely to be the infamous behavior of MRI to not
release memory it once allocated, to avoid allocation performance
effect.
JRuby will certainly be better in this regard.
MK
http://twitter.com/michaelklishin
On Sat, Aug 20, 2011 at 6:44 PM, Anand M.
[email protected] wrote:
ok … now I understand why JRuby will give me more performance.
I would like to move my project to JRuby. But there is a C extension I use -
gbarcode, for generating barcodes. If there is a ruby alternative to that
and all the other dependent gems work well in JRuby, I will switch.
Try barby: GitHub - toretore/barby: The Ruby barcode generator
On Sat, Aug 20, 2011 at 12:50 PM, aslak hellesoy
[email protected] wrote:
Try barby: GitHub - toretore/barby: The Ruby barcode generator
Nice, hadn’t seen that one. Death to C extensions!
thanks, I will checkout barby if it can replace good old gbarcode.
Anand
http://www.rubyinair.com
On Sat, Aug 20, 2011 at 11:20 PM, aslak hellesoy
ok, I will profile my app and see if JRuby will work for me.
On Sat, Aug 20, 2011 at 11:19 PM, Michael K. <
On 20 August 2011 20:08, Anand M. [email protected]
wrote:
ok, I will profile my app and see if JRuby will work for me.
let us know.