As you read JRuby blog posts and other resources around the web, you may find references to JRuby’s compile.invokedynamic option, that as of continues to ship turned off by default.

So, why is it off? I asked the JRuby developers and here’s what they had to say about it:

…and here’s what Joe Kutner’s “Deploying with JRuby 9k” has to say about it:

The invokedynamic instruction promised great performance improvements for JRuby, but it turned out to improve only a few specific cases. […] for now, JRuby keeps this feature off by default. You may find it worthwhile to test your application with invokedynamic turned on. It’s possible you’ll see some performance gains depending on the kind of logic you have in your app.

So in some benchmarks it seems rather relevant, but others suggest than on production applications it may not be the way to go. So which is it?

To test it out, I decided to benchmark it with one of Talkdesk’s internal JRuby applications. This application (dubbed ciw) reads tasks from rabbitmq message queue, and communicates with another internal microservice in order to update or create new records based on the received data.

After warming up the application, I loaded 6000 tasks on the rabbitmq message queue and measured how long (in seconds) the application took to go through all the tasks and empty the queue. The tests were performed on a Core i7-6500U (2.5 GHz) with 8GB of RAM running Ubuntu Linux 16.10, and the JVM used was the Oracle Java(TM) SE Runtime Environment (build 1.8.0_121-b13) / Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode). The application was configured to use 16 threads to process tasks.

I tested four different configurations: both JRuby and are tested on their default configurations (compile.invokedynamic turned off) and with the option turned on.

The results are shown below:

Benchmarking results

Turning compile.invokedynamic on yields a 26% speedup for JRuby, shaving more than a minute from the time needed to execute the workload!

Furthermore, we can also see how JRuby performance has slightly improved in a year, between JRuby (released in January of 2016) and JRuby (released in January of 2017).

So what’s the verdict? If you’re not impacted by having longer start-up and warm-up times for your application, you should really be adding -Xcompile.invokedynamic=true to your JRUBY_OPTS or application startup scripts.

As for JRuby it may be time to enable this option by default again. Or at least rename it to something more awesome-sounding, like --production-booster ;)