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

4

10

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

Tintoretto answered 3/12, 2020 at 6:12 Comment(3)
where do you see these commands logged?Lunitidal
@rioV8, in htopTintoretto
it is a program written in rust that is an enhanced replacement for grep. Looking at your rg command it isn't searching for anything. is it only looking in .go files. Maybe ask via an VSC issue why they need to call it so often (on a MacOS) and what they are searching forLunitidal
T
4

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.

Tintoretto answered 4/12, 2020 at 4:12 Comment(2)
then what is the reason to use --no-ignore-parent argument. the crux of .gitignore is that you locally specify what extra stuff you want to be ignored.Lunitidal
I don't know why --no-ignore-parent is used. I also find an alternative way is to exclude folders in vscode settings, which also seem to work.Tintoretto
H
4

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.

Hashim answered 23/1 at 20:12 Comment(0)
A
0

I have just experienced same issue.

I have relatively small Node/Express project with only few files.

After trying few suggested fixes, none worked. I have found out that other projects I was loading did not have same issue, so started looking at project related possible issue and only thing that was quite bloated was .git folder. Was consuming over 100mB in space and around 10k files.

I have followed Clear local git cache suggestions and it worked. All 20x CPU cores utilisation dropped to 10-15% instead of being almost max out at all times.

Clear local git cache:

git rm -r --cached .
git add .
git commit -am 'git cache cleared'
git push

I have not further investigated what caused the issue, but I assume some git bloating.

Adiabatic answered 9/4 at 11:0 Comment(0)
P
-1

In my case, it's a problem related to the local history extension I used.

I was running a jupyter notebook in VS Code and the extension may be continuously checking the file changes abnormally. Disable it and the CPU usage immediately drops.

Therefore, this problem can be extension-related. Any extension processes many files may cause this issue.

Paraldehyde answered 14/6 at 13:22 Comment(2)
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From ReviewBerkley
Hello and welcome in StackOverflow, and thx for your contribution. However, your answer don't reply to the question.Lebar

© 2022 - 2024 — McMap. All rights reserved.