microsoft / ConcordExtensibilitySamples

Visual Studio Debug Engine Extensibility Samples
Other
122 stars 50 forks source link

Performance problem, when a lot of local variables. #35

Closed onor13 closed 7 years ago

onor13 commented 7 years ago

Hello, the debugger I am implementing must deal with up to 3 000 local variables, sometimes even more. Each variable is an object containing some information that will be displayed in the Visual Studio « Locals » window. So my Expression Compiler generate the PE, as described here https://github.com/Microsoft/ConcordExtensibilitySamples/wiki/CLR-Expression-Evaluators, containing up to 3 000 methods (1 for each variable), where each of this methods returns a custom object. The problem is when the debugger enters IDkmClrResultProvider.GetResult method, all the 3000 methods from PE are already evaluated, which takes a lot of time for some reason. I noticed that the debugger spends about 12-15 seconds (on my Intel-i7 laptop) between the end of IDkmClrExpressionCompiler.GetClrLocalVariableQuery method and the start of IDkmClrResultProvider.GetResult method on every Debug Step Over. Is it possible to make this evaluation lazy? Because the list of the variables is so long, in the Visual Studio locals windows they are not all visible at once, the user has to Scroll Down/Up to see the rest of the variables. Similar lazy evaluation already exists when displaying arrays in the IDkmClrResultProvider.GetItems(DkmEvaluationResultEnumContext enumContext, DkmWorkList workList, int startIndex, int count, DkmCompletionRoutine completionRoutine) method, where only the COUNT number of variables are displayed. Is there anything I can do, like implementing some additional interfaces in order to improve the performance of the debugger?

Vladimir.

kelltrick commented 7 years ago

@plnelson, we always evaluate all locals in scope, or is that something that can be controlled?

plnelson commented 7 years ago

I haven't investigated. However, both Concord and AD7 APIs support getting partial lists of locals so presumably the UI is asking for all locals at once. Seems reasonable to get all locals at once to avoid round trips between local/remote though this won't work too well if there are thousands of locals :-)