PowerShellEditorServices icon indicating copy to clipboard operation
PowerShellEditorServices copied to clipboard

Add Breakpoint Label frame to optimize debug stepping performance

Open JustinGrote opened this issue 1 year ago • 2 comments

PR Summary

Implements DAP DelayedStackTraceLoading and returns an artificial breakpoint label frame based on the invocation info ASAP once the debugger stops. The rest of the stack trace is then returned on a future request that doesn't block the client UI.

https://github.com/user-attachments/assets/b909655b-1085-4f8e-a453-99b8af21b877

PR Context

Debug stepping takes 300ms+ due to waiting for stack trace collection via the slow Get-PSCallStack "hack". Further improvements will come around this later.

JustinGrote avatar Oct 12 '24 22:10 JustinGrote

@SeeminglyScience @andyleejordan I made this a fairly minimal PR to be easy to review. Additional things I plan to do next as future incrementals

  • Add start/end/column positioning to all stack frames (it's available in the position property, just has to be serialized properly)
  • Separate variable and frame processing into independent resolution paths
  • Implement "fast path" for local runspace sessions to use the runspace debugger properties and methods rather than going thru the pipeline to fetch the frame info, ~2-3ms vs 300ms-800ms
  • Move all the scope/stack/variable resolution to a new async-based DebugStoppedContext class that can be disposed and re-instantiated cleanly and kept separate from the DebugService concerns, since LSP spec says no IDs/etc. should be reused between debug adapter stop/resumes

JustinGrote avatar Oct 12 '24 22:10 JustinGrote

@SeeminglyScience @andyleejordan I made this a fairly minimal PR to be easy to review. Additional things I plan to do next as future incrementals

  • Add start/end/column positioning to all stack frames (it's available in the position property, just has to be serialized properly)
  • Separate variable and frame processing into independent resolution paths
  • Implement "fast path" for local runspace sessions to use the runspace debugger properties and methods rather than going thru the pipeline to fetch the frame info, ~2-3ms vs 300ms-800ms
  • Move all the scope/stack/variable resolution to a new async-based DebugStoppedContext class that can be disposed and re-instantiated cleanly and kept separate from the DebugService concerns, since LSP spec says no IDs/etc. should be reused between debug adapter stop/resumes

I'm super excited for all of this.

andyleejordan avatar Oct 14 '24 19:10 andyleejordan

This has been rebased to the latest prerelease and is good for re-review.

JustinGrote avatar Nov 19 '24 00:11 JustinGrote

@andyleejordan @SeeminglyScience your opinions have officially been deemed irrelevant by our AI overlords, please approve as is /s image

JustinGrote avatar Nov 26 '24 20:11 JustinGrote

All feedback should be addressed. I also removed some of the TraceOutput log stuff I was experimenting with, I'm going to submit a separate test-specific PR to revamp the DAP E2E tests.

JustinGrote avatar Dec 02 '24 05:12 JustinGrote

@andyleejordan this wording sounded so unnecessarily passive aggressive, LOL image

Thanks! Excited to speed this up, it's annoyed me for YEARS.

JustinGrote avatar Dec 03 '24 22:12 JustinGrote