Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extension slow to respond #1130

Open
brunnerh opened this issue Aug 4, 2021 · 59 comments
Open

Extension slow to respond #1130

brunnerh opened this issue Aug 4, 2021 · 59 comments
Labels
perf Performance

Comments

@brunnerh
Copy link
Member

brunnerh commented Aug 4, 2021

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
image

System (please complete the following information):

  • OS: Windows 10, 64bit
  • IDE: VSCode
  • Plugin/Package: Svelte for VSCode
@brunnerh brunnerh added the bug Something isn't working label Aug 4, 2021
@jasonlyu123
Copy link
Member

jasonlyu123 commented Aug 4, 2021

I did encounter a similar issue before. Still can't found out why, but it maybe is slowing down in the typescript language service part. It only pops up occasionally for me so this is not easy to debug.
Some other context might help. Do you use pnpm? There's seem to be some pnpm issues in the typescript repo. And what version of svelte for vscode you're using? if it's 105.3.3, does roll back to 105.3.1 helps? Or does turning off typescript.suggest.includeCompletionsForImportStatements and javascript.suggest.includeCompletionsForImportStatements helps?

@stolinski
Copy link

stolinski commented Aug 4, 2021

We're having major slowdown and often get a pop up saying that VSCode is waiting of the Svelte formatter.

Some details
v. 105.3.3
Svelte Kit App
TS for js
Scss for css
NOT using pnpm, just npm.

Giving typescript.suggest.includeCompletionsForImportStatements a try

@jasonlyu123
Copy link
Member

I publish a new version(105.3.4). Hope this would address the performance issues you're facing.

@brunnerh
Copy link
Member Author

brunnerh commented Aug 5, 2021

That might have fixed it. Right now the file statistics do not grow as much as previously:

SnapshotManager File Statistics:
Project files: 21
Svelte files: 6
From node_modules: 382
Total: 404

@brunnerh
Copy link
Member Author

brunnerh commented Aug 5, 2021

I will have to revoke that statement.
After working on a Svelte file, opening a new element tag, trying to get import suggestions, it started to load a lot of the other files again and slowed down to a crawl.

SnapshotManager File Statistics:
Project files: 26022
Svelte files: 6
From node_modules: 26040
Total: 26066
SnapshotManager File Statistics:
Project files: 26022
Svelte files: 7
From node_modules: 26041
Total: 26067
SnapshotManager File Statistics:
Project files: 26022
Svelte files: 2420
From node_modules: 28454
Total: 28480

Turning off the includeCompletionsForImportStatements options might have helped, but i should probably test a bit longer.

After a while with includeCompletionsForImportStatements turned off i also managed to trigger a load of thousands of files again, more or less freezing the server

SnapshotManager File Statistics:
Project files: 26022
Svelte files: 7
From node_modules: 26041
Total: 26066
SnapshotManager File Statistics:
Project files: 26022
Svelte files: 3080
From node_modules: 29114
Total: 29139
SnapshotManager File Statistics:
Project files: 26022
Svelte files: 6294
From node_modules: 32328
Total: 32353

@brunnerh
Copy link
Member Author

brunnerh commented Aug 5, 2021

Tried downgrading to version 105.3.1; it also has this problem.
I am not using pnpm.

I think that i could work or Carbon projects without the freezes at some point. When I have some more time i could try to bisect the extension version, but any help in that regard would also be appreciated.

@jasonlyu123
Copy link
Member

Do you have a tsconfig.json or jsconfig.json? It looks like maybe your problem isn't about the recent updates.

@brunnerh
Copy link
Member Author

brunnerh commented Aug 5, 2021

My tsconfig.json currently looks like this:

{
	"compilerOptions": {
		"strict": true,
		"moduleResolution": "node",
		"target": "es6",
		"lib": ["ES2020", "DOM", "DOM.Iterable"],
		"sourceMap": true,
		"importsNotUsedAsValues": "error", /* for svelte-preprocess */
		"resolveJsonModule": true,
		"allowSyntheticDefaultImports": true,
		"allowJs": true,
		"skipLibCheck": true,
	},
	"exclude": ["out/**/*"],
}

I can also try to put together a repro repository later.

@jasonlyu123
Copy link
Member

You can try excluding node_modulus and build directories like __sapper__ or .svelte-kit. From the number of svelte files, I guess it is some sort of hashed generated files.

@brunnerh
Copy link
Member Author

brunnerh commented Aug 5, 2021

This does not use sapper or svelte-kit.
Have a look at what carbon-icons-svelte exposes: https://unpkg.com/[email protected]/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?

@jasonlyu123
Copy link
Member

carbon-icons-svelte have provided typescript definitions. So it's safe to exclude the source files.

@brunnerh
Copy link
Member Author

brunnerh commented Aug 6, 2021

I tried excluding node_modules, worked on a project for a few hours and the issue did not come up.

@dummdidumm
Copy link
Member

Did the slowness in any way creep back or can we close this?

@brunnerh
Copy link
Member Author

@dummdidumm Would be fine by me. Don't know about @stolinski's issue though.

@andreavaccari
Copy link

andreavaccari commented Aug 23, 2021

Hi, I'm also experiencing significant slowdowns with the latest version of the Svelte extension.

I'm also using carbon-components-svelte. I have not been able to pinpoint the root problem.

This is the process hogs my cpu and makes both VS Code and my entire system barely usable:

Code Helper (Renderer) --experimental-modules /Users/andvac/.vscode/extensions/svelte.svelte-vscode-105.3.4/node_modules/svelte-language-server/bin/server.js

I'd be happy to provide logs/dumps to help sort this out.

@andreavaccari
Copy link

I'd like to give more context because I suspect my issues are caused by our monorepo setup:

monorepo/
├─ node_modules/
├─ packages/
│  ├─ package1/
│  │  ├─ tsconfig.json
│  │  ├─ vite.config.js
│  ├─ package2/
│  │  ├─ tsconfig.json
│  │  ├─ vite.config.js
├─ svelte.config.js
├─ tsconfig.json
├─ tsconfig.base.json
  • Each package has a vite.config.js that calls svelte({ configFile: "../../svelte.config.js" })
  • Each package has a tsconfig.json that extends /tsconfig.base.json and excludes node_modules
  • The other tsconfig.json in the monorepo root only includes project references to some packages.

When looking at the output of the Svelte extension, I notice two possible issues:

  • There are multiple consecutive lines of Using Svelte v3.42.2 from... without any statistics printed
  • The stats on files processed vary wildly.

We have many small packages, and the stats usually look like this:

Project files: 5
Svelte files: 8
From node_modules: 416
Total: 555

But then sometimes they look like this:

Project files: 484
Svelte files: 66
From node_modules: 596
Total: 1062

I hope this long comment is helpful and I'd be happy to provide more info.

My current setup is barely usable and I would really appreciate your help.

dummdidumm pushed a commit to dummdidumm/language-tools that referenced this issue Aug 24, 2021
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 changes, which make the request wait again

This hopefully makes perceived responsiveness of the language server better
sveltejs#1098, sveltejs#1130, sveltejs#1139
dummdidumm added a commit that referenced this issue Aug 24, 2021
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 changes, which make the request wait again

This hopefully makes perceived responsiveness of the language server better
#1098, #1130, #1139
@dummdidumm
Copy link
Member

The latest release includes some performance improvements, for example completions should have higher priority now. Please let me know if it improved for you.
When you say "barely usable", which parts are those where you experience the slowness? Completion, diagnostics, ..?
Also, could you add "svelte.trace.server": "messages" to your user settings JSON, then reproduce your slowness for 1-2 minutes and then copy the output of the Svelte extension in here? I'm interested in the response times that are logged for the various requests.

@andreavaccari
Copy link

Hi @dummdidumm, thank you for looking into this. I've added a settings and I'll share the output asap.

The most notable slowdowns are when VS Code is waiting for code actions from the Svelte extension:

  • I enabled save on blur on so this happens a lot with my setup.
  • In these situations, a file can take from several seconds to over a minute to save.
  • I often have to cancel the code actions by clicking cancel on the VS Code popup.
  • This saves the file but svelte-language-server/bin/server.js continues to churn in the background.
  • While it's churning, everything is slow: the cursor is jittery, switching windows is sluggish, ...
  • I'm on a maxed out Macbook Pro 16in so my hardware shouldn't be the problem.

@dummdidumm
Copy link
Member

dummdidumm commented Aug 24, 2021

When you say "code actions" do you only refer to saving specifically, or other code actions as well? I guess while saving, you also format the code? What if you turn off "format on save" (if my guess is right; just for testing), is it then fast again? I ask this because the Svelte for VS Code extension by default is also responsible for formatting the code. Or do did you set the Prettier extension as the default formatter for Svelte files?

@andreavaccari
Copy link

I use this extension for formatting .svelte files and my code actions on save are:

  • editor.formatOnSave
  • source.organizeImports
  • source.fixAll
  • source.addMissingImports

Q: Should I only disable editor.formatOnSave or also the other options?

I haven't started coding yet so I haven't bumped into the issue, but I figured I would share the output of the extension after a clean open of the monorepo main directory with "svelte.trace.server": "messages". Note the last line[Trace - 10:25:31 AM] Received response 'textDocument/codeAction - (16)' in 48636ms.

[Trace - 10:24:30 AM] Sending request 'initialize - (0)'.
Initialize language server at  file:///Users/andreavaccari/monorepo
[Trace - 10:24:31 AM] Received response 'initialize - (0)' in 1121ms.
[Trace - 10:24:31 AM] Sending notification 'initialized'.
[Trace - 10:24:31 AM] Sending notification 'workspace/didChangeConfiguration'.
[Trace - 10:24:31 AM] Sending notification 'textDocument/didOpen'.
[Trace - 10:24:31 AM] Sending notification 'textDocument/didOpen'.
Initialize new ts service at  /Users/andreavaccari/monorepo/packages/ui-viewer/tsconfig.json
[Trace - 10:24:31 AM] Sending request 'textDocument/documentSymbol - (1)'.
[Trace - 10:24:31 AM] Sending request 'textDocument/codeAction - (2)'.
[Trace - 10:24:31 AM] Sending request 'textDocument/codeAction - (3)'.
[Trace - 10:24:31 AM] Sending request 'textDocument/documentColor - (4)'.
[Trace - 10:24:31 AM] Sending request 'textDocument/documentColor - (5)'.
[Trace - 10:24:31 AM] Sending request 'textDocument/linkedEditingRange - (6)'.
[Trace - 10:24:31 AM] Sending request 'textDocument/linkedEditingRange - (7)'.
Trying to load configs for /Users/andreavaccari/monorepo/packages/ui-viewer
Initialize new ts service at  /Users/andreavaccari/monorepo/packages/app-review/tsconfig.json
Trying to load configs for /Users/andreavaccari/monorepo/packages/app-review
[Trace - 10:24:31 AM] Sending request 'textDocument/semanticTokens/range - (8)'.
[Trace - 10:24:31 AM] Sending request 'textDocument/semanticTokens/range - (9)'.
[Trace - 10:24:31 AM] Received response 'textDocument/codeAction - (2)' in 123ms.
[Trace - 10:24:31 AM] Received response 'textDocument/codeAction - (3)' in 124ms.
[Trace - 10:24:31 AM] Received response 'textDocument/linkedEditingRange - (6)' in 140ms.
Loaded config at  /Users/andreavaccari/monorepo/svelte.config.js
SnapshotManager File Statistics:
Project files: 6
Svelte files: 4
From node_modules: 0
Total: 6
SnapshotManager File Statistics:
Project files: 9
Svelte files: 5
From node_modules: 0
Total: 9
[Trace - 10:24:31 AM] Received response 'textDocument/linkedEditingRange - (7)' in 249ms.
[Trace - 10:24:31 AM] Sending request 'textDocument/semanticTokens/full - (10)'.
[Trace - 10:24:31 AM] Sending request 'textDocument/semanticTokens/full - (11)'.
Using Svelte v3.42.2 from /Users/andreavaccari/monorepo/node_modules/svelte/compiler
[Trace - 10:24:32 AM] Sending notification '$/cancelRequest'.
[Trace - 10:24:32 AM] Sending request 'textDocument/documentSymbol - (12)'.
[Trace - 10:24:32 AM] Sending request 'textDocument/documentSymbol - (13)'.
Initialize new ts service at  /Users/andreavaccari/monorepo/packages/card-note/tsconfig.json
Trying to load configs for /Users/andreavaccari/monorepo/packages/card-note
[Trace - 10:24:34 AM] Sending notification '$/cancelRequest'.
[Trace - 10:24:34 AM] Sending request 'textDocument/documentColor - (14)'.
[Trace - 10:24:34 AM] Sending notification '$/cancelRequest'.
[Trace - 10:24:34 AM] Sending request 'textDocument/documentColor - (15)'.
Initialize new ts service at  /Users/andreavaccari/monorepo/packages/card-qa/tsconfig.json
Trying to load configs for /Users/andreavaccari/monorepo/packages/card-qa
[Trace - 10:24:38 AM] Received response 'textDocument/documentColor - (4)' in 6835ms.
[Trace - 10:24:38 AM] Received response 'textDocument/documentColor - (5)' in 6835ms.
[Trace - 10:24:38 AM] Received response 'textDocument/semanticTokens/range - (8)' in 6734ms.
[Trace - 10:24:38 AM] Received response 'textDocument/semanticTokens/range - (9)' in 6735ms.
[Trace - 10:24:38 AM] Received response 'textDocument/semanticTokens/full - (10)' in 6535ms.
Using Svelte v3.42.2 from /Users/andreavaccari/monorepo/node_modules/svelte/compiler
SnapshotManager File Statistics:
Project files: 15
Svelte files: 2
From node_modules: 0
Total: 15

warn - You have enabled the JIT engine which is currently in preview.
warn - Preview features are not covered by semver, may introduce breaking changes, and can change at any time.
Using Svelte v3.42.2 from /Users/andreavaccari/monorepo/node_modules/svelte/compiler
[Trace - 10:24:42 AM] Received response 'textDocument/documentSymbol - (1)' in 10948ms.
[Trace - 10:24:42 AM] Received response 'textDocument/semanticTokens/full - (11)' in 10645ms.
[Trace - 10:24:42 AM] Received notification 'textDocument/publishDiagnostics'.
[Trace - 10:24:42 AM] Received response 'textDocument/documentSymbol - (12)' in 9445ms.
[Trace - 10:24:42 AM] Received response 'textDocument/documentSymbol - (13)' in 9454ms.
[Trace - 10:24:42 AM] Received response 'textDocument/documentColor - (14)' in 8000ms.
[Trace - 10:24:42 AM] Received response 'textDocument/documentColor - (15)' in 8000ms.
[Trace - 10:24:42 AM] Sending request 'textDocument/codeAction - (16)'.
Using Svelte v3.42.2 from /Users/andreavaccari/monorepo/node_modules/svelte/compiler
[Trace - 10:25:31 AM] Received notification 'textDocument/publishDiagnostics'.
[Trace - 10:25:31 AM] Received response 'textDocument/codeAction - (16)' in 48636ms.

@andreavaccari
Copy link

andreavaccari commented Aug 24, 2021

I just bumped into the problem: slow autocompletion (on ctrl-space) and slow formatting:

Using Svelte v3.42.2 from /Users/andreavaccari/monorepo/node_modules/svelte/compiler
[Trace - 10:36:44 AM] Received notification 'textDocument/publishDiagnostics'.
[Trace - 10:36:44 AM] Received response 'textDocument/linkedEditingRange - (58)' in 50198ms.
[Trace - 10:36:44 AM] Received response 'textDocument/codeAction - (59)' in 50151ms.
[Trace - 10:36:44 AM] Received response 'textDocument/hover - (60)' in 49787ms.
[Trace - 10:36:44 AM] Received response 'textDocument/hover - (61)' in 43943ms.
[Trace - 10:36:44 AM] Received response 'textDocument/definition - (62)' in 43689ms.
[Trace - 10:36:44 AM] Received response 'textDocument/linkedEditingRange - (65)' in 42492ms.
[Trace - 10:36:44 AM] Received response 'textDocument/codeAction - (66)' in 42493ms.
[Trace - 10:36:44 AM] Received response 'textDocument/linkedEditingRange - (68)' in 42306ms.
[Trace - 10:36:44 AM] Received response 'textDocument/codeAction - (69)' in 42279ms.
[Trace - 10:36:44 AM] Received response 'textDocument/hover - (70)' in 41926ms.
[Trace - 10:36:44 AM] Received response 'textDocument/hover - (71)' in 41743ms.
[Trace - 10:36:44 AM] Received response 'textDocument/hover - (72)' in 41564ms.
[Trace - 10:36:44 AM] Received response 'textDocument/hover - (73)' in 40803ms.
[Trace - 10:36:44 AM] Received response 'textDocument/linkedEditingRange - (75)' in 37574ms.
[Trace - 10:36:44 AM] Received response 'textDocument/codeAction - (76)' in 37573ms.
[Trace - 10:36:44 AM] Received response 'textDocument/linkedEditingRange - (81)' in 33427ms.
[Trace - 10:36:44 AM] Received response 'textDocument/codeAction - (82)' in 33427ms.
[Trace - 10:36:44 AM] Received response 'textDocument/linkedEditingRange - (84)' in 33312ms.
[Trace - 10:36:44 AM] Received response 'textDocument/codeAction - (85)' in 33272ms.
[Trace - 10:36:44 AM] Received response 'textDocument/linkedEditingRange - (86)' in 32310ms.
[Trace - 10:36:44 AM] Received response 'textDocument/codeAction - (87)' in 32260ms.
[Trace - 10:36:44 AM] Received response 'textDocument/linkedEditingRange - (88)' in 30650ms.
[Trace - 10:36:44 AM] Received response 'textDocument/codeAction - (89)' in 30600ms.
[Trace - 10:36:44 AM] Received response 'textDocument/linkedEditingRange - (90)' in 30352ms.
[Trace - 10:36:44 AM] Received response 'textDocument/codeAction - (91)' in 30300ms.
[Trace - 10:36:44 AM] Received response 'textDocument/hover - (92)' in 25329ms.
[Trace - 10:36:44 AM] Received response 'textDocument/hover - (93)' in 24149ms.
[Trace - 10:36:44 AM] Received response 'textDocument/hover - (94)' in 21740ms.
[Trace - 10:36:44 AM] Received response 'textDocument/linkedEditingRange - (95)' in 21356ms.
[Trace - 10:36:44 AM] Received response 'textDocument/codeAction - (96)' in 21305ms.
SnapshotManager File Statistics:
Project files: 24
Svelte files: 44
From node_modules: 623
Total: 748
[Trace - 10:36:44 AM] Received response 'textDocument/completion - (97)' in 20969ms.
[Trace - 10:36:44 AM] Received response 'textDocument/linkedEditingRange - (98)' in 20970ms.
[Trace - 10:36:45 AM] Sending request 'completionItem/resolve - (102)'.
[Trace - 10:36:45 AM] Received response 'completionItem/resolve - (102)' in 42ms.
[Trace - 10:36:45 AM] Received response 'textDocument/documentSymbol - (63)' in 43490ms.
[Trace - 10:36:45 AM] Received response 'textDocument/documentColor - (64)' in 43490ms.
[Trace - 10:36:45 AM] Received response 'textDocument/documentSymbol - (67)' in 43492ms.
Using Svelte v3.42.2 from /Users/andreavaccari/monorepo/node_modules/svelte/compiler
[Trace - 10:36:46 AM] Received response 'textDocument/documentColor - (74)' in 39002ms.
[Trace - 10:36:46 AM] Received response 'textDocument/documentSymbol - (77)' in 39000ms.
[Trace - 10:36:46 AM] Received response 'textDocument/semanticTokens/full - (78)' in 38968ms.
[Trace - 10:36:46 AM] Received response 'textDocument/semanticTokens/range - (79)' in 38947ms.
[Trace - 10:36:46 AM] Received response 'textDocument/documentColor - (80)' in 34855ms.
[Trace - 10:36:46 AM] Received response 'textDocument/documentSymbol - (83)' in 34849ms.
[Trace - 10:36:46 AM] Received response 'textDocument/semanticTokens/full - (99)' in 22275ms.
[Trace - 10:36:46 AM] Received response 'textDocument/documentColor - (100)' in 21581ms.
[Trace - 10:36:46 AM] Received response 'textDocument/documentSymbol - (101)' in 21174ms.
[Trace - 10:36:52 AM] Sending request 'textDocument/formatting - (103)'.
Using Svelte v3.42.2 from /Users/andreavaccari/monorepo/node_modules/svelte/compiler
[Trace - 10:37:36 AM] Received notification 'textDocument/publishDiagnostics'.
Using Prettier v2.3.2 from /Users/andreavaccari/monorepo/node_modules/prettier
[Trace - 10:37:37 AM] Received response 'textDocument/formatting - (103)' in 44768ms.
[Trace - 10:37:37 AM] Sending notification 'textDocument/didChange'.
[Trace - 10:37:37 AM] Sending notification 'textDocument/didSave'.
[Trace - 10:37:37 AM] Sending request 'textDocument/linkedEditingRange - (104)'.
[Trace - 10:37:37 AM] Received response 'textDocument/linkedEditingRange - (104)' in 1ms.
[Trace - 10:37:37 AM] Sending request 'textDocument/semanticTokens/full - (105)'.
Using Svelte v3.42.2 from /Users/andreavaccari/monorepo/node_modules/svelte/compiler
[Trace - 10:37:38 AM] Sending request 'textDocument/documentColor - (106)'.
Using Svelte v3.42.2 from /Users/andreavaccari/monorepo/node_modules/svelte/compiler
Using Svelte v3.42.2 from /Users/andreavaccari/monorepo/node_modules/svelte/compiler
Using Svelte v3.42.2 from /Users/andreavaccari/monorepo/node_modules/svelte/compiler
[Trace - 10:37:39 AM] Received notification 'textDocument/publishDiagnostics'.
[Trace - 10:37:39 AM] Received notification 'textDocument/publishDiagnostics'.
Using Svelte v3.42.2 from /Users/andreavaccari/monorepo/node_modules/svelte/compiler
[Trace - 10:37:39 AM] Received notification 'textDocument/publishDiagnostics'.
[Trace - 10:37:39 AM] Received response 'textDocument/semanticTokens/full - (105)' in 1450ms.
Using Svelte v3.42.2 from /Users/andreavaccari/monorepo/node_modules/svelte/compiler
[Trace - 10:37:39 AM] Received notification 'textDocument/publishDiagnostics'.
[Trace - 10:37:39 AM] Sending request 'textDocument/codeAction - (107)'.
[Trace - 10:37:39 AM] Received response 'textDocument/codeAction - (107)' in 59ms.
[Trace - 10:37:39 AM] Received response 'textDocument/documentColor - (106)' in 1058ms.
[Trace - 10:38:10 AM] Sending request 'textDocument/documentSymbol - (108)'.
Using Svelte v3.42.2 from /Users/andreavaccari/monorepo/node_modules/svelte/compiler
[Trace - 10:38:28 AM] Received notification 'textDocument/publishDiagnostics'.
[Trace - 10:38:29 AM] Sending request 'textDocument/codeAction - (109)'.
[Trace - 10:39:08 AM] Received notification 'textDocument/publishDiagnostics'.
[Trace - 10:39:08 AM] Received response 'textDocument/documentSymbol - (108)' in 58252ms.
[Trace - 10:39:08 AM] Received response 'textDocument/codeAction - (109)' in 39482ms.
[Trace - 10:39:08 AM] Sending request 'textDocument/codeAction - (110)'.
[Trace - 10:39:08 AM] Received response 'textDocument/codeAction - (110)' in 1ms.

@dummdidumm
Copy link
Member

Ok these diagnostics look like it has nothing to do with formatting, it's only the most visible then, because something else blocks the thread and the formatter is waiting to get started for a long time. From looking at the logs it looks like it may be the diagnostics that take so long. What if happens if you turn them off?

"svelte.plugin.typescript.diagnostics.enable": false,
"svelte.plugin.svelte.diagnostics.enable": false

If it is much faster, try turning only one off to see which diagnostic part takes longer.

@andreavaccari
Copy link

Big improvement!

  • Some responses still take a few seconds
  • Prettier sneaks into the logs even though I explicitly set this extension as the formatter
  • Should I enable "svelte.enable-ts-plugin" in my settings.json?
[Trace - 10:45:23 AM] Sending notification 'textDocument/didChange'.
[Trace - 10:45:23 AM] Sending request 'textDocument/formatting - (31)'.
Using Prettier v2.3.2 from /Users/andreavaccari/monorepo/node_modules/prettier
[Trace - 10:45:23 AM] Sending request 'textDocument/linkedEditingRange - (32)'.
[Trace - 10:45:23 AM] Sending request 'textDocument/codeAction - (33)'.
[Trace - 10:45:23 AM] Received response 'textDocument/linkedEditingRange - (32)' in 51ms.
[Trace - 10:45:23 AM] Received response 'textDocument/codeAction - (33)' in 2ms.
[Trace - 10:45:23 AM] Sending request 'textDocument/semanticTokens/full - (34)'.
[Trace - 10:45:24 AM] Sending notification '$/cancelRequest'.
[Trace - 10:45:24 AM] Sending request 'textDocument/linkedEditingRange - (35)'.
[Trace - 10:45:24 AM] Sending request 'textDocument/codeAction - (36)'.
[Trace - 10:45:24 AM] Received response 'textDocument/formatting - (31)' in 763ms.
[Trace - 10:45:24 AM] Received notification 'textDocument/publishDiagnostics'.
[Trace - 10:45:24 AM] Received response 'textDocument/linkedEditingRange - (35)' in 175ms.
[Trace - 10:45:24 AM] Received response 'textDocument/codeAction - (36)' in 123ms.
[Trace - 10:45:24 AM] Sending notification 'textDocument/didSave'.
[Trace - 10:45:24 AM] Sending request 'textDocument/documentColor - (37)'.
[Trace - 10:45:25 AM] Received response 'textDocument/semanticTokens/full - (34)' in 1840ms.
[Trace - 10:45:25 AM] Received notification 'textDocument/publishDiagnostics'.
[Trace - 10:45:25 AM] Received notification 'textDocument/publishDiagnostics'.
[Trace - 10:45:25 AM] Received response 'textDocument/documentColor - (37)' in 1140ms.
[Trace - 10:45:27 AM] Sending request 'textDocument/documentSymbol - (38)'.
[Trace - 10:45:28 AM] Received response 'textDocument/documentSymbol - (38)' in 1016ms.
[Trace - 10:45:31 AM] Sending request 'textDocument/linkedEditingRange - (39)'.
[Trace - 10:45:31 AM] Received response 'textDocument/linkedEditingRange - (39)' in 0ms.
[Trace - 10:45:31 AM] Sending request 'textDocument/codeAction - (40)'.
[Trace - 10:45:31 AM] Received response 'textDocument/codeAction - (40)' in 1ms.
[Trace - 10:45:35 AM] Sending request 'textDocument/hover - (41)'.
[Trace - 10:45:35 AM] Sending notification '$/cancelRequest'.
[Trace - 10:45:35 AM] Received response 'textDocument/hover - (41)' in 78ms.
[Trace - 10:45:37 AM] Sending request 'textDocument/documentSymbol - (42)'.
[Trace - 10:45:37 AM] Sending notification 'textDocument/didOpen'.
[Trace - 10:45:37 AM] Sending request 'textDocument/documentColor - (43)'.
[Trace - 10:45:37 AM] Sending request 'textDocument/linkedEditingRange - (44)'.
[Trace - 10:45:37 AM] Sending request 'textDocument/codeAction - (45)'.
[Trace - 10:45:37 AM] Sending notification '$/cancelRequest'.
[Trace - 10:45:37 AM] Received response 'textDocument/linkedEditingRange - (44)' in 16ms.
[Trace - 10:45:37 AM] Received response 'textDocument/codeAction - (45)' in 15ms.
[Trace - 10:45:37 AM] Sending request 'textDocument/documentSymbol - (46)'.
[Trace - 10:45:37 AM] Sending request 'textDocument/semanticTokens/full - (47)'.
[Trace - 10:45:37 AM] Sending request 'textDocument/semanticTokens/range - (48)'.
[Trace - 10:45:38 AM] Received notification 'textDocument/publishDiagnostics'.
[Trace - 10:45:38 AM] Received response 'textDocument/documentSymbol - (42)' in 1003ms.
[Trace - 10:45:38 AM] Sending request 'textDocument/linkedEditingRange - (49)'.
[Trace - 10:45:38 AM] Received response 'textDocument/linkedEditingRange - (49)' in 0ms.
[Trace - 10:45:38 AM] Sending request 'textDocument/codeAction - (50)'.
[Trace - 10:45:38 AM] Received response 'textDocument/codeAction - (50)' in 119ms.
[Trace - 10:45:38 AM] Received response 'textDocument/documentColor - (43)' in 1030ms.
[Trace - 10:45:38 AM] Sending request 'textDocument/hover - (51)'.
[Trace - 10:45:38 AM] Received response 'textDocument/documentSymbol - (46)' in 1315ms.
[Trace - 10:45:38 AM] Received response 'textDocument/semanticTokens/full - (47)' in 1329ms.
[Trace - 10:45:38 AM] Received response 'textDocument/semanticTokens/range - (48)' in 1330ms.
[Trace - 10:45:38 AM] Received response 'textDocument/hover - (51)' in 235ms.
[Trace - 10:45:42 AM] Sending request 'textDocument/documentSymbol - (52)'.
[Trace - 10:45:42 AM] Sending request 'textDocument/documentColor - (53)'.
[Trace - 10:45:42 AM] Sending request 'textDocument/linkedEditingRange - (54)'.
[Trace - 10:45:42 AM] Sending request 'textDocument/codeAction - (55)'.
[Trace - 10:45:42 AM] Sending notification '$/cancelRequest'.
[Trace - 10:45:42 AM] Sending request 'textDocument/documentSymbol - (56)'.
[Trace - 10:45:42 AM] Received response 'textDocument/linkedEditingRange - (54)' in 11ms.
[Trace - 10:45:42 AM] Received response 'textDocument/codeAction - (55)' in 10ms.
[Trace - 10:45:42 AM] Sending request 'textDocument/linkedEditingRange - (57)'.
[Trace - 10:45:42 AM] Received response 'textDocument/linkedEditingRange - (57)' in 1ms.
[Trace - 10:45:42 AM] Sending request 'textDocument/codeAction - (58)'.
[Trace - 10:45:42 AM] Received response 'textDocument/codeAction - (58)' in 10ms.
[Trace - 10:45:43 AM] Sending request 'textDocument/hover - (59)'.
[Trace - 10:45:43 AM] Received response 'textDocument/hover - (59)' in 12ms.
[Trace - 10:45:43 AM] Received response 'textDocument/documentSymbol - (52)' in 1005ms.
[Trace - 10:45:43 AM] Received response 'textDocument/documentColor - (53)' in 1005ms.
[Trace - 10:45:43 AM] Received response 'textDocument/documentSymbol - (56)' in 1006ms.
[Trace - 10:45:48 AM] Sending request 'textDocument/linkedEditingRange - (60)'.
[Trace - 10:45:48 AM] Received response 'textDocument/linkedEditingRange - (60)' in 1ms.
[Trace - 10:45:48 AM] Sending request 'textDocument/codeAction - (61)'.
[Trace - 10:45:48 AM] Received response 'textDocument/codeAction - (61)' in 1ms.
[Trace - 10:45:48 AM] Sending request 'textDocument/completion - (62)'.
[Trace - 10:45:49 AM] Received response 'textDocument/completion - (62)' in 433ms.
[Trace - 10:45:49 AM] Sending request 'completionItem/resolve - (63)'.
[Trace - 10:45:49 AM] Received response 'completionItem/resolve - (63)' in 806ms.

...

[Trace - 10:46:27 AM] Sending request 'textDocument/documentSymbol - (64)'.
[Trace - 10:46:27 AM] Sending notification 'textDocument/didOpen'.
[Trace - 10:46:27 AM] Sending request 'textDocument/documentColor - (65)'.
[Trace - 10:46:27 AM] Sending request 'textDocument/linkedEditingRange - (66)'.
[Trace - 10:46:27 AM] Sending request 'textDocument/codeAction - (67)'.
[Trace - 10:46:27 AM] Sending notification '$/cancelRequest'.
[Trace - 10:46:27 AM] Sending request 'textDocument/documentSymbol - (68)'.
[Trace - 10:46:27 AM] Received response 'textDocument/linkedEditingRange - (66)' in 13ms.
[Trace - 10:46:27 AM] Sending request 'textDocument/semanticTokens/full - (69)'.
[Trace - 10:46:27 AM] Received response 'textDocument/codeAction - (67)' in 14ms.
[Trace - 10:46:27 AM] Sending request 'textDocument/semanticTokens/range - (70)'.
[Trace - 10:46:27 AM] Sending request 'textDocument/linkedEditingRange - (71)'.
[Trace - 10:46:27 AM] Received response 'textDocument/linkedEditingRange - (71)' in 1ms.
[Trace - 10:46:27 AM] Sending request 'textDocument/codeAction - (72)'.
SnapshotManager File Statistics:
Project files: 24
Svelte files: 44
From node_modules: 623
Total: 750
[Trace - 10:46:27 AM] Received response 'textDocument/codeAction - (72)' in 89ms.
[Trace - 10:46:28 AM] Received notification 'textDocument/publishDiagnostics'.
[Trace - 10:46:28 AM] Received response 'textDocument/documentSymbol - (64)' in 1006ms.
[Trace - 10:46:28 AM] Received response 'textDocument/documentColor - (65)' in 1006ms.
[Trace - 10:46:28 AM] Received response 'textDocument/documentSymbol - (68)' in 1008ms.
[Trace - 10:46:28 AM] Received response 'textDocument/semanticTokens/full - (69)' in 1001ms.
[Trace - 10:46:28 AM] Received response 'textDocument/semanticTokens/range - (70)' in 1042ms.
[Trace - 10:46:30 AM] Sending request 'textDocument/linkedEditingRange - (73)'.
[Trace - 10:46:30 AM] Received response 'textDocument/linkedEditingRange - (73)' in 1ms.
[Trace - 10:46:30 AM] Sending request 'textDocument/codeAction - (74)'.
[Trace - 10:46:30 AM] Received response 'textDocument/codeAction - (74)' in 0ms.
[Trace - 10:46:30 AM] Sending request 'textDocument/linkedEditingRange - (75)'.
[Trace - 10:46:30 AM] Received response 'textDocument/linkedEditingRange - (75)' in 1ms.
[Trace - 10:46:30 AM] Sending request 'textDocument/codeAction - (76)'.
[Trace - 10:46:30 AM] Received response 'textDocument/codeAction - (76)' in 0ms.
[Trace - 10:46:31 AM] Sending request 'textDocument/completion - (77)'.
[Trace - 10:46:31 AM] Received response 'textDocument/completion - (77)' in 45ms.
[Trace - 10:46:31 AM] Sending request 'completionItem/resolve - (78)'.
[Trace - 10:46:31 AM] Received response 'completionItem/resolve - (78)' in 40ms.

...

[Trace - 10:47:22 AM] Received notification 'textDocument/publishDiagnostics'.
SnapshotManager File Statistics:
Project files: 15
Svelte files: 10
From node_modules: 0
Total: 15
[Trace - 10:47:23 AM] Received response 'textDocument/documentColor - (115)' in 1015ms.
[Trace - 10:47:23 AM] Received response 'textDocument/documentSymbol - (118)' in 1014ms.
[Trace - 10:47:23 AM] Received response 'textDocument/semanticTokens/full - (119)' in 1007ms.
[Trace - 10:47:24 AM] Sending request 'textDocument/linkedEditingRange - (125)'.
[Trace - 10:47:24 AM] Sending request 'textDocument/codeAction - (126)'.
[Trace - 10:47:24 AM] Sending notification 'textDocument/didChange'.
[Trace - 10:47:24 AM] Sending notification '$/cancelRequest'.
[Trace - 10:47:24 AM] Sending notification '$/cancelRequest'.
[Trace - 10:47:24 AM] Sending request 'textDocument/linkedEditingRange - (127)'.
[Trace - 10:47:24 AM] Sending request 'textDocument/semanticTokens/full - (128)'.
[Trace - 10:47:25 AM] Sending request 'textDocument/completion - (129)'.
[Trace - 10:47:25 AM] Sending request 'textDocument/hover - (130)'.
[Trace - 10:47:25 AM] Sending notification '$/cancelRequest'.
[Trace - 10:47:25 AM] Sending request 'textDocument/documentColor - (131)'.
[Trace - 10:47:25 AM] Sending request 'textDocument/hover - (132)'.
[Trace - 10:47:26 AM] Sending request 'textDocument/documentSymbol - (133)'.
[Trace - 10:47:26 AM] Sending notification '$/cancelRequest'.
[Trace - 10:47:27 AM] Received response 'textDocument/semanticTokens/range - (120)' in 5337ms.
[Trace - 10:47:27 AM] Received response 'textDocument/linkedEditingRange - (125)' in 3137ms.
[Trace - 10:47:27 AM] Received notification 'textDocument/publishDiagnostics'.
[Trace - 10:47:27 AM] Received response 'textDocument/codeAction - (126)' in 3088ms.
[Trace - 10:47:27 AM] Received response 'textDocument/linkedEditingRange - (127)' in 2836ms.
[Trace - 10:47:28 AM] Received response 'textDocument/completion - (129)' in 2923ms.
[Trace - 10:47:28 AM] Sending request 'completionItem/resolve - (134)'.
[Trace - 10:47:28 AM] Received response 'textDocument/hover - (130)' in 2783ms.
[Trace - 10:47:28 AM] Received response 'textDocument/hover - (132)' in 2400ms.
[Trace - 10:47:28 AM] Received response 'completionItem/resolve - (134)' in 40ms.
[Trace - 10:47:28 AM] Received notification 'textDocument/publishDiagnostics'.
[Trace - 10:47:28 AM] Received response 'textDocument/semanticTokens/full - (128)' in 3769ms.
[Trace - 10:47:29 AM] Received response 'textDocument/documentColor - (131)' in 3514ms.
[Trace - 10:47:29 AM] Received response 'textDocument/documentSymbol - (133)' in 2884ms.
[Trace - 10:47:48 AM] Sending request 'textDocument/formatting - (135)'.
Using Prettier v2.3.2 from /Users/andreavaccari/monorepo/node_modules/prettier
[Trace - 10:47:49 AM] Received response 'textDocument/formatting - (135)' in 196ms.
[Trace - 10:47:49 AM] Sending notification 'textDocument/didChange'.
[Trace - 10:47:49 AM] Sending notification 'textDocument/didSave'.
[Trace - 10:47:49 AM] Sending request 'textDocument/linkedEditingRange - (136)'.
[Trace - 10:47:49 AM] Received response 'textDocument/linkedEditingRange - (136)' in 1ms.
[Trace - 10:47:49 AM] Sending request 'textDocument/semanticTokens/full - (137)'.
[Trace - 10:47:49 AM] Received notification 'textDocument/publishDiagnostics'.
[Trace - 10:47:50 AM] Sending request 'textDocument/documentColor - (138)'.
[Trace - 10:47:50 AM] Received notification 'textDocument/publishDiagnostics'.
[Trace - 10:47:50 AM] Received notification 'textDocument/publishDiagnostics'.
[Trace - 10:47:50 AM] Received notification 'textDocument/publishDiagnostics'.
[Trace - 10:47:50 AM] Received notification 'textDocument/publishDiagnostics'.
[Trace - 10:47:50 AM] Received notification 'textDocument/publishDiagnostics'.
[Trace - 10:47:50 AM] Received notification 'textDocument/publishDiagnostics'.
[Trace - 10:47:50 AM] Received response 'textDocument/semanticTokens/full - (137)' in 1139ms.
[Trace - 10:47:51 AM] Received response 'textDocument/documentColor - (138)' in 1005ms.
[Trace - 10:47:51 AM] Sending request 'textDocument/documentSymbol - (139)'.
[Trace - 10:47:52 AM] Received response 'textDocument/documentSymbol - (139)' in 1009ms.

@dummdidumm
Copy link
Member

The Prettier log is alright, it's a sign that the extension uses the referenced package for formatting. To be more specific: The Svelte extension uses Prettier to format the file, which is why, if you have prettier-plugin-svelte installed, you could also use the Prettier extension for this.

The logs also seem ok. My guess now is that "svelte.plugin.svelte.diagnostics.enable": false should be enough to make it fast again. This disables running the Svelte compiler to find the warnings, which involves preprocessing the files, which can be costly, depending on the circumstances.
How many files are open when the diagnostics are slow? Which preprocessors are you using? Are you by any chance using a CSS preprocessor like SCSS/Tailwind and referencing a big external stylesheet in one of the open files?

The TS plugin is unrelated to this issue.

@andreavaccari
Copy link

Thank you for the detailed explanation. I will keep "svelte.plugin.svelte.diagnostics.enable": false and removed "svelte.plugin.typescript.diagnostics.enable": false. I will also switch on "svelte.enable-ts-plugin": true (I understand it's unrelated but I figure I should mention it.)

Re open files:

  • I don't use tabs so I don't have a visual reference. My guess is between 20-40 on average.
  • You made me realize this is bad practice so I added the following global settings:
"workbench.editor.limit.enabled": true
"workbench.editor.limit.perEditorGroup": true
"workbench.editor.limit.value": 1

Re preprocessors:

  • We use svelte-preprocess, typescript, postcss, and tailwind
  • Tailwind is configured to use jit mode and to process always all packages (instead of just the one being run or built)
  • We use carbon-components-svelte. We have a sass-only package in the monorepo that compiles the theme with our custom color and tweaks. It used to be that preprocessing the sass theme would slow everything down but the separate package solved that. We tried to set up the custom preprocessors to optimize imports and css for carbon but we haven't found a way to make them work.
  • vite only takes a few seconds to run dev. The slowdowns are in VS Code with the Svelte extensions.

One question:

  • Running vite build on our app-level package (which imports all other packages) only took 20 seconds.
  • Why would the diagnostics be slower than the build? Is it because they are executed for each open file in parallel?

@dummdidumm
Copy link
Member

It could be slightly faster because tsconfig file loading is cached in newer versions, and the user-supplied svelte-preprocess is used if present.
Interesting, so the Linux+pnpm-combination seems to lead to the performance penality. I'll try to setup WSL on my windows machine if I have time and see if I can then reproduce it, too.

@dimfeld
Copy link

dimfeld commented Sep 13, 2021

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 to typescript@*, yarn was just never upgrading it in coc-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.

@dummdidumm
Copy link
Member

Thanks for the info. I tried this with VS Code inside WSL2 and couldn't reproduce the slowness either.

@dummdidumm
Copy link
Member

dummdidumm commented Jan 10, 2022

The newest VS Code extension (version 105.9.0) contains a performance improvement which should make global auto completions significantly faster, which should increase the overall responsiveness of the extension (and hopefully also improves the battery drain Scrott mentioned). Please provide feedback if it's better now.

@dummdidumm dummdidumm added perf Performance and removed bug Something isn't working labels Jan 10, 2022
@takoyaro
Copy link

I used to have this issue last summer, then it got fixed.
For the past week however, all my projects are plagued with this. Unfortunately I can't share any repo as all these projects are under NDA....

[Trace - 10:58:24 AM] Received notification 'textDocument/publishDiagnostics'.
[Trace - 10:58:24 AM] Received response 'textDocument/documentColor - (2)' in 56808ms.
[Trace - 10:58:24 AM] Received response 'textDocument/codeAction - (10)' in 19105ms.
[Trace - 10:58:37 AM] Sending request 'textDocument/codeAction - (18)'.
[Trace - 10:58:37 AM] Sending notification '$/cancelRequest'.
[Trace - 10:58:39 AM] Sending request 'textDocument/hover - (19)'.
[Trace - 10:58:41 AM] Sending notification '$/cancelRequest'.
[Trace - 10:58:41 AM] Sending request 'textDocument/definition - (20)'.
[Trace - 10:58:41 AM] Sending notification '$/cancelRequest'.
[Trace - 10:58:42 AM] Sending request 'textDocument/hover - (21)'.
[Trace - 10:58:42 AM] Sending notification '$/cancelRequest'.
[Trace - 10:58:42 AM] Sending request 'textDocument/definition - (22)'.
[Trace - 10:58:43 AM] Sending notification '$/cancelRequest'.
[Trace - 10:58:43 AM] Sending request 'textDocument/hover - (23)'.
[Trace - 10:58:44 AM] Sending notification '$/cancelRequest'.
[Trace - 10:58:56 AM] Received response 'textDocument/hover - (7)' in 86316ms.
[Trace - 10:58:56 AM] Received response 'textDocument/hover - (8)' in 69630ms.
[Trace - 10:58:56 AM] Received response 'textDocument/hover - (9)' in 68468ms.
[Trace - 10:58:56 AM] Received response 'textDocument/hover - (14)' in 49199ms.
[Trace - 10:58:56 AM] Received response 'textDocument/hover - (16)' in 38664ms.
[Trace - 10:58:56 AM] Received response 'textDocument/codeAction - (1)' in 88423ms.
[Trace - 10:58:56 AM] Received response 'textDocument/codeAction - (3)' in 87531ms.
[Trace - 10:58:56 AM] Received response 'textDocument/codeAction - (6)' in 87166ms.
[Trace - 10:58:56 AM] Received response 'textDocument/codeAction - (13)' in 50491ms.
[Trace - 10:58:56 AM] Received response 'textDocument/definition - (15)' in 39950ms.
[Trace - 10:58:56 AM] Received response 'textDocument/documentSymbol - (4)' in 87499ms.
[Trace - 10:58:56 AM] Received response 'textDocument/documentColor - (5)' in 87167ms.
[Trace - 10:58:56 AM] Received response 'textDocument/documentColor - (11)' in 50716ms.
[Trace - 10:58:56 AM] Received response 'textDocument/documentSymbol - (12)' in 50716ms.
[Trace - 10:58:56 AM] Received notification 'textDocument/publishDiagnostics'.
[Trace - 10:58:56 AM] Received response 'textDocument/hover - (17)' in 32678ms.
[Trace - 10:58:56 AM] Received response 'textDocument/codeAction - (18)' in 18634ms.
[Trace - 10:58:56 AM] Received response 'textDocument/hover - (19)' in 17145ms.
[Trace - 10:58:56 AM] Received response 'textDocument/definition - (20)' in 15398ms.
[Trace - 10:58:56 AM] Received response 'textDocument/hover - (21)' in 14262ms.
[Trace - 10:58:56 AM] Received response 'textDocument/definition - (22)' in 14199ms.
[Trace - 10:58:56 AM] Received response 'textDocument/hover - (23)' in 12549ms.

@dummdidumm
Copy link
Member

We didn't have any changes related to performance in the last two weeks, so that's strange. Some questions:

  • Do you use the new transformation? If you don't know what that is, you don't use it.
  • What happens if you disable diagnostics? "svelte.plugin.svelte.diagnostics.enable": false and "svelte.plugin.typescript.diagnostics.enable": false (both false or only one of them)
  • What the VS Code extension version? Is it the latest?

@takoyaro
Copy link

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:

[email protected]=>4.9.8 This is a rollback
[email protected]=>3.46.3
[email protected]=>4.5.5

After making these changes, the extension is now working fine.

@gyurielf
Copy link

I ran into this as well, but just only on large files, which at least around 1k lines.

  System:
    OS: Linux 5.15 Ubuntu 20.04.4 LTS (Focal Fossa)
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 6.45 GB / 15.48 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 18.15.0 - ~/.nvm/versions/node/v18.15.0/bin/node
    npm: 9.4.0 - ~/node_modules/.bin/npm
  Browsers:
    Chrome: 111.0.5563.110
    Firefox: 111.0.1
  npmPackages:
    @sveltejs/adapter-static: ^2.0.1 => 2.0.1 
    @sveltejs/kit: ^1.14.0 => 1.14.0 
    svelte: ^3.57.0 => 3.57.0 
    vite: ^4.2.1 => 4.2.1 

@lucassilvas1
Copy link

I ran into this as well, but just only on large files, which at least around 1k lines.

  System:
    OS: Linux 5.15 Ubuntu 20.04.4 LTS (Focal Fossa)
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 6.45 GB / 15.48 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 18.15.0 - ~/.nvm/versions/node/v18.15.0/bin/node
    npm: 9.4.0 - ~/node_modules/.bin/npm
  Browsers:
    Chrome: 111.0.5563.110
    Firefox: 111.0.1
  npmPackages:
    @sveltejs/adapter-static: ^2.0.1 => 2.0.1 
    @sveltejs/kit: ^1.14.0 => 1.14.0 
    svelte: ^3.57.0 => 3.57.0 
    vite: ^4.2.1 => 4.2.1 

Same here with 1.5K lines:

  System:
    OS: Windows 10 10.0.19045
    CPU: (12) x64 AMD Ryzen 5 5600X 6-Core Processor
    Memory: 14.76 GB / 31.91 GB
  Binaries:
    Node: 16.13.0 - C:\Program Files\nodejs\node.EXE
    npm: 8.4.1 - ~\node_modules\.bin\npm.CMD
  Browsers:
    Edge: Spartan (44.19041.1266.0), Chromium (112.0.1722.39)
  npmPackages:
    svelte: ^3.58.0 => 3.58.0
    svelte-check: ^3.0.3 => 3.0.3
    svelte-preprocess: ^5.0.1 => 5.0.1
    typescript: ^4.9.5 => 4.9.5

Did you manage to fix it?

@jasonlyu123
Copy link
Member

Instead of commenting "Same here," please provide information with the steps I commented earlier.

@lucassilvas1
Copy link

Instead of commenting "Same here," please provide information with the steps I commented earlier.

What steps? I have node_modules excluded in my tsconfig already.
Anyway, I split the file into smaller ones, the biggest one now has 600 lines, not nearly as laggy as before with the 1.5k lines, but still noticeably slow.

@ptrxyz
Copy link

ptrxyz commented May 11, 2023

I ran into the same problems as explained above, I use Tailwind, Prettier, EsLint, Typescript, SvelteKit.
A big problem seem to be larger imports (JSON doc, filesize ~2MB), however I can't avoid these in my application.
But also when I remove those for testing purposes, it's still in the oder of 10s+ to get autocompletion work. Co-Pilot does the suggestions faster :D

Versions I am using:

    "@sveltejs/kit": "^1.16.3"
    "svelte": "^3.59.1",
    "svelte-check": "^3.3.2",
    "typescript": "^5.0.4",
    "vite": "^4.3.5",
    "tailwindcss": "^3.3.2"

Extensions are up to date, latest stable, OS is Linux

@ptrxyz
Copy link

ptrxyz commented May 11, 2023

[Trace - 8:36:10 PM] Received response 'textDocument/codeAction - (42)' in 2393ms.
[Trace - 8:36:10 PM] Received response 'textDocument/codeAction - (44)' in 2055ms.
[Trace - 8:36:10 PM] Received response 'textDocument/completion - (43)' in 2377ms.
[Trace - 8:36:10 PM] Sending request 'completionItem/resolve - (47)'.
[Trace - 8:36:10 PM] Received response 'textDocument/inlayHint - (45)' in 1153ms.
[Trace - 8:36:10 PM] Sending request 'textDocument/documentColor - (48)'.
[Trace - 8:36:10 PM] Sending request 'textDocument/documentSymbol - (49)'.
[Trace - 8:36:13 PM] Received response 'textDocument/semanticTokens/full - (46)' in 3367ms.
[Trace - 8:36:13 PM] Received notification 'textDocument/publishDiagnostics'.
[Trace - 8:36:13 PM] Received response 'completionItem/resolve - (47)' in 2641ms.
[Trace - 8:36:14 PM] Received response 'textDocument/documentColor - (48)' in 3543ms.
[Trace - 8:36:14 PM] Received response 'textDocument/documentSymbol - (49)' in 3429ms.

Just for reference, to show which actions seem to take long.

@conoremclaughlin
Copy link

conoremclaughlin commented Jun 2, 2023

+1. Steps to produce:

  1. Create a 2,200 line Svelte file
  2. Import a basic store
  3. Use option+space on the store to trigger intellisense autocomplete 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.

Trace - 00:41:47] Sending request 'textDocument/completion - (5264)'.
[Trace - 00:41:47] Sending request 'textDocument/codeAction - (5265)'.
Using Svelte v3.56.0 from /Users/cm/ws/svelte-frontend/node_modules/svelte/compiler
[Trace - 00:41:48] Sending notification '$/cancelRequest'.
[Trace - 00:41:48] Sending request 'textDocument/completion - (5266)'.
[Trace - 00:41:48] Sending notification '$/cancelRequest'.
[Trace - 00:41:48] Sending request 'textDocument/inlayHint - (5267)'.
[ts] getCompletionData: Get current token: 0.004291057586669922
[ts] getCompletionData: Is inside comment: 0.018208026885986328
[ts] getCompletionData: Get previous token: 0.027250051498413086
[ts] getCompletionsAtPosition: isCompletionListBlocker: 0.00787496566772461
[ts] getExportInfoMap: cache miss or empty; calculating new results
[ts] getExportInfoMap: done in 16.80887508392334 ms
[ts] collectAutoImports: resolved 0 module specifiers, plus 0 ambient and 127 from cache
[ts] collectAutoImports: response is incomplete
[ts] collectAutoImports: 9.609333992004395
[ts] getCompletionData: Semantic work: 28.18766689300537
[ts] getCompletionsAtPosition: getCompletionEntriesFromSymbols: 4.0915000438690186
[Trace - 00:41:50] Received notification 'textDocument/publishDiagnostics'.
[Trace - 00:41:50] Sending request 'textDocument/codeAction - (5268)'.
[Trace - 00:41:50] Sending notification '$/cancelRequest'.
Using Svelte v3.56.0 from /Users/cm/ws/svelte-frontend/node_modules/svelte/compiler
Using Svelte v3.56.0 from /Users/cm/ws/svelte-frontend/node_modules/svelte/compiler
[Trace - 00:41:52] Sending request 'textDocument/documentSymbol - (5269)'.
Using Svelte v3.56.0 from /Users/cm/ws/svelte-frontend/node_modules/svelte/compiler
Using Svelte v3.56.0 from /Users/cm/ws/svelte-frontend/node_modules/svelte/compiler
Using Prettier v2.8.8 from /Users/cm/ws/svelte-frontend/node_modules/prettier
[ts] getCompletionData: Get current token: 0.004541873931884766
[ts] getCompletionData: Is inside comment: 0.023833036422729492
[ts] getCompletionData: Get previous token: 0.016124963760375977
[ts] getCompletionsAtPosition: isCompletionListBlocker: 0.001708984375
[ts] getCompletionData: Semantic work: 0.24299979209899902
[ts] getCompletionsAtPosition: getCompletionEntriesFromSymbols: 0.1382920742034912
[Trace - 00:41:57] Received response 'textDocument/completion - (5259)' in 13755ms.
[Trace - 00:41:57] Received response 'textDocument/codeAction - (5260)' in 12723ms.
[Trace - 00:41:57] Received notification 'textDocument/publishDiagnostics'.
[Trace - 00:41:57] Received response 'textDocument/semanticTokens/full - (5261)' in 12719ms.
[Trace - 00:41:57] Received response 'textDocument/inlayHint - (5262)' in 11725ms.
[Trace - 00:41:57] Received response 'textDocument/codeAction - (5263)' in 11479ms.
[Trace - 00:41:57] Received response 'textDocument/completion - (5264)' in 10208ms.
[Trace - 00:41:57] Received notification 'textDocument/publishDiagnostics'.
[Trace - 00:41:57] Received response 'textDocument/codeAction - (5265)' in 9960ms.
[Trace - 00:41:57] Received response 'textDocument/inlayHint - (5267)' in 8960ms.
[Trace - 00:41:57] Received response 'textDocument/completion - (5266)' in 9331ms.
[Trace - 00:41:57] Received response 'textDocument/codeAction - (5268)' in 7570ms.
[Trace - 00:41:58] Sending request 'textDocument/codeAction - (5270)'.
[Trace - 00:41:58] Received response 'textDocument/codeAction - (5270)' in 1ms.
[Trace - 00:41:58] Received response 'textDocument/documentSymbol - (5269)' in 6474ms.
[Trace - 00:41:59] Sending request 'textDocument/semanticTokens/full - (5271)'.
[Trace - 00:41:59] Received response 'textDocument/semanticTokens/full - (5271)' in 3ms

Snapshot

SnapshotManager File Statistics:
Project files: 60
Svelte files: 52
From node_modules: 478
Total: 542

Here's the tsconfig:

{
  "extends": "@tsconfig/svelte/tsconfig.json",

  "include": ["src/**/*"],
  "exclude": ["node_modules/*", "__sapper__/*", "public/*"]
}

@carlocorradini
Copy link

Hey 👋
Any update on this?
I've created a dummy project with Tauri and any action on a .svelte file requires > 20 seconds. Strangely, all .ts files works perfectly.
Thank you 😊

@dummdidumm
Copy link
Member

Could you post a link to a repository along with instructions in which file and how it happens so we can reproduce?

@carlocorradini
Copy link

Sorry for the late reply. I'll try to create a simple repo.
Thanks 😊

@carlocorradini
Copy link

@dummdidumm
Sorry if it took me a few days but the example repository is finally ready:
https://github.com/carlocorradini/svelte-language-tools

Editing any .svelte file can take some time.
The time grows as you add more .svelte (or increase complexity, i.e. # lines) and TypeScript files.

@jasonlyu123
Copy link
Member

I cannot reproduce with your reproduction. I tried launching the Tauri app in dev mode and without dev mode. Do you have an instruction step to reproduce it?

@carlocorradini
Copy link

@jasonlyu123 The problem is during development while editing .svelte files.

@jasonlyu123
Copy link
Member

jasonlyu123 commented Jun 8, 2023

Yes. I know that. But I didn't see a significant slowdown. You might need to be more specific. Does it like slow down after you save a file? Create a new file?

@carlocorradini
Copy link

@jasonlyu123
In a project with additional files (not too many), the format operation takes seconds 😔
The strange thing is that it only affects svelte files :/

@ryanzoleta
Copy link

Hello any updates on this? I'd like to add my own experience and reproduction steps of the symbol navigation lag in VS Code.

Demo:

CleanShot 2023-07-03 at 22 23 59

As shown here, it takes a while for the symbol navigator to load. In subsequent triggers to the symbol navigator there's no slowdown. But if you edit the file in any way, it slows down again.

In comparison, here's how it looks like in Next.js:

CleanShot 2023-07-03 at 22 27 08

Absolutely no delay.

I tested this on a clean install of VS Code with the version:

CleanShot 2023-07-03 at 22 28 50

Only the official Svelte extension was installed.

Here's my VS Code config file:

{
    "svelte.plugin.css.diagnostics.enable": false,
    "svelte.plugin.css.documentSymbols.enable": false,
    "svelte.plugin.css.completions.enable": false,
    "svelte.plugin.svelte.diagnostics.enable": false,
    "svelte.plugin.typescript.diagnostics.enable": false,
    "window.zoomLevel": 3
}

I'm open to switching editors that doesn't have this issue in case this is a VS Code thing and not a language server issue.

@ChrolloDeveloper
Copy link

I've been encountering the same issue recently. I think one thing I noticed that no one else here has mentioned is that intellisense/autocomplete is only slow due to the HTML code in the same file. When I comment out the HTML code in my file, intellisense autofills become immediate. Maybe I'm just dropping total line number down, but it would also explain why .ts files have no problems.

So to whoever is investigating this, the lag may be caused by whatever parsing/interpreting is happening between the JS in the <script> tag and the JS-bound HTML on the page. VueJS's Volar extension has a similar issue, I think, but there's got unusable much more quickly. For now, a "workaround" has been to comment out all of the HTML in a given file if I'm not actively working on it.

I hope this get resolved at some point because I really don't to use webstorm.

@jasonlyu123
Copy link
Member

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.

@ChrolloDeveloper
Copy link

Thank you, I've opened #2179 for that. I found the same performance hit happens even when there's no svelte variables/bindings in the HTML, which is interesting.

@vlrevolution
Copy link

Same issue. Super annoying

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
perf Performance
Projects
None yet
Development

No branches or pull requests