The documentation is quite brief. Just add:
<PropertyGroup>
<TieredPGO>true</TieredPGO>
</PropertyGroup>
in your .csproj file and profile guided optimization will be enabled, or add an environment variable DOTNET_TieredPGO
and set it to 1
.
I assume that this is a process-wide setting, (especially because it can be set via an environment variable) so we do not need to add these lines to libraries and DLL's, only to the main application (the one with the Main(string[] args)
enty point). Or am I wrong?
What happens if it is included for a DLL but not for the main application?
Will it also apply when hosted in a parent process such as the AspNetCoreModule in IIS?
Can the setting get lost in the build-deployment chain if a config file is not copied?
Is it a flag baked into the binary (like CoreFlags)?
(also see my other question on the scope of optimized code persistence)
PGO is a process-wide setting, so if specified in the environment, all processes launched from that environment will use it; if specified in a project file or runtime config, it will apply only if that module is the main executable.
For ASP.NET what happens likely depends if you are launching things in process out out of process, though I am less familiar with the details there.
Note in .NET 8 this feature is enabled by default so there is no need to configure it (unless you want to disable).