razor icon indicating copy to clipboard operation
razor copied to clipboard

Slow OnAutoInsert for brace completion

Open gundermanc opened this issue 3 years ago • 5 comments

Describe the bug: Typing '\n' in a C# block in Razor results in slow brace completion edits, which can feel somewhat jarring.

Version used: e.g. VS2022 17.2 Preview 3

To reproduce: Steps to reproduce the behavior:

  1. Create a new Blazor app
  2. Open Index.razor
  3. Add a C# block @{}
  4. Type some {} inside of the c# block.
  5. Press ENTER

Expected behavior: Brace completion completes immediately.

Actual behavior: It seems to consistently take 1-2 seconds. Possib

JarringSlowEdit le dupe of #5617?

gundermanc avatar Mar 11 '22 01:03 gundermanc

Related VS language server client protocol issue: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1488456.

@NTaylorMullen any recommendations on what to do when LS is slow like this?

  • Option 1 - cancel if the caret has moved.
  • Option 2 - cancel if some timeout elapses (1-2 seconds?)
  • Option 3 - apply the edit anyways at the original location
  • Option 4 - apply the edit anyways at caret position, but only if it got there via typing.

I'm leaning toward option 4, as scrolling away and seeing the text suddenly change 2-3 seconds later is a bit jarring.

**cc: ** @dibarbet

gundermanc avatar Mar 11 '22 01:03 gundermanc

For whatever it is worth, Roslyn perf appears to be acceptable - with a p99.9 of 1.2-1.5s and p90 of 25ms image

dibarbet avatar Mar 11 '22 01:03 dibarbet

Razor definitely seem to be where the slowdown comes in but nothing like 1-2s. Based on telemetry the worst case scenario averages around 673ms but the 90th percentile is around 180ms. I wouldn't be surprised if it was Razor's formatting perf influencing this

NTaylorMullen avatar Mar 11 '22 16:03 NTaylorMullen

nothing like 1-2s

The one other possibility is that our switch to main thread is so low priority it's delayed. I'll look into that..

gundermanc avatar Mar 11 '22 17:03 gundermanc

@gundermanc Is there any update on this issue?

allisonchou avatar Apr 07 '22 22:04 allisonchou