-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Thread abort exceptions, do not preallocate + some cleanup. #46455
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
|
I have run diagnostics tests with these changes, a few times to be sure - no new failures were observed. |
|
I like the cleanup of the ThreadAbort handling. But is it really worth the saved size to not to preallocate the exceptions? It seems that an Exception instance takes ~100 bytes only. |
|
@janvorli - allocations were the original complaint that lead to this PR. Allocating these instances and handles may not be a lot, but still measurable in the context of startup. @stephentoub may have more on how much they stick out in the profiles. As I see this - these exceptions are now used only in an extreme corner case when an expression evaluation times out while debugging, and even then pre-allocating them is not really important, so why have that. |
I keep hitting timeouts when viewing the locals window in VS very often. So I wouldn't call that extreme corner cases :-). But I am not worried about an impact of the thread abort exception allocation. But I was a bit worried about the preallocated base exception removal. The comments at the following two places explicitly mentions that it was not desirable to get OOM exception there in case of OOM: runtime/src/coreclr/vm/clrex.cpp Lines 135 to 150 in 51f59f5
runtime/src/coreclr/vm/clrex.cpp Lines 820 to 833 in 51f59f5
The new GetBestBaseException would give us OOM exception in case we cannot allocate the Exception, contradicting those two comments. On the other hand, the likelyhood that the runtime can survive the state when just allocating a new exception results in OOM seems to be very low, so it seems the new way would not make things worse in a general way. |
janvorli
left a comment
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, thank you!
|
Regarding:
My reasoning is that since we cannot provide the "right" exception, because we cannot allocate it, giving OOM would be fairly truthful - we are in a state where we cannot function normally because of memory shortage. User can try handle the situation by trimming memory use or at least will see OOM in Watson/dump and have a bit more info about environment at the time of the crash. |
|
Thanks!!! |
stephentoub
left a comment
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!
Main assumptions:
Resolves:#44442