Skip to content
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

RipGrep using a lot of CPU #40480

Closed
bcherny opened this issue Dec 19, 2017 · 7 comments
Closed

RipGrep using a lot of CPU #40480

bcherny opened this issue Dec 19, 2017 · 7 comments
Assignees
Labels
info-needed Issue requires more information from poster perf

Comments

@bcherny
Copy link

bcherny commented Dec 19, 2017

OSX's Activity Monitor reports two rg processes pegged around 350% CPU. My machine is really slow, and fans are spinning loudly.

$ code --status

Version:          Code 1.19.0 (816be6780ca8bd0ab80314e11478c48c70d09383, 2017-12-14T09:51:12.123Z)
OS Version:       Darwin x64 17.3.0)
CPUs:             Intel(R) Core(TM) i7-6920HQ CPU @ 2.90GHz (8 x 2900)
Memory (System):  16.00GB (0.02GB free)
Load (avg):       9, 11, 14
VM:               0%
Screen Reader:    no

CPU %	Mem MB	Process
    3	    33	code main
    0	    16	   gpu-process
    0	    16	   shared-process
    0	    33	   window (input.txt — flow-to-typescript)
    0	    16	     watcherService
    0	    16	     extensionHost
    0	    16	       searchService
  146	   377	         /Applications/Visual Studio Code.app/Contents/Resources/app/node_modules/vscode-ripgrep/bin/rg --files --hidden --case-sensitive -g /*.r|.rd|rmd --no-ignore --follow --quiet -- .
    0	    16	       electron_node electronForkStart.js tsserver.js 
    0	    16	         electron_node typingsInstaller.js tsserver.js typesMap.js 
    0	    16	       electron_node server.js 
    0	    16	       electron_node jsonServerMain.js 
    0	    16	       extensionHost
    0	    16	       extensionHost
    0	    16	     searchService
  152	   475	       /Applications/Visual Studio Code.app/Contents/Resources/app/node_modules/vscode-ripgrep/bin/rg --files --hidden --case-sensitive -g **/*.{css,html} -g !/undefined -g !**/.git -g !**/.svn -g !**/.hg -g !**/CVS -g !**/.DS_Store -g !/.bower/** -g !/.sass-cache/** --no-ignore --follow -- .

Workspace Stats: 
|  Window (input.txt — flow-to-typescript)
|    Folder (flow-to-typescript): 125 files
|      File types: ts(38) txt(36) js(19) map(19) json(4) DS_Store(3) md(2)
|                  gitignore(1) yml(1) flowconfig(1)
|      Conf files: tslint.json(2) package.json(1) tsconfig.json(1)

Steps to Reproduce:

git clone git@github.com:bcherny/flow-to-typescript.git
cd flow-to-typescript
yarn
code .

Reproduces without extensions: No

@cleidigh cleidigh added the perf label Dec 19, 2017
@genuss
Copy link

genuss commented Dec 19, 2017

Add to your config "search.useRipgrep": false and search won't use rg

@roblourens
Copy link
Member

Reproduces without extensions: No

Which extensions do you have installed? (Help > Report issue to get a list)

@roblourens roblourens added the info-needed Issue requires more information from poster label Dec 19, 2017
@bcherny
Copy link
Author

bcherny commented Dec 20, 2017

@genuss Does search still work without RipGrep? What is the downside of disabling it?

@roblourens See below v

  • VSCode Version: Code 1.19.0 (816be67, 2017-12-14T09:51:12.123Z)
  • OS Version: Darwin x64 17.3.0
  • Extensions:
Extension Author (truncated) Version
gc-excelviewer Gra 2.0.16
beautify Hoo 1.1.1
r Iku 0.5.2
ejs-language-support Qas 0.0.1
haskelly UCL 0.4.28
html-css-class-completion Zig 1.14.0
npm-intellisense chr 1.3.0
path-intellisense chr 1.4.2
vscode-eslint dba 1.4.3
scala-lsp dra 0.2.2
tslint eg2 1.0.24
vscode-npm-script eg2 0.3.3
flow-for-vscode flo 0.7.3
vscode-ghc-mod hoo 1.2.0
language-haskell jus 2.4.0
csstriggers kis 0.4.0
python ms- 0.9.1
debugger-for-chrome msj 4.0.0
PostCSS ric 1.0.1
vscode-flow rto 276.3.0
elm sbr 0.15.1
stylelint shi 0.31.0
visualclojure sti 0.0.2
vscode-import-cost wix 2.5.1

(1 theme extensions excluded)

@roblourens
Copy link
Member

roblourens commented Dec 20, 2017

Does search still work without RipGrep? What is the downside of disabling it?

Yes but it will be much slower.

I'm guessing the first rg instance is from the R extension since it seems to be looking for R files.

  • How long does it take for those processes to finish?
  • Are you using pnpm or cnpm?
  • If you run that command directly on the command line, /Applications/Visual Studio Code.app/Contents/Resources/app/node_modules/vscode-ripgrep/bin/rg --files --hidden --case-sensitive -g /*.r|.rd|rmd --no-ignore --follow --quiet -- . does it finish faster?

@bcherny
Copy link
Author

bcherny commented Dec 20, 2017

Thanks for the guidance @roblourens! The issue was caused by my forked version of Babel, which contains circular imports. It caused rg to run in an infinite loop (see output from Ripgrep below).

To solve this, I disabled Ripgrep ("search.useRipgrep": false) for now, until I'm back on mainline Babel.

So the question now: Why do circular imports (or at least this flavor of them) cause an infinite loop?

Googling for the error message, I found #35659, which links to the underlying RipGrep issue BurntSushi/ripgrep#633.

Closing this issue as a duplicate.

$ "/Applications/Visual Studio Code.app/Contents/Resources/app/node_modules/vscode-ripgrep/bin/rg" --files --hidden --case-sensitive -g "*.r|.rd|rmd" --no-ignore --follow --quiet -- .
File system loop found: ./node_modules/babel/packages/babel-standalone/node_modules/@babel/plugin-syntax-object-rest-spread/node_modules/@babel/core/node_modules/@babel/helper-transform-fixture-test-runner/node_modules/@babel/core points to an ancestor ./node_modules/babel/packages/babel-standalone/node_modules/@babel/plugin-syntax-object-rest-spread/node_modules/@babel/core
File system loop found: ./node_modules/babel/packages/babel-standalone/node_modules/@babel/plugin-syntax-object-rest-spread/node_modules/@babel/core/node_modules/@babel/register/node_modules/@babel/core points to an ancestor ./node_modules/babel/packages/babel-standalone/node_modules/@babel/plugin-syntax-object-rest-spread/node_modules/@babel/core
...

@bcherny bcherny closed this as completed Dec 20, 2017
@roblourens
Copy link
Member

Thanks for investigating that. Ripgrep probably isn't getting into an infinite loop, but is slow in following lots of symlinks.

One thing you can try - reenable ripgrep and tell it not to follow symlinks, with "search.followSymlinks": false - I think that is respected for the searches triggered to activate extensions.

@bcherny
Copy link
Author

bcherny commented Dec 20, 2017

@roblourens You're right it's possible that it's just slow - I've been running that rg command for 20 mins and it's still running.

"search.followSymlinks": false does seem to fix the issue, as also noted in the other VSCode thread I linked.

@vscodebot vscodebot bot locked and limited conversation to collaborators Feb 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
info-needed Issue requires more information from poster perf
Projects
None yet
Development

No branches or pull requests

4 participants