Performance gap between Ruby MRI and JRuby


(Nicola Mingotti) #1

Hi,

I just completed writing an application which substitutes FileBeat, for
our Elasticsearch stack.

I wrote it in Ruby 2.5.0, I considered it a good idea to move it under
JRuby because the server where it runs is not under my direct control.
Running it as JRuby would ensure me better protection against future
changes in the server software stack. The idea is: make a .jar of it and close the story
once and for all.

Since the Java env. running in the server is not the newest I can
run there at best JRuby 9.1.17.0 (Ruby 2.3.3).

The point is, when i compare the performance on the server, from "top"
i see this:

···

--------------------
⇒ Ruby → 20-30% CPU, 1% mem
⇒ MRI Ruby → 4% CPU (stable), 0.1% mem
--------------------

In your opinion, is the gap due to the older Ruby version ? Is it related to Java ?

Consier the code is the same, i simply run it either with "ruby" or "jruby".

bye
Nicola


(Nicola Mingotti) #2

For whoever may be using JRuby,

I was able to spot the reason why JRuby was eating much more resources
than MRI: Threads. I was using a library making extensive use of them, thousands.

Replacing the library with ad hoc code solved completely.

bye
n.

···

On 11/20/18 10:55 PM, Nicola Mingotti wrote:

Hi,

I just completed writing an application which substitutes FileBeat, for
our Elasticsearch stack.

I wrote it in Ruby 2.5.0, I considered it a good idea to move it under
JRuby because the server where it runs is not under my direct control.
Running it as JRuby would ensure me better protection against future
changes in the server software stack. The idea is: make a .jar of it and close the story
once and for all.

Since the Java env. running in the server is not the newest I can
run there at best JRuby 9.1.17.0 (Ruby 2.3.3).

The point is, when i compare the performance on the server, from "top"
i see this:
--------------------
⇒ Ruby → 20-30% CPU, 1% mem
⇒ MRI Ruby → 4% CPU (stable), 0.1% mem
--------------------

In your opinion, is the gap due to the older Ruby version ? Is it related to Java ?

Consier the code is the same, i simply run it either with "ruby" or "jruby".

bye
Nicola