-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: Public PGO config switch #70410
Comments
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch Issue DetailsBackground and motivationWe want users to be able to easily turn on 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 - I have a small write-up here. We define three modes for PGO:
A good visualization of the difference between these modes is this TE benchmark: Proposal & UsageAdd a runtime switch for .csproj:
and runtimeconfig.json:
(in dotnet/sdk project) Where Alternative Designs
cc @richlander @terrajobst @AndyAyersMS @davidwrighton @dotnet/jit-contrib
|
I sort of wish there were two dynamic PGO modes:
|
Technically it can be achieved if we instrument R2R'd code, but it's likely a huge binary size penalty (at least now) |
Right, we would not want to instrument R2R code. You can instrument the hot methods once the process starts up, like:
|
The other side of the coin is better visibility into what form of PGO is enabled: |
@EgorBo are you proposing this change for .NET 7 or after .NET 7? |
For .NET 7.0. Ideally with Jan's idea eventually we won't need any switches and the default mode will be good as is (both "full" level of perf and R2R-level of startup) but we're not there and not sure it will make it to even 8.0. Currently some of our customers struggle enabling PGO properly to try it (even 1st parties) especially for aspnet so it'd be nice to provide them with a simple csproj/json key switch |
Seems likely that if we want to have R2R -> instrumented -> optimized we'll need to do a bunch of work to improve the efficiency of the instrumented code. Otherwise, apps will see perf start out reasonably good (R2R, especially composite), then dip -- perhaps substantially -- for a while (instrumented), then improve (optimized). We've been trying to avoid modes where the performance can have dips like this. For example, we will likely need to fully support code that is both instrumented and optimized. Some relevant issues:
|
I went ahead and filed PRs #71438 and dotnet/sdk#26350 In #70941 we realized that we can only expose a boolean property |
Seems legit. Having a property (MSBuild and runtime config) seems like a good plan. |
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:
Default
- Current DefaultFull
- All R2R images are ignored, everything is compiled and profiled from scratch. Noticeable startup regression with the most performant steady state.Dynamic
or e.g.Hybrid
orMixed
- 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:
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:
and runtimeconfig.json:
(in dotnet/sdk project)
Where
full
basically setsDOTNET_ReadyToRun=false
andDOTNET_TieredPGO=true
internally anddynamic
only definesDOTNET_TieredPGO=true
(OSR and QJFL are already enabled by default in .NET 7.0 and omitted here)Alternative Designs
<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<DynamicPgo>true</DynamicPgo>
and<IgnoreR2R>true</IgnoreR2R>
Define two simple bool properties, where
<IgnoreR2R>true</IgnoreR2R>
is added only whenFullPgo
mode is requested.cc @richlander @terrajobst @AndyAyersMS @davidwrighton @dotnet/jit-contrib
The text was updated successfully, but these errors were encountered: