A survey of inlining heuristics 0 ▲ Max Bernstein's Blog 178 days ago · 21 min read4263 words · Tech · hide · Fediverse post Compilers, especially method just-in-time compilers, operate on one function at a time. It is a natural code unit size, especially for a dynamic language JIT: at a given point in time, what more information can you gather about other parts of a running, changing system? I don’t have any data to back this up—maybe I should go gather some—but on average, methods are small. Especially in languages such as Ruby that use method dispatch for everything, even instance variable (attribute, field, …) lookups, they are small. And everywhere. This makes the compiler sad. If we are to continue to anthropomorphize them, compilers like having more context so they can optimize better. Consider the following silly-looking example that is actually representative of a surprising amount of real-world code: class Point def initialize(x, y) @x = x @y = y end def distance(other) Math.sqrt((@x - other.x)**2 + (@y - other.y)**2) end end def distance_from_origin(x, y) Point.new(x, y).distance(Point.new(0, 0))… Commenting on Bubbles has been removed. Why? If you want to talk about this post, write to the author, use the comments on their blog if it has them, or reply with a "RE:" post on your own blog. Suggestions? feedback@bubbles.town