language-tools: Extension slow to respond
Describe the bug
Getting auto-completion, symbol navigation or symbol information can be very slow (tooltip stuck on Loading...
).
(It is probably the language server, because the profile from “Running Extensions” does not pick it up as causing CPU load.)
To Reproduce Invoke commands like “Trigger Suggest” and “Go to Definition”.
As for the conditions necessary to cause the slowdown, i am not sure. It may have to do with using carbon-components-svelte
/carbon-icons-svelte
which introduce a lot of Svelte files.
The “Output” panel shows this for Svelte:
SnapshotManager File Statistics:
Project files: 26022
Svelte files: 7210
From node_modules: 33251
Total: 33276
Expected behavior Language features are reasonably fast.
Screenshots
System (please complete the following information):
- OS: Windows 10, 64bit
- IDE: VSCode
- Plugin/Package: Svelte for VSCode
About this issue
- Original URL
- State: open
- Created 3 years ago
- Comments: 59 (29 by maintainers)
Commits related to this issue
- (perf) add priority queue Give certain requests priority. If a request doesn't have priority, we first wait 1 second to 1. let higher priority requests get through first 2. wait for possible document... — committed to dummdidumm/language-tools by deleted user 3 years ago
- (perf) add priority queue (#1144) Give certain requests priority. If a request doesn't have priority, we first wait 1 second to 1. let higher priority requests get through first 2. wait for possib... — committed to sveltejs/language-tools by dummdidumm 3 years ago
Please open a separate issue with reproduction on the problematic HTML. Usually, the ts/js part is much more heavy because the cross-file semantic analysis is needed. If I have to make a wild guess, it may be that your style tag or template preprocess is too heavy.
+1. Steps to produce:
store.<methods hopefully here>
I wish I could provide a better reproducable example but the project seems to need to be of sufficient size to trigger whatever rapid degradation in performance is occurring. As you can see from the log below, the code action takes 11 seconds to complete on an M1 Macbook Pro. Svelte may be trying to do too much work on its end rather than simply proxying to the TS server. The tsconfig explicitly ignores node_modules but they’re showing up in the snapshot.
Snapshot
Here’s the tsconfig:
Same here with 1.5K lines:
Did you manage to fix it?
My apologies, I should have provided better feedback than that 🥲
I am not using the transformation. I have disabled diagnostics. I am using the latest svelte extension.
I have fixed my problem by changing my project dependencies packages versions…would have to pinpoint which one was causing the issue. Updated deps:
svelte-preprocess@4.10.1=>4.9.8
This is a rollbacksvelte@3.44.0=>3.46.3
typescript@4.4.3=>4.5.5
After making these changes, the extension is now working fine.
Ok, so I also did not see this reproduce when I tried in in VSCode proper, but I did figure out my particular issue.
Since
svelte-language-server
is linked totypescript@*
, yarn was just never upgrading it incoc-svelte
and it was still pointing to version 4.1.3. There have been a bunch of performance fixes in typescript for pnpm repositories, and indeed, after forcing it to upgrade to latest typescript it’s just as fast with pnpm as with yarn.Unfortunately this won’t really help anyone else having performance issues, but consider my problems done 😃. I am still seeing it slow with both Neovim and VSCode on really large Svelte files (like 2000 lines) with tons of reactive statements, but that’s less concerning.
Ah, I’m using Linux, Ubuntu 21.04, so that’s probably related… The pnpm/yarn difference makes me think it’s something related to symlinks, and so the Linux/Windows difference could be relevant here 😃. Using svelte-language-server 0.14.8, but I can try with VSCode as well.
Thanks for the link to the setup instructions. I’m pretty sure I can look into this further over the next few days so I’ll hopefully have some updates soon!
In my experience PNPM is a significant factor here. I’ve been seeing performance problems in the autocomplete as well and if I install my project’s dependencies with Yarn instead then it’s a lot faster. 5-7 seconds with pnpm compared to a second or so with Yarn on my system. And this only happens in Svelte files; plain Typescript files perform great.
The public project I’m working on that exposes this the most is at https://github.com/dimfeld/ergo. It’s not really minimal but hopefully it’ll help. The specific steps I’m doing are:
cd web
pnpm i
src/components/Query.svelte
.I’m actually using Neovim but my language server dependencies are up to date. I wouldn’t expect VS Code to be any different here.
If I have some time this week I’ll try to dive in more to see where exactly in the language server internals is running slowly.
This does not use sapper or svelte-kit. Have a look at what
carbon-icons-svelte
exposes: https://unpkg.com/carbon-icons-svelte@10.36.0/lib/index.js All of those are separate.svelte
files.If i were to exclude that, i would lose the completion for that, though, right?