1 hour ago · 14 min read2800 words · Tech · hide · 0 comments

Originally published on Rails At Scale. We recently enabled a really cool feature in ZJIT that makes it feel like a Real Compiler™: the inliner! We’ll write more about it soon. In this post, we’ll talk about one excellent concrete benefit we are already seeing and how it optimizes blocks in pretty much every Ruby program. I’ll start off with a refresher on how blocks work in the Ruby interpreter, then show you how ZJIT understands and optimizes that bytecode, and then show you the impact of the inliner. Ruby: a refresher In the beginning, there were loops. arr = [1, 2, 3] i = 0 sum = 0 while i < arr.length sum += arr[i] i += 1 end People used them to navigate and manipulate variable-length structures, like arrays and strings. This was fine. Then, in the 1970s, a small group of computer scientists at Palo Alto Research Center invented a programming language called Smalltalk. One of the core features of Smalltalk was that everything was an object and computation was done by sending…

No comments yet. Log in to reply on the Fediverse. Comments will appear here.