Skip to content

Proposal: Public PGO config switch #70410

@EgorBo

Description

@EgorBo

Background and motivation

We want users to be able to easily enable the Dynamic PGO feature in .NET 7.0. Currently it's not as convenient as it could be: users have to define a set of environment variables and make sure those are defined in the process of app's execution (it's especially complicated for asp.net scenarios) - I have a small write-up here. We define three modes for PGO:

  1. Default - Current Default
  2. Full - All R2R images are ignored, everything is compiled and profiled from scratch. Noticeable startup regression with the most performant steady state.
  3. Dynamic or e.g. Hybrid or Mixed - JIT only instruments functions without R2R data. (NOTE: it doesn't mean such functions won't benefit from PGO - e.g. lots of BCL's code contains a "generic" profile baked into R2R which is then used by the tiered JIT for tier1) - a balance between start up time and performance. Eventually, we hope that this mode will be the default one.

A good visualization of the difference between these modes is this TE benchmark:
image
Full significantly regresses "time to first request" but provides the best performance. Dynamic still slightly regresses "time to first request" but eventually we plan to reduce overhead from instrumentation in tier0 and minimize it.

Proposal & Usage

Add a runtime switch for .csproj:

<PgoMode>full</PgoMode>

and runtimeconfig.json:

"System.Runtime.PgoMode": dynamic

(in dotnet/sdk project)

Where full basically sets DOTNET_ReadyToRun=false and DOTNET_TieredPGO=true internally and dynamic only defines DOTNET_TieredPGO=true (OSR and QJFL are already enabled by default in .NET 7.0 and omitted here)

Alternative Designs

  1. <OptimizeFor>
    Alternatively, we can encapsulate all of that into a generic <OptimizeFor> property with "FastStartup", "MaxPerformance", "SmallWorkingSet" values and rely on them in JIT/VM/BCL in various places, not just for PGO

  2. <DynamicPgo>true</DynamicPgo> and <IgnoreR2R>true</IgnoreR2R>
    Define two simple bool properties, where <IgnoreR2R>true</IgnoreR2R> is added only when FullPgo mode is requested.

cc @richlander @terrajobst @AndyAyersMS @davidwrighton @dotnet/jit-contrib

Metadata

Metadata

Assignees

Labels

area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions