-
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
JIT: Enable EH Write Thru by default #35923
Comments
@CarolEidt is this 5.0? I can look at cleaning up some of the hot path workarounds if that would be helpful? |
@benaadams - I think I should have put this in "Future". The issue is that it degrades performance in some cases (see the comments above, and the linked issue). What's needed is to first fully understand the causes for the scenarios where performance degrades and then determine the best approach to mitigate those. |
I'm hoping it's caused by the hot-paths current higher register cost to workaround the EH issue; which then the writethrough adds to; so taking those out should make it lighter? 52d6d27 |
Oh, shoot. At the time I was working on EH WriteThru I had change those workarounds, but I'm pretty sure that wasn't done for the measurements described in #35534. The one in |
Moved future since .NET 6 scope items are complete now. |
I spent some time to enable this for multi-vars and the ones that needs zero initialization and from the asmdiffs, we continue to see the regressions because of the reason Carol mentioned:
The first line of attack would be to track the def/use ratio and see if we can enable enregistration of lvlVar if
|
Today, if all the variables that are live cross exception handlers (EH) are kept on stack. This proves expensive for hot methods containing EH code. It is also expensive for certain language constructs like presence
async
which calls in .NET libraries code that has EH. In below example, even if methodCalculate
doesn't have any EH regions, the presence ofasync
introduces EH region.The call to AsyncMethodBuilderCore:Start contains EH code and the performance for these methods can be degraded because of accessing the EH vars from stack. We added a work around specially inside
AsyncMethodBuilderCore:Start()
in dotnet/coreclr#15629 to make sure that EH vars get registers.We have an implementation of enregistering EH Vars but from the analysis of #35534 showed mixed results for enabling EH Write Thru by default. This issue tracks of enabling the EH Write thru by default. The outcome that we are expecting is that in addition to storing the EH variable values on stack, also store them in a register and use register (as much as possible) during the uses in non-EH code. Additionally, also assign a register for the code that is totally contained inside a EH region.
There are at least a couple of issues, though further analysis should be done to validate that these are the major contributing factors to performance regressions:
One option would be to track the number/ratio of defs and uses. Currently we don't readily have that information until we build
Interval
s, and at that point it is difficult for the register allocator to change its mind about making something a candidate. That said, it could presumably decide that some of the candidates should never get a register, effectively making it the same as if it were not a candidate, though that would require some tweaking to avoid actually allocating a register when not needed (it does better with RegOptional uses than defs).It's possible that this tracking could be done prior to register allocation at the time of ref counting.
For now, we will take an incremental approach:
Future work
Related issue:
Workaround added so far: dotnet/coreclr#15629
category:cq
theme:register-allocator
skill-level:expert
cost:medium
The text was updated successfully, but these errors were encountered: