Compiling Ruby to machine language
patshaughnessy.net
Compiling Ruby to machine language
1–10 of 56 posts
Re: Compiling Ruby to machine language
#2Re: Compiling Ruby to machine language
#3Re: Compiling Ruby to machine language
#4I haven't kept up with the evolving Ruby implementation internals, so I will sure as heck buy this new version of the book.
Re: Compiling Ruby to machine language
#5I'll have to pick up a copy of this "Ruby Under a Microscope" book when the new version comes out. I've always liked Ruby, I just haven't had much chance to use it.
Re: Compiling Ruby to machine language
#6Re: Compiling Ruby to machine language
#7At first glance this seems too simple. Compare it to JavaScript JITs, which IIRC can compile hot spots even in functions that are only called a few times (e.g. those that contain heavy loops) via on-stack replacement. (Although I’ve also heard on-stack replacement called a “party trick” - more useful for optimising benchmark scores than for real code.)
But on the other hand, Ruby’s language design might help here. Idiomatic Ruby uses blocks for loop bodies - so can Ruby JITs optimise long-running loops by treating the loop body as just another function?
Re: Compiling Ruby to machine language
#8Really happy to see Pat keeping it up! His first Ruby under a Microscope book but also his blog posts are amazing and a major source of inspiration for me. I did meet him personally in a Euruko conference. Such a great person.
Re: Compiling Ruby to machine language
#9And by what process is the correct compiled block used depending on the input variable types?
Re: Compiling Ruby to machine language
#10> To find hot spots, YJIT counts how many times your program calls each function or block At first glance this seems too simple. Compare it to JavaScript JITs, which IIRC can compile hot spots even in functions that are only called a few times (e.g. those that contain heavy loops) via on-stack replacement. (Although I’ve also heard on-stack replacement called a “party trick” - more useful for optimising benchmark sco…
Yes that's something I want to dig into and explore in this chapter... when exactly does Ruby's JIT compiler activate and optimize our code? And you're right: since Ruby will JIT blocks as if they were separate function many loops will be optimized using this simple heuristic.