yoavbls / pretty-ts-errors

๐Ÿ”ต Make TypeScript errors prettier and human-readable in VSCode ๐ŸŽ€
https://marketplace.visualstudio.com/items?itemName=yoavbls.pretty-ts-errors
MIT License
13.29k stars 89 forks source link

Typing gets laggy (UI hangs for split seconds) when using this extension #36

Closed felixfbecker closed 1 year ago

felixfbecker commented 1 year ago

Type: Bug

I absolutely love this extension and can't live without it. But I noticed that I very consistently have lags in typing when using it (the UI will freeze for split seconds while typing). I don't know what the reproduction steps are, but I used the Extension Bisect tool to identify that this only happens when the extension is active (and very consistently) and never when the extension is deactivated.

Extension version: 0.2.8 VS Code version: Code 1.77.3 (704ed70d4fd1c6bd6342c436f1ede30d1cff4710, 2023-04-12T09:41:48.638Z) OS version: Darwin arm64 22.3.0 Modes: Sandboxed: Yes

System Info |Item|Value| |---|---| |CPUs|Apple M1 Pro (10 x 24)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off| |Load (avg)|7, 7, 7| |Memory (System)|32.00GB (0.09GB free)| |Process Argv|--crash-reporter-id 9d8b3555-0016-4d38-9abf-4a1f6545cfc7| |Screen Reader|no| |VM|0%|
A/B Experiments ``` vsliv368cf:30146710 vsreu685:30147344 python383:30185418 vspor879:30202332 vspor708:30202333 vspor363:30204092 vslsvsres303:30308271 vserr242:30382549 pythontb:30283811 vsjup518:30340749 pythonptprofiler:30281270 vshan820:30294714 vstes263cf:30335440 vscorecescf:30445987 pythondataviewer:30285071 vscod805:30301674 binariesv615:30325510 bridge0708:30335490 bridge0723:30353136 cmake_vspar411:30581797 vsaa593cf:30376535 pythonvs932:30410667 cppdebug:30492333 vsclangdf:30486550 c4g48928:30535728 dsvsc012:30540252 pynewext54:30695312 azure-dev_surveyone:30548225 nodejswelcome1:30587005 3biah626:30602489 pyind779:30671433 89544117:30613380 pythonsymbol12:30671437 a9j8j154:30646983 vsctsb:30705553 functionswalk:30687959 pythonms35:30701012 pythonfmttextcf:30716743 ```
rdsedmundo commented 1 year ago

I'm also facing this. I suspected it had to do with this extension since it was the only recent I had added. I see the slowness the most when VSCode runs Prettier upon me saving the file.

yoavbls commented 1 year ago

@felixfbecker We have a lot to improve there, I still don't know about a specific thing with a significant performance impact. Any help in measuring and solving this problem will be appreciated ๐Ÿ™๐Ÿผ

@rdsedmundo I'm pretty sure it isn't related, the extension is not involved in file saving. it's just adding new diagnostics when TypeScript creates his diagnostics.

rdsedmundo commented 1 year ago

It is, I disabled and the error is gone. I did a bisect as the author suggested as well, it's definitely this extension the culprit.

felixfbecker commented 1 year ago

@yoavbls Given it blocks the UI, it leads me to believe that this must be happening in VS Code, since the extension runs in the extension host worker. So the only thing I can think of is that the amount (or frequency) of data the extension is giving VS Code overloads the UI process (or there is some inefficient code in VS Code). I'd probably go at this by using the Devtools in VS Code to capture a perf profile while it is happening and see where the CPU is spending its time.

aludvigsen commented 1 year ago

Yes, the extension is nice, but it totally kills VS Code.

yoavbls commented 1 year ago

@rdsedmundo It's weird. It shouldn't affect the file saves. Do you see something that could cause it? @felixfbecker that is a good idea. If someone wants to make some performance tests and spot the weak spots/functions that take the longest times to run it would be helpful.

I will investigate it deeper after the migration to a monorepo is completed

RobertOstermann commented 1 year ago

I haven't run into any performance issues yet, but haven't used the extension very much. Perhaps a short term solution for people running into this issue could be to have the extension run in a different process. Adding this to your settings.json should allow for the extension to use the second extension host process.

"extensions.experimental.affinity": {
    "yoavbls.pretty-ts-errors": 1,
},
counterbeing commented 1 year ago

@RobertOstermann I just ran into this issue, and found this thread by way of an extension bisect. I have a fairly complex type that I'm modifying with utility functions and doing a union on. So I think having such a heavy type is part of the problem for me. I just wanted to share that it seems your suggestion really cut down on the lag. Typing was unresponsive for 10+ seconds at a time for each key stroke.
With the change you mention, things are much better! Seems like a good workaround for the time being.

kevinbailey25 commented 1 year ago

I will second this, vscode has been very sluggish lately with this extension. I've disabled it for now. This extension has been a MAJOR help with the ts errors for newer devs on my team, hope these issues can get resolved. Wish I had more free time to help.

yoavbls commented 1 year ago

v0.5 just published with a new caching mechanism ๐Ÿ•บ๐Ÿผ Try it out, it should solve these performance issues https://github.com/yoavbls/pretty-ts-errors/releases/tag/v0.5.0