microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
161.62k stars 28.39k forks source link

occupation of CPU is too high when open the specify project #26726

Closed icesman closed 7 years ago

icesman commented 7 years ago

Steps to Reproduce:

  1. open the demo

2.open the web pack.config.js on the root

And then cpu was occupied with process of the Code Helper, make the laptop so hot.

2017-05-16 3 37 08 2017-05-16 3 37 08

Firstly I think it is caused by the plugin and uninstall the plugin, but it still is the same. It works fine with other projects but somehow goes wrong with the demo.

bpasero commented 7 years ago

To find out more about this issue, we need to get at the process that is causing the high load. VS Code creates multiple processes, each with different tasks. Depending on your OS you can get at the full command line of the process and paste it here. On Mac, the Activity Monitor allows to find the PID of the process and from a terminal ps aux | grep <pid> reveals its arguments.

image

On Windows a tool like Process Explorer helps:

image

Once you have the information please update this issue with it. Thanks!

dmlemos commented 7 years ago

Same here. First time I started VS Code after updating to 10.12.5 my CPU went burst on all cores. I closed the process immediately. The second time I started this is what happened:

First lines are % CPU usage

100.0  0.0  2497332   4240   ??  R    11:22am   0:53.62 find -L . -not ( ( -name node_modules -o -name .git -o -name .svn -o -name .hg -o -name CVS -o -name .DS_Store ) -prune ) -type f

98.4  0.0  2498356   4248   ??  R    11:10am   0:56.48 find -L . -not ( ( -name node_modules -o -name .git -o -name .svn -o -name .hg -o -name CVS -o -name .DS_Store ) -prune ) -type f

After closing, these were still around:

196.6  8.3  4579016 1389820   ??  R    11:48am   1:41.59 /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper.app/Contents/MacOS/Code Helper /Applications/Visual Studio Code.app/Contents/Resources/app/out/bootstrap --type=watcherService

104.3  9.2  4753544 1551752   ??  R    11:48am   1:01.84 /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper.app/Contents/MacOS/Code Helper /Applications/Visual Studio Code.app/Contents/Resources/app/out/bootstrap --type=searchService

Had to kill them by hand.

After restarting the same thing happens. find doesn't come until after a while.

Update: It seems to be only happening when starting from the shell code . If I start the application normally, even though there are open projects the behaviour is not experienced.

First part seems related to #26670

icesman commented 7 years ago

@bpasero
here is the process, but I don't know why I trigger this process.

 Code.app/Contents/Frameworks/Code Helper.app/Contents/MacOS/Code Helper /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/typingsInstaller.js --globalTypingsCacheLocation /Users/iceman/Library/Caches/typescript --enableTelemetry
iceman            1031   0.0  0.0  2443044   2012 s000  S+    8:57上午   0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn 1013
2017-05-17 8 45 18
bpasero commented 7 years ago

Looks like TypeScript typings aquisition.

icesman commented 7 years ago

Can I fix it ? Actually I doesn't write any code at TypeScript and it happens in some earlier versions of VS Code.

hezedu commented 7 years ago

Reason is .eslintrc: It causes CPU to always be high

dmlemos commented 7 years ago

More issues related to this #27133 #27131. This seems to be getting quite common.

Is there any more information you need?

mjbvz commented 7 years ago

The typings installer high CPU issue was tracked by https://github.com/Microsoft/TypeScript/issues/15301 but we didn't have enough data to investigate further

@icesman TypeScript powers both our javascript and TypeScript language features. Using the latest insiders build for VSCode 1.13, can you please try collecting the typings installer logs:

icesman commented 7 years ago

@mjbvz I try the VSCode 1.13 but can't reproduce the issue. It works well of the VSCode 1.13

icesman commented 7 years ago

@mjbvz It appears again after working about half hour...

Global cache location '/Users/iceman/Library/Caches/typescript', safe file path '/applications/visual studio code - insiders.app/contents/resources/app/extensions/node_modules/typescript/lib/typingsafelist.json'
Processing cache location '/Users/iceman/Library/Caches/typescript'
Trying to find '/Users/iceman/Library/Caches/typescript/package.json'...
Loaded content of '/Users/iceman/Library/Caches/typescript/package.json': {"devDependencies":{"@types/async":"^2.0.40","@types/babel-core":"^6.7.14","@types/compression-webpack-plugin":"^0.3.1","@types/copy-webpack-plugin":"^4.0.0","@types/extract-text-webpack-plugin":"^2.0.1","@types/firebase":"^2.4.31","@types/glob":"^5.0.30","@types/html-webpack-plugin":"^2.28.0","@types/js-base64":"^2.1.5","@types/node":"^7.0.18","@types/optimize-css-assets-webpack-plugin":"^1.3.1","@types/sprintf":"0.0.28","@types/stylus":"^0.48.27","@types/webpack":"^2.2.15","@types/webpack-dev-server":"^1.12.6","@types/webpack-hot-middleware":"^2.15.0","@types/webpack-merge":"0.0.4"}}
Adding entry into typings cache: 'async' => '/Users/iceman/Library/Caches/typescript/node_modules/@types/async/index.d.ts'
Adding entry into typings cache: 'babel-core' => '/Users/iceman/Library/Caches/typescript/node_modules/@types/babel-core/index.d.ts'
Adding entry into typings cache: 'compression-webpack-plugin' => '/Users/iceman/Library/Caches/typescript/node_modules/@types/compression-webpack-plugin/index.d.ts'
Adding entry into typings cache: 'copy-webpack-plugin' => '/Users/iceman/Library/Caches/typescript/node_modules/@types/copy-webpack-plugin/index.d.ts'
Adding entry into typings cache: 'extract-text-webpack-plugin' => '/Users/iceman/Library/Caches/typescript/node_modules/@types/extract-text-webpack-plugin/index.d.ts'
Adding entry into typings cache: 'firebase' => '/Users/iceman/Library/Caches/typescript/node_modules/@types/firebase/index.d.ts'
Adding entry into typings cache: 'glob' => '/Users/iceman/Library/Caches/typescript/node_modules/@types/glob/index.d.ts'
Adding entry into typings cache: 'html-webpack-plugin' => '/Users/iceman/Library/Caches/typescript/node_modules/@types/html-webpack-plugin/index.d.ts'
Adding entry into typings cache: 'js-base64' => '/Users/iceman/Library/Caches/typescript/node_modules/@types/js-base64/index.d.ts'
Adding entry into typings cache: 'node' => '/Users/iceman/Library/Caches/typescript/node_modules/@types/node/index.d.ts'
Adding entry into typings cache: 'optimize-css-assets-webpack-plugin' => '/Users/iceman/Library/Caches/typescript/node_modules/@types/optimize-css-assets-webpack-plugin/index.d.ts'
Adding entry into typings cache: 'sprintf' => '/Users/iceman/Library/Caches/typescript/node_modules/@types/sprintf/index.d.ts'
Adding entry into typings cache: 'stylus' => '/Users/iceman/Library/Caches/typescript/node_modules/@types/stylus/index.d.ts'
Adding entry into typings cache: 'webpack' => '/Users/iceman/Library/Caches/typescript/node_modules/@types/webpack/index.d.ts'
Adding entry into typings cache: 'webpack-dev-server' => '/Users/iceman/Library/Caches/typescript/node_modules/@types/webpack-dev-server/index.d.ts'
Adding entry into typings cache: 'webpack-hot-middleware' => '/Users/iceman/Library/Caches/typescript/node_modules/@types/webpack-hot-middleware/index.d.ts'
Adding entry into typings cache: 'webpack-merge' => '/Users/iceman/Library/Caches/typescript/node_modules/@types/webpack-merge/index.d.ts'
Finished processing cache location '/Users/iceman/Library/Caches/typescript'
Process id: 15479
NPM location: npm (explicit '--npmLocation' not  provided)
Npm config file: /Users/iceman/Library/Caches/typescript/package.json
Updating types-registry npm package...
Got install request {"projectName":"/dev/null/inferredProject1*","fileNames":["/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/extensions/node_modules/typescript/lib/lib.es6.d.ts","/Users/iceman/vue-multiple-page-cnode/webpack.config.js"],"compilerOptions":{"module":1,"target":2,"allowSyntheticDefaultImports":true,"allowNonTsExtensions":true,"allowJs":true,"jsx":1,"checkJs":false,"noEmitForJsFiles":true,"maxNodeModuleJsDepth":2},"typeAcquisition":{"enable":true,"include":[],"exclude":[]},"unresolvedImports":["caniuse-db","caniuse-db","caniuse-db","caniuse-db","caniuse-db","caniuse-db","caniuse-db","caniuse-db","caniuse-db","caniuse-db","caniuse-db","caniuse-db","caniuse-db","caniuse-db","caniuse-db","caniuse-db","caniuse-db","caniuse-db","caniuse-db","caniuse-db","caniuse-db","caniuse-db","caniuse-db","caniuse-db","caniuse-db","caniuse-db","caniuse-db","caniuse-db","caniuse-db","caniuse-db","caniuse-db","caniuse-db","caniuse-db","caniuse-db","caniuse-db","caniuse-db","caniuse-db","caniuse-db","caniuse-db","caniuse-db","caniuse-db","caniuse-db","caniuse-db","caniuse-db","caniuse-db","caniuse-db","caniuse-db","caniuse-db","caniuse-db","caniuse-db","caniuse-db","caniuse-db","caniuse-db","caniuse-db","caniuse-db","caniuse-db","caniuse-db","caniuse-db","child_process","crypto","events","events","fs","http","net","path","readline","stream","tls"],"projectRootPath":"","kind":"discover"}

Here is the log, I hope it is helpful for u

mjbvz commented 7 years ago

Hey @andy-ms, the "projectRootPath":"","kind":"discover" bit looks suspicious. It seems like the discoverTypings function never completes in this case?

Can you please take a look at the logs and see if anything stands out

dmlemos commented 7 years ago

@mjbvz Unfortunately I cannot get the log. I set the setting, but when I try TypeScript: Open TS Server log gives me this error:

Could not open TS Server log file

icesman commented 7 years ago

@dmlemos I also can't open the log file and I use the ps aux | grep <pid> to get the information. It will print the path of log file after you enable the log. Hope it also works for you.

mjbvz commented 7 years ago

Yes there was a bug in VSCode 1.12 where if the logfile grows very large we would fail to open it.

ps aux should work, and in VSCode 1.13 the Open TS Server Logcommand will now open the log file directory instead of trying to open the log file itself. VSCode 1.13 also prints to log file path to the TypeScript section of the output window (scroll to the very top of the output to see this):

screen shot 2017-06-01 at 2 09 54 pm

You can try this out in the current insiders builds: https://code.visualstudio.com/insiders

mjbvz commented 7 years ago

Talked with the TypeScript team this morning about this issue. As a first step to investigate what may be causing the high cpu usage with the typings installer, I believe that we need to add some additional logging around the discover part of the typings installer. I've opened https://github.com/Microsoft/TypeScript/issues/16203 to track this work on the TypeScript side. We'll continue the investigation into this problem over there

Thanks

dmlemos commented 7 years ago

Can't get the log path with ps either. Running this command: ps aux | grep -i code | grep -i log

Version: 1.12.2

When is the insider build coming out?

jens1o commented 7 years ago

You can download it here: https://code.visualstudio.com/insiders

(It will update each day.)

dmlemos commented 7 years ago

Issue remains with 1.13.0

mecp commented 7 years ago

Same here with 1.13.0

icesman commented 7 years ago

@mecp @dmlemos the issue now is moved to Microsoft/TypeScript#16203 . It's not fixed right now.