-
Notifications
You must be signed in to change notification settings - Fork 5k
Clean up AggressiveOpt tier in vm #90504
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
Conversation
Does this mean by adding that attribute my method can get optimized code immediately? If so that sounds like a workaround for #87753? |
This PR doesn't change anything for codegen, it only fixes "diagnostics" basically, it's now easier to understand from JitDisasm/JitDisasmSummary or even PerfView whether this method bypassed tier0 or not. The attribute always forces JIT to compile a method straight to the final tier (usually, it has worse performance compared to not having that attribute and reaching Tier1 naturally, especially now, with PGO being enabled by default).. |
I'm having trouble parsing this -- if it forces JIT to compile directly to the final tier, that's what we want for #87753 isn't it? And it's not just diagnostics - that would be customer visible. |
When JIT bypasses Tier0/instrumented tiers and goes straight to the final one, it usually produces worse (in terms of perf) codegen , so we try to avoid recommending The codegen is worse because of two reasons:
For the case you referenced |
Which the source generated code for regexes relies on heavily, e.g. to eliminate all the checks related to timeouts, to devirtualize SearchValues-related object accesses, etc. |
Ah -- I didn't realize this. It's become a misleading name, I guess. The docs do say this
I wonder how widely this is understood in the ecosystem. My guess is that it's almost always used "because this path is hot" |
https://grep.app/search?current=2&q=AggressiveOptimization&words=true&filter[lang][0]=C%23 Doesn't look too bad on grep.app (no idea how representative it is) |
Part of the ecosystem does not measure that is the number one rule of perf, and use AggressiveInlining and AggressiveOptimization just because it is there. When not used carefully, each of these attributes can and will have opposite effect and actually make the code run slower. |
when AggressiveInlining is a deoptimization is that essentially because of less code localization (and fatter assemblies)? or are there bad interactions with PGO, tiering, or other JIT optimizations? Unlike for AggressiveOptimization, the MethodImplOptions topic doesn't warn about it. |
BTW, I assume we don't expect we would ever offer a |
Too much of AggressiveInlining makes the JIT hit its internal implementation limits that makes it use conservative register allocator and turn off optimizations. In this repo, we have this problem in System.Text.Json (see #85531). IMHO, System.Text.Json uses AggressiveInlining too much. |
How does dotnet/dotnet-api-docs#9188 look? |
Ping @kouvel, the PR is simple if you check "ignore whitespaces" on "Files changed" page. |
Closes #90490
Currently, MethodDesc with
[AggressiveOptimization]
attribute still returnstrue
forIsEligibleForTieredCompilation()
. This PR makes itfalse
+ clean up.So now methods with that attribute are reported as FullOpts instead of Tier1.
PS: I recommend disabling "show whitespaces" on the review page.