Chapter 04The Compiler's Optimization BudgetPaid chapter

Inlining: Budgets, Costs, PGO, and What Breaks It

Inspect inlining decisions and demonstrate how caller context can change allocation behavior.

Launch paywall

This chapter is part of the paid launch. The preview stays visible so readers can evaluate the exact scope before buying.

Included in

Core and Complete. Complete also includes the practical exam and free Go-version updates.

Preview

What this chapter teaches

Common belief

Extracting a helper function is free — the compiler inlines small functions anyway, so splitting code up for readability has no performance cost.

What actually happens

inlining is gated by a fixed cost budget (80 AST-node units in Go 1.25). A function one unit over the budget is not inlined at all — it's a cliff, not a slope. And because inlining is what lets escape analysis see across a call (Chapter 1), losing it on a leaf can move an allocation into the caller with no change at the call site (the cold open). "Clean" refactors that extract helpers, add a defer, or grow a switch are performance-visible on hot paths until a benchmark proves otherwise.

Mechanisms covered
Inlining exposes operations to other optimization passes; ordinary calls can still carry escape summaries.
PGO supplies profile information to compiler decisions; a representative profile and explicit non-PGO baseline are required.
compilebenchcompile + bench
One-time purchase

Unlock Chapter 04 and the rest of the course.

Core unlocks every paid chapter and lab. Complete also includes the practical exam and future Go-version updates.

Core
$49

Full course access with the complete mechanics curriculum.

All paid chapters unlocked
One-time purchase
Perfect if you want the material only
Complete
$79
Best value

Best-value launch option with the exam and free Go-version course updates.

Everything in Core
Black Belt practical exam
Free Go-version updates

No subscription or account required. Access is tied to the email entered at Stripe Checkout and can be restored by email.

Free chapter
Escape Analysis: The Compiler's Fragile Decision
Distinguish escape diagnostics from measured allocations and explain the role of lifetime and call-site visibility.
Free chapter
Maps: Swiss Tables, Growth, and Permanent Memory
Distinguish map table capacity from referenced payloads and inspect clearing and growth on Go 1.25.