-
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
Improve windows hardware exception handling performance #74426
Improve windows hardware exception handling performance #74426
Conversation
With my recent change that modified hardware exception handling so that the related managed exception is thrown directly from the vectored exception handler, the performance of handling such exceptions have regressed. Several exception handling dotnet/performance microbenchmarks have regressed upto 15%. The reason for the regression was the larger number of stack frames between the exception raising and the actual handler frame. With a recent change that @AntonLapounov has made to fix process corrupting exceptions handling, the regression went down to 8%. This change moves the location where we raise the exception down to the ClrVectoredExceptionHandlerShim, which means to the closest possible frame to the managed code. This gets rid of the regression completely.
src/coreclr/vm/excep.cpp
Outdated
} | ||
|
||
LONG retVal = 0; | ||
VEH_ACTION retVal = VEH_NO_ACTION; |
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.
Nit: We could get rid of this local variable or move down this definition.
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.
Looks great, thank you!
@@ -240,7 +240,16 @@ VOID DECLSPEC_NORETURN RealCOMPlusThrowOM(); | |||
|
|||
#endif // !defined(FEATURE_EH_FUNCLETS) | |||
|
|||
LONG WINAPI CLRVectoredExceptionHandler(PEXCEPTION_POINTERS pExceptionInfo); | |||
enum VEH_ACTION |
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.
Do these really need to be in the header? Adding definitions to the header implies they are used in other places whereas this are not.
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.
Thanks @AaronRobinsonMSFT, it is actually used in two sources, the excep.cpp and excepx86.cpp. However, I have forgotten to modify the excepx86.cpp to get the result of the CLRVectoredExceptionHandler
call into VEH_ACTION
, it was still using DWORD
. I am updating the change.
/backport to release/7.0 |
Started backporting to release/7.0: https://github.com/dotnet/runtime/actions/runs/2927798654 |
@janvorli backporting to release/7.0 failed, the patch most likely resulted in conflicts: $ git am --3way --ignore-whitespace --keep-non-patch changes.patch
Applying: Improve windows hardware exception handling performance
Using index info to reconstruct a base tree...
M src/coreclr/vm/excep.cpp
Falling back to patching base and 3-way merge...
Auto-merging src/coreclr/vm/excep.cpp
CONFLICT (content): Merge conflict in src/coreclr/vm/excep.cpp
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Improve windows hardware exception handling performance
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Error: The process '/usr/bin/git' failed with exit code 128 Please backport manually! |
Port of dotnet#74426 to release/7.0 * Improve windows hardware exception handling performance With my recent change that modified hardware exception handling so that the related managed exception is thrown directly from the vectored exception handler, the performance of handling such exceptions have regressed. Several exception handling dotnet/performance microbenchmarks have regressed upto 15%. The reason for the regression was the larger number of stack frames between the exception raising and the actual handler frame. With a recent change that @AntonLapounov has made to fix process corrupting exceptions handling, the regression went down to 8%. This change moves the location where we raise the exception down to the ClrVectoredExceptionHandlerShim, which means to the closest possible frame to the managed code. This gets rid of the regression completely. Close dotnet#71069
…#74590) Port of #74426 to release/7.0 * Improve windows hardware exception handling performance With my recent change that modified hardware exception handling so that the related managed exception is thrown directly from the vectored exception handler, the performance of handling such exceptions have regressed. Several exception handling dotnet/performance microbenchmarks have regressed upto 15%. The reason for the regression was the larger number of stack frames between the exception raising and the actual handler frame. With a recent change that @AntonLapounov has made to fix process corrupting exceptions handling, the regression went down to 8%. This change moves the location where we raise the exception down to the ClrVectoredExceptionHandlerShim, which means to the closest possible frame to the managed code. This gets rid of the regression completely. Close #71069
Improvements on: |
With my recent change that modified hardware exception handling so that
the related managed exception is thrown directly from the vectored
exception handler, the performance of handling such exceptions have
regressed. Several exception handling dotnet/performance microbenchmarks
have regressed upto 15%.
The reason for the regression was the larger number of stack frames
between the exception raising and the actual handler frame. With a
recent change that @AntonLapounov has made to fix process corrupting
exceptions handling, the regression went down to 8%. This change moves
the location where we raise the exception down to the
ClrVectoredExceptionHandlerShim, which means to the closest possible
frame to the managed code.
This gets rid of the regression completely.
Close #71069