-
-
Notifications
You must be signed in to change notification settings - Fork 594
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
Sometimes Vetur is still very slow #2192
Comments
Can you attach a profile? If not, can you validate your hypothesis by
|
Tried to |
I've studied this side. Maybe |
I've just found an old buried pull request which might be useful... #1141 |
I want to provide some information Platform: macos In my typescript project, performance problems have bothered me for a long time, and I checked a lot of performance related problems, such as #2163 and #2150 #2150 (comment) The reproduction method is as follows
The profile of this operation is as follows But I can’t save this, because one click save, chrome dev tools will crash directly After this replacement process, vetur enters the slow mode, all operations will become very slow For example, for this type of automatic completion prompt, the corresponding prompt box will pop up about 15-20 seconds after entering the point This is the cpuprofile for this operation Then after restarting vscode, the same operation will become faster, just like this Let me talk about my thoughts first I think that every save operation will generate typescript type snapshot or something, because during the batch replacement operation, I observed that the memory of the vetur server has been changing drastically, from 160mb to more than 400mb, and then back to 160mb , 4-5mb growth per second. Then a large number of snapshots caused the subsequent overall slowdown. Because through this recurring operation, I found that the running of vuter on the typescript project will become slow as the number of saves increases, and then I can only restart vscode to solve the problem Vetur is a very good plugin. I like it very much. Recently I started to write Vue projects with typescript, but this performance problem bothered me very much. I had to write code for a while and restart vscode. I hope someone can help solve this Question. Thank you very much If you want me to provide more information, please feel free to reply to me, I will see |
I will study it when free. I think we can provide a VSCode command for restart Vetur LSP. |
@yoyo930021 Thank you for your attention to this issue Recently I cloning vetur and did some tests First of all, I checked the profile I got before, and I saw that the In addition to my usual experience, when the vetur is running slowly, if you quickly type in a string of unformatted code that will report an error, the formatting error prompt is obviously delayed from your operation, and the execution of the formatting error prompt is completed. Before, all other operations, such as saving, code hints, would be blocked So I started with this function, I tried vetur/server/src/services/vls.ts Line 495 in 2e32351
In the first line of this function directly return [] Then I tested it locally, and I found that everything became very fast, including the replacement of more than 30 files. Of course, I only tested for a while, because all error verification was turned off, so typing in any code There is no error prompt, but all code prompts are complete and fast Next, I found that this function calls the doValidation function for specific verification operations. I searched for the doValidation function in the project, and I found that it is roughly composed of 3 parts vetur/server/src/modes/script/javascript.ts Line 109 in 2e32351
style vetur/server/src/modes/style/index.ts Line 59 in 2e32351
template vetur/server/src/modes/template/index.ts Line 50 in 2e32351
I tested these three parts separately. In the first line of the function, directly vetur/server/src/modes/template/index.ts Line 51 in 2e32351
One part is htmlMode , part is vueInterpolationMode After testing the two parts separately, I found that when the doValidation of vueInterpolationMode is disabled like this
return this.htmlMode.doValidation(document) Performance has been significantly improved, at least the code prompt will basically not be stuck If you directly set So if this performance problem cannot be solved temporarily, I hope I can temporarily provide an option to turn off error checking on After a period of use, I found that the performance of vetur will still slow down over time, but it is much better than before. When it is slow, the code prompt takes about two or three seconds instead of the previous 20- 30 seconds, but I think this effect is acceptable for the time being, because before I used to restart vscode after 20 or 30 minutes, now it may be restarted every half day I hope my test feedback can help you identify the problem faster |
Hi @Eurkidu , this option is existing. The name is |
Thanks, I found this option Yes, not verifying the code on the I will test it #2332 |
The #2328 is reduced recreate ts program. You can find calling I analyze I finally found |
I've found out why it's slow when using typescript template service and borken #2192 (comment). The It check When template sourceFile, The sourceFile get
I fix this problem in #2374. |
Hi @yoyo930021 Thank you so much I tried #2332 and #2328 before I read your latest reply the day before yesterday. I understand that this problem is probably related to typescript sourceFile version. Then I merged #2328 and #2374 locally and used it for a while, and also opened the previously closed After 2 days of use, I found that this is really great, everything has become very normal, I don’t need to restart vscode again after I work a day, I think the problem is probably solved, and there is basically no physical feeling the performance drops over time However, I still have a little confusion. When I perform batch file replacement, even if I only replace a comment globally, in the case of about 28 files, the replacement needs to be executed for about 15s, about 500ms for each file, depending on the status The column prompt is that vscode is formatting each file. Is this effect normal, but after the file batch replacement is completed, it will not slow down the overall operation as before. This is perfect. I will continue to test my local version, but I think the problem is probably solved. I hope that if there is no problem in the test, #2374 can be merged as soon as possible @octref |
Thanks your test. You can open a new issue about format performance problem. Here's a method for determining problem whether it's Vetur or not:
|
I encountered the same issue with Vetur on VSCode and macOS bigsur. Vetur would take too long to save a file and I had to click on cancel to save the file. The issue seems to have been resolved on my machine (at least for now). Here are the steps -
|
Info
Problem
I've seen related issues like #1272 talking about calls to
synchronizeHostData
. I did not dig in too much, but I found that when validating sources and templates, calls such asgetSemanticDiagnostics
may callsynchronizeHostData
internally (link), and by a rudimentary profiling it looks like each validation will took ~300ms on my computer. When I'm writing code, js and template will be validated separately, so they might take something like 500 or 600ms in total.I'm not sure if that's the cause of the issue since I didn't do an accurate profiling, but probably it will help.
vetur/server/src/modes/template/interpolationMode.ts
Line 72 in 53ee527
vetur/server/src/modes/script/javascript.ts
Line 118 in 2e32351
The text was updated successfully, but these errors were encountered: