Repository: vscode
Issue: "Search files by name" is slow when using remote
Labels: bug,search

<!-- ⚠️⚠️ Do Not Delete This! bug_report_template ⚠️⚠️ -->
<!-- Please read our Rules of Conduct: https://opensource.microsoft.com/codeofconduct/ -->
<!-- 🕮 Read our guide about submitting issues: https://github.com/microsoft/vscode/wiki/Submitting-Bugs-and-Suggestions -->
<!-- 🔎 Search existing issues to avoid creating duplicates. -->
<!-- 🧪 Test using the latest Insiders build to see if your issue has already been fixed: https://code.visualstudio.com/insiders/ -->
<!-- 💡 Instead of creating your report here, use 'Report Issue' from the 'Help' menu in VS Code to pre-fill useful information. -->
<!-- 🔧 Launch with `code --disable-extensions` to check. -->
Does this issue occur when all extensions are disabled?: Yes/No

<!-- 🪓 If you answered No above, use 'Help: Start Extension Bisect' from Command Palette to try to identify the cause. -->
<!-- 📣 Issues caused by an extension need to be reported directly to the extension publisher. The 'Help > Report Issue' dialog can assist with this. -->
- VS Code Version: 1.78.2
- OS Version: MacOs Ventura 13.3.1

Steps to Reproduce:

1. Use VSCode in remote mode and use "Search files by name" (with telemetry enabled)
2. Compare the results within the same folder when not using remote

The bigger the repository, the worse it gets, and in subsequent calls, the gap narrows (I'm assuming this happens because of some in-memory cache being populated).

I've already followed [Search Issues · microsoft/vscode Wiki](https://github.com/Microsoft/vscode/wiki/Search-Issues#slow-search-rg-running-for-a-long-time-or-consuming-lots-of-cpumemory) to troubleshoot known cases, and tweaked the configuration to exclude as many files as I could, but in my codebase, it takes a really long time to perform searches.

Here is an example of me trying to use `cmd+p` and entering a query, waiting for it to resolve, and then trying the exact same query:

```
2023-05-25 17:34:42.321 [trace] telemetry/searchComplete {"properties":{"reason":"openFileHandler","scheme":"other","common.machineId":"66a593bf48622b3d8732d01f98fa2c27a72345606331167b14474051cdbccf7b","sessionID":"9d6c1d73-9a19-4e78-afb1-d7d8e95a90141685057185375","commitHash":"b3e4e68a0bc097f0ae7907b217c1119af9e03435","version":"1.78.2","common.platformVersion":"22.4.0","common.platform":"Mac","common.nodePlatform":"darwin","common.nodeArch":"arm64","common.product":"desktop","timestamp":"2023-05-25T23:34:42.320Z","common.version.shell":"22.5.2","common.version.renderer":"108.0.5359.215","common.firstSessionDate":"Mon, 12 Sep 2022 16:11:14 GMT","common.lastSessionDate":"Fri, 12 May 2023 17:29:33 GMT","common.isNewSession":"0","common.remoteAuthority":"ssh-remote","common.sandboxed":"0"},"measurements":{"resultCount":0,"workspaceFolderCount":1,"endToEndTime":8812,"sortingTime":-1,"fileWalkTime":8780,"directoriesWalked":0,"filesWalked":0,"cmdTime":8780,"cmdResultCount":368085,"common.timesincesessionstart":496945,"common.sequence":7,"common.cli":1}}
2023-05-25 17:35:20.492 [trace] telemetry/cachedSearchComplete {"properties":{"reason":"openFileHandler","scheme":"other","common.machineId":"66a593bf48622b3d8732d01f98fa2c27a72345606331167b14474051cdbccf7b","sessionID":"9d6c1d73-9a19-4e78-afb1-d7d8e95a90141685057185375","commitHash":"b3e4e68a0bc097f0ae7907b217c1119af9e03435","version":"1.78.2","common.platformVersion":"22.4.0","common.platform":"Mac","common.nodePlatform":"darwin","common.nodeArch":"arm64","common.product":"desktop","timestamp":"2023-05-25T23:35:20.491Z","common.version.shell":"22.5.2","common.version.renderer":"108.0.5359.215","common.firstSessionDate":"Mon, 12 Sep 2022 16:11:14 GMT","common.lastSessionDate":"Fri, 12 May 2023 17:29:33 GMT","common.isNewSession":"0","common.remoteAuthority":"ssh-remote","common.sandboxed":"0"},"measurements":{"resultCount":110872,"workspaceFolderCount":1,"endToEndTime":7734,"sortingTime":3375,"cacheWasResolved":1,"cacheLookupTime":0,"cacheFilterTime":125,"cacheEntryCount":368086,"common.timesincesessionstart":535116,"common.sequence":22,"common.cli":1}}
```