Sometimes Vetur is still very slow
See original GitHub issueInfo
- Platform: Windows
- Vetur version: 0.26.1
- VS Code version: 1.48.1
Problem
I’ve seen related issues like https://github.com/vuejs/vetur/issues/1272 talking about calls to synchronizeHostData
. I did not dig in too much, but I found that when validating sources and templates, calls such as getSemanticDiagnostics
may call synchronizeHostData
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.
https://github.com/vuejs/vetur/blob/53ee52746b1f26f44391c3764bc7bd06d4ddaa46/server/src/modes/template/interpolationMode.ts#L72
https://github.com/vuejs/vetur/blob/2e32351514b01f3bec9478c0e55217e21b88d8ae/server/src/modes/script/javascript.ts#L118
Issue Analytics
- State:
- Created 3 years ago
- Comments:14 (7 by maintainers)
Top GitHub Comments
Hi @yoyo930021 Thank you so much
I tried #2332 and #2328 before The performance problem is better than at the beginning, but it is still very slow. I closed
vetur.validation.interpolation
andvetur.languageFatures.codeAction
because of work later. After closing these two items, the performance is not so badI 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
vetur. .validation.interpolation
andvetur.languageFatures.codeAction
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
I’ve found out why it’s slow when using typescript template service and borken https://github.com/vuejs/vetur/issues/2192#issuecomment-699864856.
vetur.experimental.templateInterpolationService: true
.The
synchronizeHostData
function will check up to date withisProgramUptoDate
function. https://github.com/microsoft/TypeScript/blob/c88e44a9e65f7d7a72ef72c9dfae94ef0fcb6bb0/src/services/services.ts#L1307It check
sourceFileNotUptoDate
with using sourceFileversion
property equal tohost.getScriptVersion(sourceFile.fileName)
result . https://github.com/microsoft/TypeScript/blob/c88e44a9e65f7d7a72ef72c9dfae94ef0fcb6bb0/src/compiler/program.ts#L579When template sourceFile, The sourceFile get
version
propertyundefined
. Because we create new sourceFile when generated template code, and missingversion
,scriptSnapshot
properties in language service sourceFile. https://github.com/vuejs/vetur/blob/a7331253140367075e841268bbcc3a2b06ec04df/server/src/services/typescriptService/preprocess.ts#L118I fix this problem in #2374.