I’ve wondered Why Rails becomes slow with JIT for a long time. Today, I’m pleased to share my answer to the question in this article, which I spent three years of my life to figure out.

RubyKaig 2018 / The Method JIT Compiler for Ruby 2.6

"MJIT Does Not Improve Rails Performance"

As I wrote in Ruby 3.0.0 Release Note and my previous post, we thought:

it is still not ready for optimizing workloads like Rails, which often spend time on so many methods and therefore suffer from i-cache misses exacerbated by JIT.

We thought Ruby 3’s JIT a.k.a. MJIT Does Not Improve Rails Performance and Rails Ruby Bench gets slower, not faster. …


Ruby 3.0 JIT is the fastest JIT ever for MRI. However, despite Ruby 3.0's big improvement in reducing i-cache misses, it's still not ready for optimizing Rails applications. Stay tuned for Ruby 3.1.

"Is Ruby 3 Actually Three Times Faster?"

Ruby 3 is indeed 3x faster than Ruby 2.0 in a Ruby 3x3 benchmark, Optcarrot:


As proposed by Eregon, we measured performance after 3000 frames to measure peak time performance with Optcarrot.

Note that Ruby's JIT compiler methodology using a C compiler called "MJIT" was originally implemented by Vladimir Makarov. The JIT of Ruby 2.6 / 2.7 …


We focused to improve Rails application performance in Ruby 2.7 JIT, but the last year's assumption was wrong and Ruby 2.7 JIT didn't meet the goal. We'll change the approach for it in Ruby 3.0.

Ruby 2.7 is released!

Merry Christmas! The new Ruby is out. As I've sometimes promised to make performance improvements in Ruby 2.7 JIT, let me explain how it went. See also The method JIT compiler for Ruby 2.6 and Ruby 2.6 JIT - Progress and Future in case you're not familiar with the context.

Since my original motivation to work on JIT is to improve Rails application's performance, I…

In early 2018, Ruby core team merged JIT compiler infrastructure called “MJIT”, which is created by Vladimir Makarov and uses C compiler to generate native code and loads a shared object file dynamically, along with my JIT compiler that is implemented on MJIT and Ruby 2.5-compatible Virtual Machine.

Fortunately my effort has not been reverted, so it will be officially released next week!

Over 10 months, Ruby’s JIT has evolved for the following focuses:

  • Performance
  • Portability
  • Stability
  • Security

Let me show you what we’ve achieved for each of them in Ruby 2.6.


At least for Ruby, JIT is introduced to…

My benchmark tool development was accepted as a Ruby Association Grant 2017 project and completed on March 21st. I’ll show you the details of the project.

benchmark_driver.gem's example usage that outputs a graph:

Project Summary

Here is a copy of the project summary which I sent to Ruby Association:

This project aims to improve benchmark_driver.gem, which is built to compare performance of different Ruby binaries easily and precisely. …

This month, I merged the Ruby's first JIT compiler.

Then I gave a talk about it yesterday at my company's conference.

As it isn't ultra-fast yet, I haven't shared it deeply until the conference. But some of you guys kindly wrote great articles about it.

Probably they are easier to understand than my article. But I found several things to point out or announce. So I decided to write this article.

What's "MJIT"?

Let me share the summary about recent JIT topics on Ruby. …

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store