liveBook · Manning

Tiered compilation

As explained in .NET in Action, Second Edition

Tiered compilation is a runtime compilation strategy that initially favors fast compilation and later recompiles code using execution information.

Tiered compilation is a .NET runtime strategy that quickly compiles methods to native code, then recompiles them using execution behavior observed under load. section 10.2

The runtime uses two compilation stages:

  • Performs an initial fast compilation so execution can begin quickly. section 10.2
  • Recompiles code after observing how it is used under load, potentially producing better-optimized native code. section 10.2
  • Can affect benchmark results, so BenchmarkDotNet uses pilot and warmup phases and gives the JIT time to complete. section 10.2

Benchmarking tiered execution

Run a BenchmarkDotNet benchmark in Release mode and allow its pilot and warmup phases to execute before comparing results. The generated summary includes environment details and result statistics. section 10.2

How .NET in Action, Second Edition covers it

How deep it goes
Explains the fast-first and usage-informed recompilation stages, but does not detail optimization algorithms or generated machine code.
Examples
Uses BenchmarkDotNet pilot and warmup phases before comparing benchmark methods and generating a result table.
What you can do after
Evaluate performance with BenchmarkDotNet while accounting for JIT compilation behavior during warmup.
How it connects
Connects the JIT compiler with native code generation, runtime load, and BenchmarkDotNet warmup phases.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of .NET in Action, Second Edition. The section links point to the parts of the book it draws on.