All Topics
All Topics
Technology
Technology
Design
Design
Programming
Programming
Science
Science
News
News
Gaming
Gaming
Entertainment
Entertainment
Business
Business
Finance
Finance
Sports
Sports
Health
Health
Food
Food
Travel
Travel
Art
Art
Music
Music
Books
Books
Education
Education
Politics
Politics
Personal
Personal
No algorithm. No AI slop. No ads. Just RSS. Pro-human. Indie writers. Real journalism. Open web. Chronological. Hand toasted.

Understanding Partial Inlining: How Compilers Optimize Functions with Fast and Slow Paths

By

hasheddan

5mo ago· 5 min readenInsight

Summary

This technical blog post explores partial inlining as a compiler optimization technique, explaining how compilers can selectively inline only certain parts of a function rather than the entire function. The article uses a practical example of a function with fast and slow paths to demonstrate how partial inlining can optimize performance while avoiding code bloat. It discusses the trade-offs between inlining benefits and code size considerations, showing how compilers make intelligent decisions about which parts of functions to inline based on usage patterns and performance characteristics.

Key quotes

· 4 pulled
Inlining doesn't have to be all-or-nothing!
We've learned how important inlining is to optimisation, but also that it might sometimes cause code bloat.
Let's look at a simple function that has a fast path and slow path; and then see how the compiler handles it.
In this example we have some process function that has a really trivial fast case for numbers in the range 0-100. For other numbers it does something more expensive.
Snippet from the RSS feed
Inlining doesn't have to be all-or-nothing

You might also wanna read