-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Fix perf regressions with a recent change. #55300
Conversation
PTAL @kunalspathak @EgorBo @dotnet/jit-contrib |
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.
Did you try running some BDN benchmarks that regressed and were able to see the gains come back?
src/coreclr/jit/morph.cpp
Outdated
{ | ||
// Morph is checking if lvDoNotEnregister is already set for some optimizations. | ||
// If we are running in min opts and know that we won't enregister any locals | ||
// it is better to set this flag before we start reading it. |
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.
I was hoping to see MinOpts check here...why is it not there?
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.
The comment was poorly written, what I was trying to explain here:
-
the main flag is
(opts.compFlags & CLFLG_REGVAR)
, if it is not set we can't enregister variables; -
right now it is set if we use
CLFLG_MAXOPT
and not set when usingCLFLG_MINOPT
, an example where we set it:
runtime/src/coreclr/jit/compiler.cpp
Lines 2615 to 2620 in 7f88911
// Don't optimize .cctors (except prejit) or if we're an inlinee else if (!jitFlags->IsSet(JitFlags::JIT_FLAG_PREJIT) && ((info.compFlags & FLG_CCTOR) == FLG_CCTOR) && !compIsForInlining()) { opts.compFlags = CLFLG_MINOPT; } -
in theory nothing prevents us to disable CLFLG_REGVAR when MinOpts is not set, or enable it when it is set, so I do not want to check
isMinOpts
instead of!compEnregLocals()
here.
I have updated the comments to reflect that, please take a look.
Yes, they are back to the previous values. |
the failures are unrelated. |
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.
LGTM
Co-authored-by: Kunal Pathak <Kunal.Pathak@microsoft.com>
#54998 introduced a perf regression that this PR is fixing.
Thanks to @kunalspathak for catching and @EgorBo for repro help.
The regression was happening only when we switched from MinOpts to FullOpts and it was happening because of Tier0 QuickJitForLoops=disabled, so SPMI did not reproduce this scenario so it was not catched in my local testing.
We still want to have
doNotEnreg
flag to be known as soon as possible but with this change, we just add two additional iterations to set it for minopts in comparasing with the previous version that was trying to init it when we created a lclVar.Why can't we init it when we create a lclVar? It is because at this time we don't know the final optimization level yet and we can't reset
doNotEnreg
flag after the optimization flag is finalized.No SPMI diffs as expected but CoreRun with Tiering=1 shows improvements on methods with loops.