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

IntelliSense is painfully slow #5063

Open
rigtigeEmil opened this issue Dec 17, 2024 · 27 comments
Open

IntelliSense is painfully slow #5063

rigtigeEmil opened this issue Dec 17, 2024 · 27 comments

Comments

@rigtigeEmil
Copy link

Vue - Official extension or vue-tsc version

v2.1.10

VSCode version

1.96

Vue version

3.5.13

TypeScript version

5.7.2

System Info

System:
    OS: Windows 11 10.0.22631
    CPU: (24) x64 AMD Ryzen 9 5900X 12-Core Processor
    Memory: 35.22 GB / 63.91 GB
  Binaries:
    Node: 20.10.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.22 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 9.6.6 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Chromium (127.0.2651.74)
    Internet Explorer: 11.0.22621.3527

package.json dependencies

No response

Steps to reproduce

Intellisense is slow both in template and in script parts of Vue files. I've had a look at the output, and it seems a bunch of the requests are taking a long (multiple seconds) time.

The only thing I'm doing in this test is writing <div, expecting the tag to be closed automatically, and waiting. I see similar results, of requests taking a long time when editing the script part, or anything else essentially.

[Trace - 6:58:22 PM] Sending request 'textDocument/linkedEditingRange - (375)'.
[Trace - 6:58:22 PM] Received response 'textDocument/documentSymbol - (369)' in 2104ms.
[Trace - 6:58:22 PM] Received response 'textDocument/semanticTokens/range - (370)' in 1998ms.
[Trace - 6:58:22 PM] Received notification 'textDocument/publishDiagnostics'.
[Trace - 6:58:22 PM] Received response 'textDocument/inlayHint - (371)' in 1876ms.
[Trace - 6:58:22 PM] Received response 'textDocument/inlayHint - (372)' in 1702ms.
[Trace - 6:58:22 PM] Received response 'textDocument/documentLink - (373)' in 1430ms.
[Trace - 6:58:22 PM] Received response 'textDocument/documentColor - (374)' in 1314ms.
[Trace - 6:58:22 PM] Received response 'textDocument/linkedEditingRange - (375)' in 63ms.
[Trace - 6:58:22 PM] Received notification 'textDocument/publishDiagnostics'.
[Trace - 6:58:22 PM] Sending request 'textDocument/linkedEditingRange - (376)'.
[Trace - 6:58:23 PM] Received response 'textDocument/linkedEditingRange - (376)' in 2ms.
[Trace - 6:58:24 PM] Sending request 'textDocument/linkedEditingRange - (377)'.
[Trace - 6:58:24 PM] Received response 'textDocument/linkedEditingRange - (377)' in 1ms.
[Trace - 6:58:25 PM] Sending notification 'textDocument/didChange'.
[Trace - 6:58:25 PM] Sending request 'textDocument/completion - (378)'.
[Trace - 6:58:25 PM] Received request 'workspace/configuration - (35)'.
[Trace - 6:58:25 PM] Sending response 'workspace/configuration - (35)'. Processing request took 0ms
[Trace - 6:58:25 PM] Received request 'workspace/configuration - (36)'.
[Trace - 6:58:25 PM] Sending response 'workspace/configuration - (36)'. Processing request took 0ms
[Trace - 6:58:25 PM] Sending request 'textDocument/linkedEditingRange - (379)'.
[Trace - 6:58:25 PM] Sending request 'textDocument/signatureHelp - (380)'.
[Trace - 6:58:25 PM] Sending request 'textDocument/foldingRange - (381)'.
[Trace - 6:58:25 PM] Sending request 'textDocument/documentSymbol - (382)'.
[Trace - 6:58:25 PM] Sending request 'textDocument/semanticTokens/range - (383)'.
[Trace - 6:58:26 PM] Sending request 'textDocument/inlayHint - (384)'.
[Trace - 6:58:26 PM] Sending notification '$/cancelRequest'.
[Trace - 6:58:26 PM] Sending request 'textDocument/inlayHint - (385)'.
[Trace - 6:58:26 PM] Sending request 'textDocument/documentColor - (386)'.
[Trace - 6:58:26 PM] Sending request 'textDocument/documentLink - (387)'.
[Trace - 6:58:26 PM] Received response 'textDocument/completion - (378)' in 1332ms.
[Trace - 6:58:26 PM] Received response 'textDocument/linkedEditingRange - (379)' in 1301ms.
[Trace - 6:58:26 PM] Received response 'textDocument/signatureHelp - (380)' in 1226ms.
[Trace - 6:58:26 PM] Received response 'textDocument/foldingRange - (381)' in 1151ms.
[Trace - 6:58:26 PM] Received response 'textDocument/documentSymbol - (382)' in 988ms.
[Trace - 6:58:26 PM] Received notification 'textDocument/publishDiagnostics'.
[Trace - 6:58:26 PM] Sending request 'completionItem/resolve - (388)'.
[Trace - 6:58:27 PM] Received response 'textDocument/semanticTokens/range - (383)' in 1427ms.
[Trace - 6:58:27 PM] Received notification 'textDocument/publishDiagnostics'.
[Trace - 6:58:27 PM] Received response 'textDocument/inlayHint - (384)' in 1306ms.
[Trace - 6:58:27 PM] Received response 'textDocument/inlayHint - (385)' in 1133ms.
[Trace - 6:58:27 PM] Received response 'textDocument/documentColor - (386)' in 894ms.
[Trace - 6:58:27 PM] Received response 'textDocument/documentLink - (387)' in 794ms.
[Trace - 6:58:27 PM] Received response 'completionItem/resolve - (388)' in 581ms.
[Trace - 6:58:27 PM] Sending notification 'textDocument/didChange'.
[Trace - 6:58:27 PM] Sending request 'completionItem/resolve - (389)'.
[Trace - 6:58:27 PM] Received response 'completionItem/resolve - (389)' in 1ms.
[Trace - 6:58:27 PM] Sending request 'textDocument/signatureHelp - (390)'.
[Trace - 6:58:27 PM] Sending notification 'textDocument/didChange'.
[Trace - 6:58:27 PM] Sending request 'completionItem/resolve - (391)'.
[Trace - 6:58:27 PM] Sending notification 'textDocument/didChange'.
[Trace - 6:58:27 PM] Sending notification '$/cancelRequest'.
[Trace - 6:58:27 PM] Sending request 'completionItem/resolve - (392)'.
[Trace - 6:58:27 PM] Received response 'textDocument/signatureHelp - (390)' in 201ms.
[Trace - 6:58:27 PM] Received response 'completionItem/resolve - (391)' in 148ms.
[Trace - 6:58:27 PM] Received response 'completionItem/resolve - (392)' in 36ms.
[Trace - 6:58:27 PM] Sending request 'textDocument/signatureHelp - (393)'.
[Trace - 6:58:27 PM] Received response 'textDocument/signatureHelp - (393)' in 2ms.
[Trace - 6:58:28 PM] Sending request 'textDocument/linkedEditingRange - (394)'.
[Trace - 6:58:28 PM] Received response 'textDocument/linkedEditingRange - (394)' in 2ms.
[Trace - 6:58:28 PM] Received notification 'textDocument/publishDiagnostics'.
[Trace - 6:58:28 PM] Sending notification 'textDocument/didChange'.
[Trace - 6:58:28 PM] Sending request 'textDocument/completion - (395)'.
[Trace - 6:58:28 PM] Sending request 'textDocument/documentSymbol - (396)'.
[Trace - 6:58:28 PM] Sending notification '$/cancelRequest'.
[Trace - 6:58:28 PM] Sending request 'volar/client/autoInsert - (397)'.
[Trace - 6:58:28 PM] Sending request 'textDocument/signatureHelp - (398)'.
[Trace - 6:58:28 PM] Sending request 'textDocument/linkedEditingRange - (399)'.
[Trace - 6:58:28 PM] Sending request 'textDocument/documentSymbol - (400)'.
[Trace - 6:58:28 PM] Sending request 'textDocument/documentColor - (401)'.
[Trace - 6:58:28 PM] Sending request 'textDocument/foldingRange - (402)'.
[Trace - 6:58:28 PM] Sending request 'textDocument/semanticTokens/range - (403)'.
[Trace - 6:58:28 PM] Sending request 'textDocument/inlayHint - (404)'.
[Trace - 6:58:28 PM] Sending notification '$/cancelRequest'.
[Trace - 6:58:28 PM] Sending request 'textDocument/inlayHint - (405)'.
[Trace - 6:58:29 PM] Sending request 'textDocument/documentLink - (406)'.
[Trace - 6:58:30 PM] Received response 'textDocument/completion - (395)' in 1863ms.
[Trace - 6:58:30 PM] Received response 'textDocument/documentSymbol - (396)' in 1841ms.
[Trace - 6:58:30 PM] Received response 'volar/client/autoInsert - (397)' in 1763ms.
[Trace - 6:58:30 PM] Sending notification 'textDocument/didChange'.
[Trace - 6:58:30 PM] Sending notification '$/cancelRequest'.
[Trace - 6:58:30 PM] Sending notification '$/cancelRequest'.
[Trace - 6:58:30 PM] Received response 'textDocument/signatureHelp - (398)' in 1750ms.
[Trace - 6:58:30 PM] Received response 'textDocument/linkedEditingRange - (399)' in 1669ms.
[Trace - 6:58:30 PM] Received response 'textDocument/documentSymbol - (400)' in 1520ms.
[Trace - 6:58:30 PM] Received response 'textDocument/documentColor - (401)' in 1489ms.
[Trace - 6:58:30 PM] Received response 'textDocument/foldingRange - (402)' in 1480ms.
[Trace - 6:58:30 PM] Received response 'textDocument/semanticTokens/range - (403)' in 1376ms.
[Trace - 6:58:30 PM] Received response 'textDocument/inlayHint - (404)' in 1251ms.
[Trace - 6:58:30 PM] Sending request 'volar/client/autoInsert - (407)'.
[Trace - 6:58:30 PM] Sending request 'textDocument/signatureHelp - (408)'.
[Trace - 6:58:30 PM] Received response 'textDocument/inlayHint - (405)' in 1226ms.
[Trace - 6:58:30 PM] Received response 'textDocument/documentLink - (406)' in 932ms.
[Trace - 6:58:30 PM] Received response 'volar/client/autoInsert - (407)' in 59ms.
[Trace - 6:58:30 PM] Received response 'textDocument/signatureHelp - (408)' in 49ms.
[Trace - 6:58:30 PM] Sending request 'textDocument/linkedEditingRange - (409)'.
[Trace - 6:58:30 PM] Received response 'textDocument/linkedEditingRange - (409)' in 2ms.
[Trace - 6:58:30 PM] Sending request 'textDocument/documentSymbol - (410)'.
[Trace - 6:58:30 PM] Received response 'textDocument/documentSymbol - (410)' in 4ms.
[Trace - 6:58:30 PM] Sending request 'textDocument/foldingRange - (411)'.
[Trace - 6:58:30 PM] Received response 'textDocument/foldingRange - (411)' in 3ms.
[Trace - 6:58:30 PM] Received notification 'textDocument/publishDiagnostics'.
[Trace - 6:58:30 PM] Sending request 'textDocument/semanticTokens/range - (412)'.
[Trace - 6:58:30 PM] Sending request 'textDocument/inlayHint - (413)'.
[Trace - 6:58:30 PM] Sending notification '$/cancelRequest'.
[Trace - 6:58:30 PM] Sending request 'textDocument/inlayHint - (414)'.
[Trace - 6:58:31 PM] Sending request 'textDocument/documentColor - (415)'.
[Trace - 6:58:31 PM] Sending request 'textDocument/documentLink - (416)'.
[Trace - 6:58:32 PM] Received response 'textDocument/semanticTokens/range - (412)' in 1672ms.
[Trace - 6:58:32 PM] Received notification 'textDocument/publishDiagnostics'.
[Trace - 6:58:32 PM] Received response 'textDocument/inlayHint - (413)' in 1545ms.
[Trace - 6:58:32 PM] Received response 'textDocument/inlayHint - (414)' in 1373ms.
[Trace - 6:58:32 PM] Received response 'textDocument/documentColor - (415)' in 1167ms.
[Trace - 6:58:32 PM] Received response 'textDocument/documentLink - (416)' in 1090ms.
[Trace - 6:58:32 PM] Received notification 'textDocument/publishDiagnostics'.

What is expected?

Intellisense is completing within a reasonable time (100ms?), both when editing template and script

What is actually happening?

Intellisense is extremely slow, often taking 10s of seconds before completions are available

Link to minimal reproduction

No response

Any additional comments?

No response

@KazariEX
Copy link
Collaborator

Is it a new project without any dependencies?

@rigtigeEmil
Copy link
Author

Is it a new project without any dependencies?

Ah sorry, I thought I included my packages. No, it's not fresh. It's a Nuxt project:

  "dependencies": {
    "@nuxt/ui": "https://pkg.pr.new/@nuxt/ui@695224f",
    "@nuxt/ui-pro": "https://pkg.pr.new/@nuxt/ui-pro@0ec16dd",
    "@nuxtjs/i18n": "^9.1.1",
    "@pinia/nuxt": "^0.9.0",
    "nuxt": "^3.14.1592",
    "pinia": "^2.3.0",
    "vue": "latest",
    "vue-router": "4.5.0",
    "zod": "^3.24.1"
  },
  "devDependencies": {
    "@hey-api/client-fetch": "^0.5.2",
    "@hey-api/openapi-ts": "^0.59.1",
    "@iconify-json/lucide": "^1.2.18",
    "@nuxt/eslint": "^0.7.3",
    "@nuxt/test-utils": "^3.15.1",
    "@vue/test-utils": "^2.4.6",
    "eslint": "^9.16.0",
    "happy-dom": "^15.11.7",
    "playwright-core": "^1.49.1",
    "ts-to-zod": "^3.15.0",
    "typescript": "^5.6.3",
    "vitest": "^2.1.6"
  },

@KazariEX
Copy link
Collaborator

Could you install a VSCode extension called Volar Labs to check the memory usage?

  • Turn off Hybrid Mode
  • Open a .vue file
  • Click Vue / TS Memory Treemap in the extensions tab

@rigtigeEmil
Copy link
Author

It spits out an HTML file, is there an easy way to share that?
Looks like this:
image

@KazariEX
Copy link
Collaborator

How much memory did it use in total?

image

@rigtigeEmil
Copy link
Author

200MB:
image

@ludwig801
Copy link

I have similar issues.
In my case, it goes up to 500MB in a single file!

image

@KazariEX
Copy link
Collaborator

KazariEX commented Dec 18, 2024

I have similar issues. 我有类似的问题。 In my case, it goes up to 500MB in a single file!就我而言,单个文件的大小高达 500MB!

image

I think this refers to the total memory used by the TS server. It would better to check which libs are consuming a large amount of memory and consider whether alternatives can be found.

@KazariEX
Copy link
Collaborator

@rigtigeEmil Could you provide a minimal reproduction for investigation?

@rigtigeEmil
Copy link
Author

@KazariEX I will try when I'm home later. Do you have an idea of what could be the cause of the issue? Do you expect it's one of the packages?

Maybe @ludwig801 has a repro he can share now?

@KazariEX
Copy link
Collaborator

It might not be a memory issue for you, but rather a problem caused by some typescript issue, or it could be something else.

@rigtigeEmil
Copy link
Author

I know it's fairly anecdotal, but I saw a few other mention a similar issue in the discord channel associated with language-tools, so it might be a common problem.

@ludwig801
Copy link

@KazariEX I will try when I'm home later. Do you have an idea of what could be the cause of the issue? Do you expect it's one of the packages?

Maybe @ludwig801 has a repro he can share now?

Unfortunately I cannot share my repro, and it seems that this does not happen in small projects...

@rigtigeEmil
Copy link
Author

@KazariEX is there any way to debug this in my project, and figure out what's going on? I've tried in a small replication with the same packages, and while the intellisense is not immediate, it's nowhere near as slow as in my real project.

In my dummy-project I get completions within a reasonable time (100ms~maybe), although not immediate like I've experienced before

@KazariEX
Copy link
Collaborator

KazariEX commented Dec 18, 2024

If you choose to prioritize troubleshooting typescripts, you can try removing files one by one (dichotomy?) from tsconfig and check if the speed of intellisense has been improved.

@johnsoncodehk
Copy link
Member

@rigtigeEmil you should gradually eliminate the differences between the two projects through dichotomy and confirm the minimal differences that cause performance problems. Even if we conduct remote investigations, we only do the same thing. Many of the performance reports we received were ultimately found to be caused by project dependencies or poor TS code.

@ludwig801 project size is usually not the reason, even in TypeScript's checker.ts with 50,000 lines of code, autocompletion can be completed in a few hundred milliseconds. Like I said above, you need to find which differences causing the performance issue.

@rigtigeEmil
Copy link
Author

@rigtigeEmil you should gradually eliminate the differences between the two projects through dichotomy and confirm the minimal differences that cause performance problems. Even if we conduct remote investigations, we only do the same thing. Many of the performance reports we received were ultimately found to be caused by project dependencies or poor TS code.

@ludwig801 project size is usually not the reason, even in TypeScript's checker.ts with 50,000 lines of code, autocompletion can be completed in a few hundred milliseconds. Like I said above, you need to find which differences causing the performance issue.

Is there a way to get debug information out from the extension? About which file(s) could be causing it to hang, if it's some files in my project that are causing the issue?

@Tenrys
Copy link

Tenrys commented Dec 18, 2024

I'm having this issue as well. Usually when I first load my project, IntelliSense can feel relatively snappy, but as I move through files in the project, the language server will start to take several seconds / minutes to catch up with the edits I've made, or an autocomplete prompt I'm asking for.

Now, I have an idea why this might be happening, as I am also working on a Nuxt project, with auto-imports enabled, but also a generated Prisma client. Here I've followed the instructions which @KazariEX provided, and ended up with this.

image

As I thought, the auto-generated Prisma declarations file is extremely large in comparison to everything else in my project, but I honestly don't know how I could work around it.

Excluding the file manually in tsconfig.json does not change anything, and adding skipLibCheck to tsconfig.json does not help either. Naturally, actually opening this file in particular always makes the editor itself choke, and then the TypeScript language might as well have completely given up, as only a full editor reload will help reset the state of things.

It's been an issue with large Prisma projects for a long time, and I imagine the fault lies with the fact that they are keeping the generated types as a single file, regardless of size. It's not like I can just get rid of Prisma altogether, as I am using it on the server side of my app and inside of my client side to help with matching the types of my inputs to the server and its outputs, and I am well into my project's development at this point.

So, I am a bit at a loss as to how to proceed, it's been difficult to keep a steady development pace, having to sometimes sit there waiting for my editor to get going. If I could just throw more RAM at the language server, I would, but it seems like it's limited to only 4 gigabytes.


EDIT: For now I am going to try using https://github.com/HRM/prisma-nitro-patcher to see if it makes any difference, and/or disable my Prisma client extensions for the time being, as I've been reading in this issue that it could be a reason for performance issues.

@ludwig801
Copy link

@ludwig801 project size is usually not the reason, even in TypeScript's checker.ts with 50,000 lines of code, autocompletion can be completed in a few hundred milliseconds. Like I said above, you need to find which differences causing the performance issue.

I understand this. The problem is that this only happens in Vue projects. In TS-only projects I have no problems with performance whatsoever.

Seeing that I'm creating SFC the way I supposed they are to be created (following the official Vue docs) and that I'm importing stuff and doing everything that I'm supposed to, I have to conclude that this issue arise from the Vue language tools and it's way of handling either TS, <script setup> or something other from the language itself.

In sum, I believe I'm not doing anything wrong with TS, since I have other large TS-only projects working just fine, and without a way to properly debug problematic files or common pitfalls that one might be falling into, it's difficult do understand where the problem might be in a project with 1000+ files/components.

@KazariEX
Copy link
Collaborator

KazariEX commented Dec 18, 2024

Before the actual inspection, no one can assert that he has not made any mistakes. And dichotomy is already a very practical debugging way.

@ludwig801
Copy link

Before the actual inspection, no one can assert that he has not made any mistakes. And dichotomy is already a very practical debugging way.

Perhaps, for a small project. For a full platform, such as is my company's case, is a huge pain in the neck with countless hours of debugging and no assurance of an answer.

I'm not trying to be difficult or snappy, but I have to realistically consider the following: this only happens in a Vue project, with the Vue Language Tools - surely it is common sense to believe that it is not my TS scripting capabilities that are at fault here since, as I've mentioned before, I have other full-fledged TS projects which present no issues at all and are quick and performant when editing.

@rigtigeEmil
Copy link
Author

If there's a way to extract more debugging information, it'd be much easer to try and debug on my own, but it's quite a big ask to "try removing stuff until it works". I've invited @KazariEX to a private fork of a minimal version of my own project, and they've confirmed they see the issue too.

I also have no issue with the completion when this extension is not installed, so normal TS IntelliSense is working, outside of Vue files

@KazariEX
Copy link
Collaborator

I just drop the gilbert-api folder then the speed of the intelliSense became fast again.

@rigtigeEmil
Copy link
Author

rigtigeEmil commented Dec 18, 2024

I just drop the gilbert-api folder then the speed of the intelliSense became fast again.

This folder includes type definitions from the backend. It's not particularly large, so it's confusing to me why it'd cause issues. I'd guess it includes perhaps a few hundred types, but is that low amount of type definitions expected to cause issues?

@KazariEX
Copy link
Collaborator

This is not closely related to the amount of code. It's more likely caused by poor TS code.

@rigtigeEmil
Copy link
Author

What's considered poor TS code to the point where it can cause this large of an issue? This code is purely auto-generated, so I won't attempt to exclude the possibility that something could be improved

@KazariEX
Copy link
Collaborator

KazariEX commented Dec 18, 2024

Before the actual inspection, no one can assert that he has not made any mistakes. And dichotomy is already a very practical debugging way.

Perhaps, for a small project. For a full platform, such as is my company's case, is a huge pain in the neck with countless hours of debugging and no assurance of an answer.

I'm not trying to be difficult or snappy, but I have to realistically consider the following: this only happens in a Vue project, with the Vue Language Tools - surely it is common sense to believe that it is not my TS scripting capabilities that are at fault here since, as I've mentioned before, I have other full-fledged TS projects which present no issues at all and are quick and performant when editing.

One important point to note is that IntelliSense itself is built on the communication between the Vue language server and the TS server, they are by no means directly comparable.

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

No branches or pull requests

5 participants