-
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
Improve performance of Debugger.NotifyOfCrossThreadDependency under a debugger #101864
Conversation
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.
Your hashtable definition has some optional features enabled that are unneeded, but otherwise looks great!
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.
I have a couple of questions.
|
||
bool IsNull() const | ||
{ | ||
return m_module == NULL && m_typeDef == 0; |
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.
Why is there an && here instead of an ||?
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.
I have && because the NULL TypeInModule is defined as a NULL m_module pointer and a 0 m_typeDef. If one of them is true but not the other, it means that something has created a TypeInModule with invalid data, which is different than a NULL TypeInModule. We shouldn't ever see one or the other, only both
|
||
INT32 Hash() const | ||
{ | ||
return (INT32)((UINT_PTR)m_module ^ m_typeDef); |
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.
Why did you choose to use this hash function?
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.
For a hash function you want it to be quick to calculate, and also relatively unique to each entry. This is very quick to compute and should be unique most of the time. On 64 bit platforms there is a very low chance that the lower 32 bits of a module could be the same as another module and the typeDef could be repeated.
[celebrate] Noah Falk reacted to your message:
…________________________________
From: David Mason ***@***.***>
Sent: Tuesday, May 7, 2024 2:47:40 AM
To: dotnet/runtime ***@***.***>
Cc: Noah Falk ***@***.***>; Review requested ***@***.***>
Subject: Re: [dotnet/runtime] Improve performance of Debugger.NotifyOfCrossThreadDependency under a debugger (PR #101864)
Merged #101864<#101864> into main.
—
Reply to this email directly, view it on GitHub<#101864 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ABPULQHOUQY3UOL636FIOADZBA6EZAVCNFSM6AAAAABHGFITLKVHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJSG4ZDENJZGEYTMOA>.
You are receiving this because your review was requested.Message ID: ***@***.***>
|
Looking forward to experiencing the results immediately 🎉 |
Consider back-porting this fix to DotNet 8 since DotNet 9 is a not a LTS release. |
We wouldn't generally backport performance improvements (even large ones). Part of that is mitigating risk that we introduce a new bug in the servicing release and part is that time spent backporting changes to past releases is time not spent making other improvements. We can certainly see what other feedback we get on this though - its not a foregone conclusion. In the meantime for many .NET apps you can successfully roll them forward to a new version of .NET runtime without needing to change code or rebuild. Even if you stay on an LTS version for shipping an app that shouldn't mean you are constrained to only debug using that same runtime version. |
Fixes #38736
Currently the filtering for whether or not we send notifications lives on the ICorDebug side, which means for every call when a debugger is attached we do all the work to pause the runtime and send an IPC event. This changes the filtering to happen on the runtime side and only send an IPC event if the debugger wants to receive it.
Running the perf test from here: #38736 (comment) on my development machine I get the following results for a speedup of ~40x.