Closed yaolunmao closed 2 years ago
I tried vicons before but I can't reproduce. Please provide repro case, and your VSCode info by Help: About
command.
This is my vscode information. In the current version, not only the CPU is 100%, but also the memory will surge to 1gb-2gb, which makes me very distressed. Is there any way to get useful logs for you? Incidentally, I didn't close vetur because I needed its TS support
Already has issue #399, but I hard to getting a repro case.
Please follow steps to make a repro case:
Help: About
command.I don't want to use issue template to force user provide all informations, but check the proformance issue that missing repro case / informations is very time consuming. I will close kind of this issues until repro case provided.
Thank you for your reminder
hello!I have uninstalled all extensions and only kept them:volar, but the problem still exists. this is my vscode info:
Version: 1.60.1 (user setup)
Commit: 83bd43bc519d15e50c4272c6cf5c1479df196a4d
Date: 2021-09-10T17:07:10.714Z
Electron: 13.1.8
Chrome: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Windows_NT x64 10.0.22000
If you want to reproduce the problem,you can
git clone https://github.com/yaolunmao/volar-test.git
cd volar-test
npm i
then open this folder with vs code
then Double click App.vue
in vscode
then
ctrl+shift+esc
see the taskmanager
The problem comes from two aspects:
vicons
& naive-ui
is too long. This problem can be reproduced in plain ts. Due to volar's overhead, the initialization time of using vicons
& naive-ui
in volar is longer than plain ts. The time in my macbook is about 55 seconds, and the time after optimization is 43 seconds.vicons
& naive-ui
, and file watcher watch all these files, which leads to the permanent system cpu using too high. Resolved by cancel to watch files that are not in the tsconfig include.im having constantly cpu usage also on my linux machine on "vite": "^2.4.4", + "ant-design-vue": "^2.2.8",
Please try 0.27.23.
Good job! I really appreciate it. The tired CPU with overwork could take a rest now.
ok it does drop to between 1 to 6% . thank you :pray:
Nice!The CPU is now between 1% and 5%,But my version was originally 0.27.23. I don't know why it works now. Hahaha
Glory belongs to reproduction provider @yaolunmao. :)
This issue has been raised a long time ago, but most people just complained or gave the lowest rating and didn't want to help solve it. If there is a repro case, I can solve it quickly usually.
@johnsoncodehk volar seems scan my project file for ever, this cause a cpu usage about 10%, why not use os fs event?
@kikyous I don't know the difference between these, currently I just use ts.sys.watchFile: https://github.com/johnsoncodehk/volar/search?q=%22ts.sys.watchFile%22
Can you provide some references, or a PR?
I think use a lib like chokidar is a good choice: https://github.com/paulmillr/chokidar
tool like Chokidar use filesystem event to listen file change, insted of polling file system.
Chokidar does still rely on the Node.js core fs module, but when using fs.watch and fs.watchFile for watching, it normalizes the events it receives, often checking for truth by getting file stats and/or dir contents.
On MacOS, chokidar by default uses a native extension exposing the Darwin FSEvents API. This provides very efficient recursive watching compared with implementations like kqueue available on most *nix platforms. Chokidar still does have to do some work to normalize the events received that way as well.
On most other platforms, the fs.watch-based implementation is the default, which avoids polling and keeps CPU usage down. Be advised that chokidar will initiate watchers recursively for everything within scope of the paths that have been specified, so be judicious about not wasting system resources by watching much more than needed.
I think use a lib like chokidar is a good choice: https://github.com/paulmillr/chokidar
Volar used chokidar at the beginning, but I forgot what caused me to deprecate it and use ts.sys.watchFile instead.
I can try it again, please open a new issue to track.
It seems that I need configure vscode ts extension to use fs event:
"typescript.tsserver.watchOptions": {
"watchDirectory": "useFsEvents",
"watchFile": "useFsEvents",
"useFsEvents": true,
"usePolling": false
}
or in tsconfig.json: https://www.typescriptlang.org/docs/handbook/configuring-watch.html
Now cpu usage is very low when idle
安装了这两个包
可能和volar插件有冲突,导致cpu占用过高