Questions: Inlining Heuristics and Decision Making

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

A compiler is evaluating whether to inline a tiny 3-instruction getter function that is called from 800 different locations, most of them in initialization code that runs once at startup. What should the heuristic decide?

AInline it everywhere — tiny functions should always be inlined to eliminate call overhead
BDo not inline — duplicating the function body 800 times bloats the binary without meaningful performance gain
CInline only the calls inside hot loops; leave the cold startup calls as-is
DInline it and then apply dead code elimination to remove the duplicates
Question 2 Multiple Choice

What is the primary reason that inlining every function call in a program could make it run *slower* than selective inlining?

AInlined code cannot be optimized by the compiler since it loses its function structure
BCode size explosion overwhelms the instruction cache, causing more cache misses
CInlining prevents the CPU from using branch prediction on the call sites
DInlined functions cannot be shared between threads, creating synchronization overhead
Question 3 True / False

A function that is very small (below the compiler's size threshold) should generally be inlined, regardless of how frequently it is called.

TTrue
FFalse
Question 4 True / False

Profile-guided optimization (PGO) improves inlining decisions by revealing which call sites execute most frequently during representative program runs.

TTrue
FFalse
Question 5 Short Answer

Why do production compilers use elaborate cost models rather than a simple size threshold when deciding whether to inline a function, and what factors beyond size matter most?

Think about your answer, then reveal below.