-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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
rg.exe takes too much cpu #43847
Comments
And somehow it starts to index at the launch of vscode which is not necessary in my point of view as I use it very rarely... |
@warpdesign How many files do you have? (In Powershell you could pipe the output of the above Is this on a local NTFS drive? |
@jens1o That is likely triggered by an extension with a |
Okay, that sounds reasonable then. I didn't knew you are using rg for file-extension lookups, too. |
@chrmarti It is a local NTFS drive. I tried to run the exact same rg.exe command in a powershell prompt but I am getting an error from powershell: is there something special to do to execute normal executables with lots of parameters in a powershell prompt?
This powershell stuff is so unfriendly and un-intuitive it makes me think vi is not so bad... |
I finally used What has the number of files to do with the cpu usage? Shouldn't the |
@warpdesign Could you check what What I do with Process Monitor is:
Please then share what you found. |
There are a lot of REPARSE results for the various ignore files, are these symlinks? Some of these later result in a NAME NOT FOUND, could these be dangling symlinks? Are there many of these? You mentioned ripgrep 0.6.0 didn't have that performance issue, does that also have these REPARSE results for the ignore files? /cc @BurntSushi |
The various checks on I don't understand the significance of a REPARSE result though. |
Like I said, there aren't much symlinks, but there are lots of files in these symlinks. So in the screenshot, there is only one symlink:
So all REPARSE are following the same symlink. Behind that symlink there are lots of files/directories but there aren't more symlinks to resolve. But if it's the symlink access that takes cpu time and it's being resolved for each file/directory, maybe this could explain the cpu usage? I don't understand the One more hint: could it be a path_length limitation problem? |
@BurntSushi My understanding is that REPARSE is the result when the file has a reparse point which is a generic hook in NTFS that is also used for symlinks. (https://msdn.microsoft.com/en-us/library/windows/desktop/aa365503%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396) |
Also, |
At least from ripgrep's point of view, crawling a directory with 100,000 entries in it isn't going to be especially snappy, at least from my experience running similar searches on Windows systems. So there might be an expectation adjustment that is at play here. I do not have any opinion on "lower multitask priority." That is beyond my domain. :) It would also help to know what version of ripgrep is being used here, since there have been changes in this area that could impact performance over the last couple releases. If you weren't observing this problem with ripgrep 0.6.0 but are observing it with ripgrep 0.7.1, then that is an interesting data point, and it might be worth comparing the process monitor output for each tool. But beyond that, I would personally need a reproducible case to debug it further. Another important debug point here is the ability to run these commands in a shell. I would suggest that someone help you figure out how to do that. ripgrep may be emitting important details about this particular search that will help diagnose the problem.
ripgrep can't read files that have paths over the limit, and this is a known bug. It will emit an error for each. |
Why would a large directory use more cpu? I would understand it would take more time to be indexed, but not why it uses more cpu. Does it mean the more files, the more cpu will be used? Jetbrain's Idea doesn't has this cpu usage problem and can index everything just fine, without putting my machine on its knees :)
I can run these commands in a All tests were done using ripgrep that's bundled with latest insider build:
|
@warpdesign I'm trying to reproduce the REPARSE events you see, but a single symbolic link to a large directory doesn't do that for me. To establish if this is a regression, could you run the following in PowerShell when in your workspace folder with ripgrep shipped with VS Code 1.20 and also with ripgrep 0.6.0 to compare against:
|
I tried running the command of my first message using ripgrep that's bundled with VSCode 1.18.1 (that's ripgrep No wonder it's faster in version |
@warpdesign It sounds like what you're saying is that ripgrep 0.7.1 is following a symbolic link even though you aren't giving it the |
@BurntSushi If I understand correctly, ripgrep isn't supposed to follow symlinks unless the |
Then I think we know where the regression comes from:
If I run the same command line with |
As I said above, I don't immediately know how that's happening. I need a reproducible case. It would also be helpful to know whether this happens with ripgrep 0.8. |
@warpdesign I don't see 0.7.1 (as shipped with VS Code 1.20) follow symbolic links nor hard links (junctions) without |
I created a very small test-case;
As you can see, ripgrep goes through resources which is a symlink, and the |
Here is the ouput of
|
Where can I get rg |
Thanks @warpdesign, I can reproduce it with the insiders build! @roblourens 0.7.1 in insiders always follows symlinks while 0.7.1 in 1.20 correctly doesn't. Using |
@warpdesign https://github.com/BurntSushi/ripgrep/releases has all releases. |
@BurntSushi Using your Windows 64bit MSVC builds 0.7.1 works correctly, 0.8.0 follows the symlink even without |
I have filed BurntSushi/ripgrep#820 to track the performance regression in ripgrep. @roblourens Can you check why the ripgrep 0.7.1 build we use in 1.21-insiders has picked up the regression from 0.8.0? |
Also filed a second issue for the original issue of following symlinks: BurntSushi/ripgrep#824 |
can confirm rg.exe causes excessive cpu usage, and of course it turned the whole editor unusable. |
I tried to set the priority of the Maybe that would be a good workaround? As a user I'd rather have the indexing process take more time than having my whole computer unusable. |
Rolling back to what we have in 1.20.1 since @roblourens is out with the following commits:
We can adapt ripgrep 0.8.1 with the fixes after VS Code 1.21 has shipped. Thanks @BurntSushi and @warpdesign! |
Did you go past the fix for #43284? It's easy to release a fix with the old rg and a fix for that if needed. |
Never mind it looks like we still have that. |
Marking as verified. I saw the CPU spike for rg.exe last week as well and don't with current Insider build. |
I post this issue as a follow up to #35659
In my workspace, the latest VSCode (1.20 or 1.21 insider) takes too much cpu. Using the task manager, I can see that VSCode spawns two rg.exe processes that use around 45% cpu each, making my computer unusable.
Note that these processes appear as soon as I press
ctrl + p
.I have a few symlinks in my project, maybe 4-6, don't know exactly.
As I said in #35659, adding
search.followSymlinks: false
doesn't fix the problem.Using the TaskManager, I could see the full command line that's being used for
rg.exe
:I tried to run the exact same command from a command prompt (after cd to my project's rootdir) and it worked, took about 1 minute with no error.
During the execution of the command, the cpu usage is very high and never goes below 85%.
I am Using Windows 10 (Inisders) 64bit. A colleague of mine got the same cpu usage problem with stable Windows 10 64 bit (Fall Creators Update), so we can rule out Windows Insider version.
Let me know if you need more information.
The text was updated successfully, but these errors were encountered: