Skip to content

ripgrep file search uses too many threads #206030

Closed

Description

@taranu

vscode appears to use ripgrep for file searches in two places: ripgrepTextSearchEngine.ts and ripgrepFileSearch.ts. ripgrep has a -j/--threads argument with a default value of 0, which "causes ripgrep to choose the thread count using heuristics", which is to say that it's implicitly multithreaded with some unknown number of threads.

I believe this is the root cause of a number of other issues filed with excessive CPU/memory usage by ripgrep (e.g. #203425), though certainly launching too many rg processes can be a problem regardless.

One issue I haven't seen reported is that on a distributed file system, having too many file search threads running simultaneously can severely degrade performance. In fact we're seeing a single user able to cause a weka filesystem to hang for a minute or more just through a remote VScode session launching one or two ripgrep processes.

I'd like to request a configuration option to set the number of threads (the -j argument to rg) wherever ripgrep is used. I'd prefer the default to be 1 to disable implicit multithreading, but 0 would be fine as long as the configuration option exists.

Activity

  1. added
    feature-request
    on Mar 22, 2024
  2. vscodenpa commented on Mar 22, 2024

    @vscodenpa

    This feature request is now a candidate for our backlog. The community has 60 days to upvote the issue. If it receives 20 upvotes we will move it to our backlog. If not, we will close it. To learn more about how we handle feature requests, please see our documentation.

    Happy Coding!

  3. vscodenpa commented on Mar 26, 2024

    @vscodenpa

    🙂 This feature request received a sufficient number of community upvotes and we moved it to our backlog. To learn more about how we handle feature requests, please see our documentation.

    Happy Coding!

  4. added
    search
    on Mar 26, 2024
  5. added
    unreleased
    insiders-released
    and removed
    unreleased
    on Jun 6, 2024
  6. andreamah commented on Jun 24, 2024

    @andreamah
    Contributor

    verification steps:

    1. Open a repo with a lot of files (ie: vscode-docs)
    2. Open the Process Explorer
    3. Run a text search for something and the command for rg.exe in the process explorer should not have the --threads argument.
    4. Set search.ripgrep.maxThreads to 1
    5. Run the text search again and the command for rg.exe in the process explorer should have the --threads 1 argument.

    See #213511 (comment) for images.

  7. added
    verification-needed
    on Jun 24, 2024
  8. added
    verified
    on Jun 25, 2024
  9. locked and limited conversation to collaborators on Jul 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

feature-requestinsiders-releasedsearchverification-neededverified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions