You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Resolving stack traces is very slow in large applications (DebuggerMethodInfoTable is a poor performing hashtable) #11056
DebuggerMethodInfoTable is based on CHashTable - a chaining hashtable that never rehashes as it grows, thus it has O(N) lookup performance rather than O(1) you would expect from a hashtable. I don’t know if there is some historical rationale for why this poorly scaling hashtable was used, but I do see comments in the code suggesting it is deprecated and that nothing else in the runtime should use it. The code declares 101 buckets, so average chain length would be num_methoddefs_loaded/101. It seems quite plausible that a big app would have 1M+ methods so an average chain size of 10,000. Not a fast lookup at all.
When doing stack trace resolution we lookup each frame in the stack in this table, all of the lookups are done synchronized under a debugger lock, and the entire operation is cooperative mode. This can cause large apps that frequently throw exceptions and log their stacks to have abnormally long GC pause times.
I don't know how all the pieces fit together well enough to know if this counts as a real world example, but I'll present it briefly and you guys can decide if it's relevant.
We captured a trace of a largish applicaton with vsdiagnostics.exe. When examining the resulting .diagsession file in VS, the next-to-top hit for Self CPU was DebuggerMethodInfoTable::Cmp (top was memset, 3rd was JIT_ByRefWriteBarrier, then it got into application code). Which is how I got here. Take if it fits, ignore it if it don't.
(Perhaps I should note that AppDynamics and Stackify were also present on this system. Not sure if that matters or not)
No, there are some cases in which you will see this at runtime. Particularly symbolication of an exception might hit this. Other than that - diagnostic scenarios are the main perf impact
No, there are some cases in which you will see this at runtime. Particularly symbolication of an exception might hit this. Other than that - diagnostic scenarios are the main perf impact
Thanks for the response. I was trying to figure out if this code will be hit during 'normal running of an application'- i.e., will optimizing it have any effect if application is running as expected(gauging importance of optimizing it). 'symbolization of an exception' I assume is something that needs to happen if there is a need to get call stack as a result of encountering an exception which I assume is a rare occurrence. Please feel free to correct me if I am wrong.
No, there are some cases in which you will see this at runtime. Particularly symbolication of an exception might hit this. Other than that - diagnostic scenarios are the main perf impact
Thanks for the response. I was trying to figure out if this code will be hit during 'normal running of an application'- i.e., will optimizing it have any effect if application is running as expected(gauging importance of optimizing it). 'symbolization of an exception' I assume is something that needs to happen if there is a need to get call stack as a result of encountering an exception which I assume is a rare occurrence. Please feel free to correct me if I am wrong.
Sorry to bother you guys again and my apologies if I missed anything from the original reply but it would be nice to get a confirmation re above questions. I'm not really familiar with diagnostics part of runtime and would appreciate some feedback here
Will suboptimal implementation in 'DebuggerMethodInfoTable' have any effect on performance during regular execution - i.e., it's not a factor unless there is a profiler attached, exception causing runtime to figure out call stack or any other unusual events
is CHashTable used else where or is it specific to 'DebuggerMethodInfoTable'. This is the other one that pops in the profile I have. The issue here is I see some comments there which indicates this can be further optimized but I'm trying to figure out the impact on real-world and it's hard to make that determination from profile unless I know which functions in there are showing up specifically due to the profiler being attached
Edit : Adding what seem like a relevant issue that's planned to be worked on : Poorly performing hash used in the DBI/EE #11466
It's used elsewhere, and it's brittle to change CHashTable. A better thing is to move to SHash. And it's more than a profiler scenario. A common pattern is something like
try{thrownewException();}catch(Exceptionex){logger.Warn("Operation failed with exception: {exception}",ex);}
It's used elsewhere, and it's brittle to change CHashTable. A better thing is to move to SHash. And it's more than a profiler scenario. A common pattern is something like
try{thrownewException();}catch(Exceptionex){logger.Warn("Operation failed with exception: {exception}",ex);}
Thank you. I see a separate issue for this that's tagged for 9.0 (#11466). Would I be correct in assuming this is planned to be worked on for the next release?
Activity
UniverseHan commentedon Oct 2, 2018
@mikem8361 I wanna try this. Could I ?
mikem8361 commentedon Oct 2, 2018
I have no problem with it.
nonbob commentedon Jan 11, 2022
I don't know how all the pieces fit together well enough to know if this counts as a real world example, but I'll present it briefly and you guys can decide if it's relevant.
We captured a trace of a largish applicaton with vsdiagnostics.exe. When examining the resulting .diagsession file in VS, the next-to-top hit for Self CPU was DebuggerMethodInfoTable::Cmp (top was memset, 3rd was JIT_ByRefWriteBarrier, then it got into application code). Which is how I got here. Take if it fits, ignore it if it don't.
(Perhaps I should note that AppDynamics and Stackify were also present on this system. Not sure if that matters or not)
DeepakRajendrakumaran commentedon Jan 8, 2024
I've seen this same thing when looking at VTune profiles for some real world apps.
My main question is - is this a profiler only method? i.e., will this be called when profiler is not attached?
hoyosjs commentedon Jan 9, 2024
No, there are some cases in which you will see this at runtime. Particularly symbolication of an exception might hit this. Other than that - diagnostic scenarios are the main perf impact
DeepakRajendrakumaran commentedon Jan 9, 2024
Thanks for the response. I was trying to figure out if this code will be hit during 'normal running of an application'- i.e., will optimizing it have any effect if application is running as expected(gauging importance of optimizing it). 'symbolization of an exception' I assume is something that needs to happen if there is a need to get call stack as a result of encountering an exception which I assume is a rare occurrence. Please feel free to correct me if I am wrong.
DeepakRajendrakumaran commentedon Jan 16, 2024
@hoyosjs @cshung @mikem8361 @tannergooding @BruceForstall
Sorry to bother you guys again and my apologies if I missed anything from the original reply but it would be nice to get a confirmation re above questions. I'm not really familiar with diagnostics part of runtime and would appreciate some feedback here
DebuggerMethodInfoTable' have any effect on performance during regular execution - i.e., it's not a factor unless there is a profiler attached, exception causing runtime to figure out call stack or any other unusual eventsCHashTableused else where or is it specific to 'DebuggerMethodInfoTable'. This is the other one that pops in the profile I have. The issue here is I see some comments there which indicates this can be further optimized but I'm trying to figure out the impact on real-world and it's hard to make that determination from profile unless I know which functions in there are showing up specifically due to the profiler being attachedEdit : Adding what seem like a relevant issue that's planned to be worked on : Poorly performing hash used in the DBI/EE #11466
hoyosjs commentedon Jan 17, 2024
It's used elsewhere, and it's brittle to change
CHashTable. A better thing is to move toSHash. And it's more than a profiler scenario. A common pattern is something likeDeepakRajendrakumaran commentedon Jan 17, 2024
Thank you. I see a separate issue for this that's tagged for 9.0 (#11466). Would I be correct in assuming this is planned to be worked on for the next release?
davidwrighton commentedon Feb 16, 2024
Yes, we plan to work on this next release. We may or may not fix it by fixing the hash tables in the debugger.
This is a small test app which shows the problem.
DeepakRajendrakumaran commentedon Feb 16, 2024
Thanks for the test code. I'll check it out locally.
I'm not going to attempt to fix it myself seeing that you guys already are planning to do this.