Many rg commands started by vscode that consume 99% of CPUs

8.5k Views Asked by At

I'm working inside a very big github repo, say its structure is like

project-root
├── project-1
│   ├── subproject-a
│   └── subproject-others
└── project-2
    ├── subproject-b
    └── subproject-others

There are many projects, each contains many subprojects. I'm just working on one of the subprojects (e.g. subproject-a). When I opened vscode inside the subproject (it's a python subproject), I noticed that it launches many rg commands like below, and my CPU usage goes above 99%. I wonder what these rg commands are about? Are they just searching for stuffs inside the subproject, or the whole git repo, which contains tens of thousands of files? Why do they consume so many resources? How could I avoid that, please?

/Applications/Visual Studio Code.app/Contents/Resources/app/node_modules.asar.unpacked/vscode-ripgrep/bin/rg --files --hidden --case-sensitive -g **/*.go/** -g **/*.go -g !**/.git -g !**/.svn -g !**/.hg -g !**/CVS -g !**/.DS_Store -g !**/.classpath -g !**/.factorypath -g !**/.project -g !**/.settings -g !**/node_modules -g !**/bower_components -g !**/*.code-search --no-ignore-parent --follow --quiet --no-config --no-ignore-global

2

There are 2 best solutions below

2
On BEST ANSWER

It turns out that there are four symlink folders with over 700k files in them. These folders are usually ignored in /project-root/.gitginore. So rg by default would ignore searching in them.

But here because of --no-ignore-parent --follow flags, they are being searched nonetheless.

I added these folders to /project-root/project-1/subproject-a/.gitignore again, and now these rg commands don't take so much cpu resource anymore.

0
On

I'm leaving my solution in case works for anyone else, none of the other solutions worked for me and I discovered that this only happened when I tried to ng build the project.

I read somewhere (can't remember where exactly) that the extension Auto Import trigger this rg process. I tried disabling it and my Mac just came back to normal. If you have the extension, try this, it may work.