-
-
Notifications
You must be signed in to change notification settings - Fork 596
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
High CPU Usage #1051
Comments
The Vetur extension is making VS Code nearly unusable for me. |
Running VS Code with Vetur is now a sure-fire way to get my laptop fans spinning non-stop. Something must have changed in the past couple of weeks to trigger this. If I disable Vetur, my CPU usage goes back to normal. |
The VS Code Process Explorer shows that "electron_node vueServerMain.js" is consuming 100% CPU! |
BTW, I'm running it on a Mac. I really hope this can get some attention soon. I love using VS Code, but it's completely unusable as soon as I install Vetur and open a .vue file. |
I have same issue.
The project is not very lagre (~ 450 files).
But if I remove baseUrl everything works fine. |
I'm not using TypeScript, so I think the issue goes beyond that. Could this be a Mac-specific issue? Is anyone seeing this on Windows? I know there are lots of people that use VS Code on a Mac to edit Vue projects. It's hard to believe this isn't affecting a lot of people now. Really serious! |
@mvolkmann Does this happen for https://github.com/octref/veturpack or only large projects? |
Interesting. I can't reproduce the problem if I clone the veturpack repo, quit out of VS Code, start it again, only open the veturpack project, and open a bunch of .vue files inside it. But if I do the same with my project, the CPU usage jumps quickly after just opening a single .vue file. My project only contains about 25 source files. So I need to figure out what it is about my project that could trigger this behavior. I'm open to suggestions for what to try. |
The "Process Explorer" in VS Code shows that "electron_node vueServerMain.js is consuming 100% of a CPU. |
@mvolkmann Try this one #1054, upgrade your TS version in We are still using TS 2.8, I'm working on allowing workspace version of TS: #682. The TypeScript Language Server (which powers the smart editing features for TS, and which Vetur builds upon) shipped with 2.8 probably received numerous fixes since then, so try a more recent version. |
I'm looking at ~/.vscode/extensions/octref.vetur-0.15.0/server/package.json and I see this: "typescript": "2.8.4", Are you suggesting that I should change that version and run "npm install" in that directory? |
Yeah, try a few different versions, for example |
I tried typescript 2.9.2 and 3.3.1. In both cases I can start VS Code from scratch, open a Vue project, open a single .vue file, and see the CPU usage spike. If I open another kind of file like a .md or .js file and have no .vue files open, the CPU usage does not spike. So it definitely seems related to processing of .vue files. |
Do you have a github link or somewhat to your .vue files for reproducing? |
I created this: https://github.com/mvolkmann/vetur-cpu-issue. All I did was use the latest version of the Vue CLI to create a new application. I didn't modify any of the code. All I need to do to trigger a CPU spike is open this project directory in VS Code, open src/App.vue, and enable Vetur. If Vetur is not enabled, I do not get a CPU spike. |
Do you suppose I could have some VS Code setting that is causing the problem? Maybe something related to TypeScript? I don't currently have TypeScript installed globally. |
Can you tell us which extensions are installed and show us your settings.json. Maybe this can help us. |
Thanks so much for taking a look at this!
A zipped version of my settings.json is attached. |
Oh, you've got lots of extensions and lots of settings. Try to deactivate all extensions and clear your settings.json (make a backup before) and try again. If the cpu-usage got better, try to re-activate one by one your extension. |
Some initial results ... Disabling all extensions except Vetur and restarting VS Code did not fix the problem. The CPU usage is still high. Now I'll try removing all my custom settings. |
My settings.json file now contains just { }. |
I understand this is a tough issue to track down. It is possible this only affects a small number of users? Every few days I decide to try using Vetur again and every time the CPU usage spikes and my cooling fans go crazy. I end up having to uninstall it again. |
#1126 may provide more info. |
Same issue here on Linux. Vetur used to be slow, which is OK but now it's eating my CPU like crazy, even for a simple EDIT: heck, the Vetur process even got stuck after closing VSCode. Had to kill it manually. EDIT2: happens in Code Insiders, too, with only Vetur installed as an extension. 😭 Have to switch to this until it's fixed. |
I'm pretty sure this is not a vscode issue but an issue with this extension itself. It's agonizingly slow when I use Vetur with VIM + a LanguageServer plugin. Autocomplete lags behind while typing, dot completion takes forever, etc. |
Actually this issue is not directly slow performance issue. It is caused when you try to save file with improper tags (invalid html). |
I don’t believe this is only caused by saving files. I can reproduce the issue simply by installing Vetur and opening a single .vue file. |
We are also facing the same issues with high cpu usage and poor performance in Vetur. It is actually so slow that we cannot use the extension. It is a pretty large project with a combination of ts files as well as vue files. The big performance problems started when upgrading to 0.18 of vetur Did some profile of the extension and it looks like the extension is spending a lot of time in "string.replace". According to the picture above, 16 seconds is spend in string.replace. The above profile was triggered by writing and deleting a character in a vue file several times. |
A did some debugging and it looks like |
@petternordholm Do you mind sending me a copy of the profile? The perf problem might be caused by either #1174, TypeScript, or Vetur's template interpolation support. For those of you running into the problem, can you try if the perf problem still reproduces in the following scenarios? (Don't do 3 together. Do them one by one to find the factor.)
|
Also here's a guide to profiling VLS: https://github.com/vuejs/vetur/blob/master/.github/PERF_ISSUE.md#profiling. It would help a lot if anyone else could attach their profile to this issue. |
@octref Kudos for great work with the extension!!. Please find attached the profiling from 0.19.2 An easy way to improve performance is to use the following replace function instead, https://jsperf.com/optimized-replace/1 (in getSingleLanguageDocument & getSingleTypeDocument). According to jspref, it performs a lot faster than plain string replace. It should work with both windows and unix line endings. We are currently using a locally patched version of vetur and the optimized replace makes the extension usable for us again. Profiling with standard string.replace And profiling with optimized replace: |
@petternordholm Nice work! I created #1264. Do you want to send a PR to just fix that? This issue is too overloaded. For All accesses to those files are cached so it should be fine returning a large list. However, does that One thing I realized is I might be returning |
I fixed #1264 and will publish a new version to benefit others. I added instructions for https://github.com/vuejs/vetur/blob/master/.github/PERF_ISSUE.md. If you still have perf issues with Vetur, please open new issues with profiles. @petternordholm Thanks again for your help. One last question: Does your change in |
@octref Great!! My change in getScriptFileNames makes a quite big difference. Discovered that excluding all files except for the vue file currently being edited broke "import auto completion" since typescript does not know anything about the other files in the project (except for the one being edited and its' dependencies). So, in our current patched version I've added back all ts files but excluded test files since we never want to include those in vue files. Code completion is still fluent but I haven't compared to the latest version in master. I will rebase my "fork" to the latest and investigate this further during the weekend and get back to you! BTW! There might be a bug in serviceHost.ts:getParsedConfig . The exclude defined in tsconfig.json will be overwritten by defaultIgnorePatterns |
If your current change does make things good for you, how about adding a exclude pattern like I see where all this problems might come from...In https://vuejs.github.io/vetur/setup.html#project-setup I suggested using {
"include": [
"./src/**/*"
]
} Which I certainly shouldn't have done... |
I think I have found a good fix. Can you try the VSIX linked here? #1277 (comment) |
@octref I have same problem
when I scroll up and down, the cpu usage would up tp 100% uninstall vetur will be normal here is the cpu profile |
@yaoguoli Please open new issues instead of attaching to old ones that was fixed. |
@octref Isn't better to re-open the issue (as it's the same), so people following it doesn't lose any update? |
@sirikon Not really, from the cpuprofile it's another perf issue. Opening new issues makes it easier for me to see which perf issues I fixed and which are not. |
same issues, high cpu, can't lint js/ts in .vue file, it work just disable vetur |
@lisonge I rewritten the Vue TypeScript Language Service to solve the performance problem, It is worth mentioning that it supports Pug, and built-in html to pug conversion tool. |
@johnsoncodehk |
I hit this problem too (MacOS 15.5.6, VS Code 1.48.2, Vetur 0.26.1). It appears there was something wrong with my settings.json/.eslintrc/.pretterrc/.editorconfig that was causing the problem. I have installed Vetur using Vue Extension Pack (0.1.3). By changing the settings files to the values shown in the readme config section and restarting VS Code the high CPU usage problem disappeared. |
@dgethings I don't think those are related to Vetur. If you really find a perf bug, please turn off all other extensions and record a profile: https://github.com/vuejs/vetur/blob/master/.github/PERF_ISSUE.md By a rough look I think it's the auto close/rename tags extensions being slow. Check their marketplace reviews. |
Same issue on neovim 0.4.4 with latest coc-vetur......... takes forever to parse 670 lines vue file, and then even scrolling is slow as hell... |
Please open a new issue. |
Info
Problem
Reproducible Case
The text was updated successfully, but these errors were encountered: