A survey of inlining heuristics
a day ago
- Inlining is crucial for optimizing dynamic language JIT compilers but introduces non-local effects and complexity.
- Compilers use heuristics to decide when to inline, balancing code size, compile time, and performance gains.
- Common heuristics include inlining small methods, limiting depth, and using cost budgets based on bytecode size or instruction count.
- Profiling with call context (e.g., trial inlining, bytecode inlining) helps avoid polymorphic pollution and improves inline decisions.
- Different JIT compilers (Cinder, V8, PyPy, HotSpot, etc.) implement inlining at various stages and with distinct strategies.
- Over-inlining can cause code bloat, cache thrashing, and block other optimizations, making careful tuning necessary.
- Research explores advanced techniques like machine learning, partial inlining, and interprocedural analysis to improve inlining decisions.