Improve windows hardware exception handling performance (#74426)
authorJan Vorlicek <janvorli@microsoft.com>
Wed, 24 Aug 2022 14:12:57 +0000 (16:12 +0200)
committerGitHub <noreply@github.com>
Wed, 24 Aug 2022 14:12:57 +0000 (16:12 +0200)
commit86412566424353b2d9b32d629fe7efb66346ac38
tree8897d05dcb8b4a9c9c3f736374900c74557cba06
parent4b14c9217d5b9c65ca697818400e79f5c03874e3
Improve windows hardware exception handling performance (#74426)

* 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.
src/coreclr/vm/excep.cpp
src/coreclr/vm/exceptmacros.h
src/coreclr/vm/i386/excepx86.cpp