Hasty Briefsbeta

Bilingual

A Survey of Inlining Heuristics

5 days ago
  • #inlining-heuristics
  • #compiler-optimization
  • #jit-compilation
  • Compilers, particularly just-in-time (JIT) compilers, operate on functions as a natural code unit, but methods are often small in dynamic languages like Ruby, limiting optimization context.
  • Inlining is a crucial optimization that enables further optimizations by copying callee code into the caller, though it requires careful heuristics to avoid negative impacts like code bloat or cache thrashing.
  • Inlining heuristics across compilers typically consider factors such as function size, call frequency, recursion depth, and profile information, with variations in implementation across systems like Cinder, V8, and HotSpot.
  • Gathering and interpreting profile data, including call context and type information, is essential for effective inlining, with approaches like bytecode inlining (JavaScriptCore) or trial inlining (SpiderMonkey).
  • Inlining decisions can be complex due to non-local effects, requiring tuning over time, and recent research explores advanced techniques like machine learning and post-inlining transformations to improve heuristics.