-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Introduce OptLevel() in jit #77465
Introduce OptLevel() in jit #77465
Conversation
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch Issue DetailsThis PR introduces Since all these paths with Existing
|
You will need to update the summary.md printed by superpmi-diffs for asmdiffs/tpdiff, I guess instead of MinOpts we should use some terminology like "FastOpts" or "FastCode". You potentially need to fix superpmi as well since its detection for MinOpts might not make much sense w.r.t. these changes. |
@AndyAyersMS (cc @dotnet/jit-contrib) could you please review this if you have time? It's almost ready, I just want to fix SuperPMI to print optimization levels. For now, it doesn't change anything for MinOpts vs Tier0 (SizeOrThroughput). better names for opt levels are welcomed. |
@@ -3271,7 +3271,7 @@ void CodeGen::genCall(GenTreeCall* call) | |||
|
|||
// If there is nothing next, that means the result is thrown away, so this value is not live. | |||
// However, for minopts or debuggable code, we keep it live to support managed return value debugging. | |||
if ((call->gtNext == nullptr) && !compiler->opts.MinOpts() && !compiler->opts.compDbgCode) | |||
if ((call->gtNext == nullptr) && !compiler->opts.OptimizationDisabled() && !compiler->opts.compDbgCode) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
!compiler->opts.OptimizationDisabled()
Nit: the double negation is hard to read. Can these (there are a number of instances) be switched to OptimizationEnabled
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, but I didn't want to distract code reviewers with that. I think we'd better do it separately, for now it's easier to review because I simply replaced MinOpts with the same OptimizationDisabled so no need to validate it 🙂
This looks really odd, I'm curious how this is showing up so differently in coreclr_tests (unfortunately no easy way to check without hacking superpmi and/or using a more detailed pin tool) |
The reason why throughput is slightly (I see that for the most important collections it's smaller) improved is because OptimizationsEnabled()/Disabled did not just return cached value previously. |
Yeah, I'm just surprised that the differences are so large. I will try to look into what exactly causes this to impact coreclr_tests so much more than the other collections, this is quite unexpected to me. |
@EgorBo It looks like this PR has diffs again in the latest superpmi-diffs run |
The majority of the TP improvement is coming from two particular contexts, 426399 and 426400 (on current latest collection on the head of this PR). These method are both named |
Interesting, thanks for looking into that! |
@EgorBo Another thing I noticed is that the disassembly often has "; unknown optimization flags" at the top, e.g. ; Assembly listing for method JitTest.HFA.TestCase:Main():int
; Emitting quick and small code for X64 CPU with AVX - Windows
; Tier-0 compilation
; unknown optimization flags
; rbp based frame
; partially interruptible
; Final local variable assignments (maybe it's expected due to SPMI?) |
It's probably this one: |
# Conflicts: # src/coreclr/jit/codegencommon.cpp
@EgorBo I presume this is still in progress. Maybe move to "Draft" status temporarily? |
@EgorBo ping |
# Conflicts: # src/coreclr/jit/lower.cpp
Draft Pull Request was automatically closed for 30 days of inactivity. Please let us know if you'd like to reopen it. |
Resolving conflicts now.. |
Draft Pull Request was automatically closed for 30 days of inactivity. Please let us know if you'd like to reopen it. |
This PR introduces
opts.OptLevel()
property to take various related jit flags into account such as "prefer size", "prefer speed", "minopts" etc. As you can see from this piece, jit used to ignore these flags. Now it doesn't. The main idea is to useOPT_SizeAndThrougput
for Tier0 (except explicit minopts and debug-friendly codegen). Other flags can be used via corresponding arguments in ILC/Crossgen.Most of the existing
OPT_SizeAndThrougput
in this PR aren't expected to affect Tier0 since most of those optimizations are disabled for Tier0 anyway.Since all these paths with
if SMALL_CODE
weren't tested previously I decided to remove some, e.g. everything related to alignment in the data section because e.g. floating point constants are expected to be 16b aligned, etc. Feel free to restore some pieces if that will show nice size savings (I bet it won't).Existing
opts.OptimizationsEnabled()
is left to be "either Blended or Speed level".Unblocks #77357