microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.28k stars 28.89k forks source link

When I use the search function, I get stuck #229131

Open imhager opened 2 weeks ago

imhager commented 2 weeks ago

Type: Performance Issue

Every time I use the search function, there is a lag. vscode version : latest

VS Code version: Code 1.93.1 (38c31bc77e0dd6ae88a4e9cc93428cc27a56ba40, 2024-09-11T17:20:05.685Z) OS version: Windows_NT x64 10.0.22631 Modes:

System Info |Item|Value| |---|---| |CPUs|13th Gen Intel(R) Core(TM) i7-1370P (20 x 2189)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off| |Load (avg)|undefined| |Memory (System)|31.69GB (7.38GB free)| |Process Argv|--file-uri file:///d%3A/workspaces/java.workspace/mycloud.code-workspace --crash-reporter-id ed426ba1-119b-4d66-9646-cbf95958db21| |Screen Reader|no| |VM|0%|
Process Info ``` CPU % Mem MB PID Process 0 142 46100 code main 0 40 9000 utility-network-service 0 27 11856 crashpad-handler 0 321 22396 window [1] (mycloud (工作区) - Visual Studio Code [管理员]) 0 113 32436 fileWatcher [1] 0 118 39756 shared-process 0 243 55564 extensionHost [1] 0 2 11964 "d:\Program Files\Git\cmd\git.exe" for-each-ref --format=%(refname)%00%(upstream:short)%00%(objectname)%00%(upstream:track)%00%(upstream:remotename)%00%(upstream:remoteref) --ignore-case refs/heads/origin/master refs/remotes/origin/master 0 5 12284 "d:\Program Files\Git\cmd\git.exe" for-each-ref --format=%(refname)%00%(upstream:short)%00%(objectname)%00%(upstream:track)%00%(upstream:remotename)%00%(upstream:remoteref) --ignore-case refs/heads/master refs/remotes/master 0 10 29244 C:\windows\system32\conhost.exe 0x4 0 3 50124 git.exe for-each-ref --format=%(refname)%00%(upstream:short)%00%(objectname)%00%(upstream:track)%00%(upstream:remotename)%00%(upstream:remoteref) --ignore-case refs/heads/master refs/remotes/master 0 397 22916 c:\Users\dean\.vscode\extensions\ms-dotnettools.csharp-2.45.25-win32-x64\.roslyn\Microsoft.CodeAnalysis.LanguageServer.exe --logLevel Information --razorSourceGenerator c:\Users\dean\.vscode\extensions\ms-dotnettools.csharp-2.45.25-win32-x64\.razor\Microsoft.CodeAnalysis.Razor.Compiler.dll --razorDesignTimePath c:\Users\dean\.vscode\extensions\ms-dotnettools.csharp-2.45.25-win32-x64\.razor\Targets\Microsoft.NET.Sdk.Razor.DesignTime.targets --starredCompletionComponentPath c:\Users\dean\.vscode\extensions\ms-dotnettools.vscodeintellicode-csharp-2.1.11-win32-x64\components\starred-suggestions\platforms\win32-x64\node_modules\@vsintellicode\starred-suggestions-csharp.win32-x64 --devKitDependencyPath c:\Users\dean\.vscode\extensions\ms-dotnettools.csharp-2.45.25-win32-x64\.roslynDevKit\Microsoft.VisualStudio.LanguageServices.DevKit.dll --sessionId 0f383968-c111-41eb-8687-25b7e1e3bfea1726819600956 --extension c:\Users\dean\.vscode\extensions\ms-dotnettools.csharp-2.45.25-win32-x64\.xamlTools\Microsoft.VisualStudio.DesignTools.CodeAnalysis.dll --extension c:\Users\dean\.vscode\extensions\ms-dotnettools.csharp-2.45.25-win32-x64\.xamlTools\Microsoft.VisualStudio.DesignTools.CodeAnalysis.Diagnostics.dll --telemetryLevel all --extensionLogDirectory c:\Users\dean\AppData\Roaming\Code\logs\20240920T160640\window1\exthost\ms-dotnettools.csharp 0 85 28980 electron-nodejs (start-server.js ) 0 5 31052 "d:\Program Files\Git\cmd\git.exe" config --local branch.master.vscode-merge-base 0 8 42152 git.exe config --local branch.master.vscode-merge-base 0 10 52588 C:\windows\system32\conhost.exe 0x4 0 4 39776 electron-nodejs (config.js ) 0 131 12168 electron-nodejs (config.js ) 0 74 56548 "c:\Users\dean\.vscode\extensions\ms-dotnettools.csdevkit-1.10.18-win32-x64\components\vs-green-server\platforms\win32-x64\node_modules\@microsoft\servicehub-controller-net60.win32-x64/Microsoft.ServiceHub.Controller" 7c4565113de718d69026d5011a84f5d35b408537ef2e25d61c4721bd83b19c44 /ControllerCooldownTimeout:30000 "/TelemetrySession:{\"TelemetryLevel\":\"all\",\"IsOptedIn\":false,\"HostName\":\"Default\",\"AppInsightsInstrumentationKey\":null,\"AsimovInstrumentationKey\":null,\"CollectorApiKey\":\"0c6ae279ed8443289764825290e4f9e2-1a736e7c-1324-4338-be46-fc2a58ae4d14-7255\",\"AppId\":1010,\"UserId\":\"37499a5e-afdf-4ea1-8111-3f0e2227d2bc\",\"Id\":\"0f383968-c111-41eb-8687-25b7e1e3bfea1726819600956\",\"ProcessStartTime\":133712932139798191,\"SkuName\":null,\"VSExeVersion\":null,\"BucketFiltersToEnableWatsonForFaults\":[{\"AdditionalProperties\":[{\"Key\":\"DumpType\",\"Value\":\"Heap\"}],\"Id\":\"81b2b10a-a4da-4266-847a-b7d88165550b\",\"WatsonEventType\":\"VisualStudioNonFatalErrors2\",\"BucketParameterFilters\":[\"(?i)microsoft.visualstudio.code.servicehost.exe\",null,\"(?i)vs.unittest.testwindowhost.fault_2\",\"(?i)streamjsonrpc.connectionlostexception\",\"(?i)system.private.corelib\",\"(?i)system.runtime.exceptionservices.exceptiondispatchinfo.throw\",null,null,null,null]}],\"BucketFiltersToAddDumpsToFaults\":[{\"AdditionalProperties\":[{\"Key\":\"DumpType\",\"Value\":\"Heap\"}],\"Id\":\"81b2b10a-a4da-4266-847a-b7d88165550b\",\"WatsonEventType\":\"VisualStudioNonFatalErrors2\",\"BucketParameterFilters\":[\"(?i)microsoft.visualstudio.code.servicehost.exe\",null,\"(?i)vs.unittest.testwindowhost.fault_2\",\"(?i)streamjsonrpc.connectionlostexception\",\"(?i)system.private.corelib\",\"(?i)system.runtime.exceptionservices.exceptiondispatchinfo.throw\",null,null,null,null]}]}" 0 115 39952 "c:\Users\dean\.vscode\extensions\ms-dotnettools.csdevkit-1.10.18-win32-x64\components\vs-green-server\platforms\win32-x64\node_modules\@microsoft\visualstudio-code-servicehost.win32-x64/Microsoft.VisualStudio.Code.ServiceHost.exe" dotnet$C94B8CFE-E3FD-4BAF-A941-2866DBB566FE net.pipe://56548F1E2AFB13448F0C0CAE69E96427B60D8 "/TelemetrySession:{\"TelemetryLevel\":\"all\",\"IsOptedIn\":false,\"HostName\":\"Default\",\"AppInsightsInstrumentationKey\":null,\"AsimovInstrumentationKey\":null,\"CollectorApiKey\":\"0c6ae279ed8443289764825290e4f9e2-1a736e7c-1324-4338-be46-fc2a58ae4d14-7255\",\"AppId\":1010,\"UserId\":\"37499a5e-afdf-4ea1-8111-3f0e2227d2bc\",\"Id\":\"0f383968-c111-41eb-8687-25b7e1e3bfea1726819600956\",\"ProcessStartTime\":133712932139798191,\"SkuName\":null,\"VSExeVersion\":null,\"BucketFiltersToEnableWatsonForFaults\":[{\"AdditionalProperties\":[{\"Key\":\"DumpType\",\"Value\":\"Heap\"}],\"Id\":\"81b2b10a-a4da-4266-847a-b7d88165550b\",\"WatsonEventType\":\"VisualStudioNonFatalErrors2\",\"BucketParameterFilters\":[\"(?i)microsoft.visualstudio.code.servicehost.exe\",null,\"(?i)vs.unittest.testwindowhost.fault_2\",\"(?i)streamjsonrpc.connectionlostexception\",\"(?i)system.private.corelib\",\"(?i)system.runtime.exceptionservices.exceptiondispatchinfo.throw\",null,null,null,null]}],\"BucketFiltersToAddDumpsToFaults\":[{\"AdditionalProperties\":[{\"Key\":\"DumpType\",\"Value\":\"Heap\"}],\"Id\":\"81b2b10a-a4da-4266-847a-b7d88165550b\",\"WatsonEventType\":\"VisualStudioNonFatalErrors2\",\"BucketParameterFilters\":[\"(?i)microsoft.visualstudio.code.servicehost.exe\",null,\"(?i)vs.unittest.testwindowhost.fault_2\",\"(?i)streamjsonrpc.connectionlostexception\",\"(?i)system.private.corelib\",\"(?i)system.runtime.exceptionservices.exceptiondispatchinfo.throw\",null,null,null,null]}]}" 0 10 12544 C:\windows\system32\conhost.exe 0x4 0 101 43768 "c:\Users\dean\.vscode\extensions\ms-dotnettools.csdevkit-1.10.18-win32-x64\components\vs-green-server\platforms\win32-x64\node_modules\@microsoft\visualstudio-code-servicehost.win32-x64\Microsoft.VisualStudio.Code.ServiceHost.exe" dotnet.projectSystem$C94B8CFE-E3FD-4BAF-A941-2866DBB566FE net.pipe://56548F1E2AFB13448F0C0CAE69E96427B60D8 "/TelemetrySession:{\"TelemetryLevel\":\"all\",\"IsOptedIn\":false,\"HostName\":\"Default\",\"AppInsightsInstrumentationKey\":null,\"AsimovInstrumentationKey\":null,\"CollectorApiKey\":\"0c6ae279ed8443289764825290e4f9e2-1a736e7c-1324-4338-be46-fc2a58ae4d14-7255\",\"AppId\":1010,\"UserId\":\"37499a5e-afdf-4ea1-8111-3f0e2227d2bc\",\"Id\":\"0f383968-c111-41eb-8687-25b7e1e3bfea1726819600956\",\"ProcessStartTime\":133712932139798191,\"SkuName\":null,\"VSExeVersion\":null,\"BucketFiltersToEnableWatsonForFaults\":[{\"AdditionalProperties\":[{\"Key\":\"DumpType\",\"Value\":\"Heap\"}],\"Id\":\"81b2b10a-a4da-4266-847a-b7d88165550b\",\"WatsonEventType\":\"VisualStudioNonFatalErrors2\",\"BucketParameterFilters\":[\"(?i)microsoft.visualstudio.code.servicehost.exe\",null,\"(?i)vs.unittest.testwindowhost.fault_2\",\"(?i)streamjsonrpc.connectionlostexception\",\"(?i)system.private.corelib\",\"(?i)system.runtime.exceptionservices.exceptiondispatchinfo.throw\",null,null,null,null]}],\"BucketFiltersToAddDumpsToFaults\":[{\"AdditionalProperties\":[{\"Key\":\"DumpType\",\"Value\":\"Heap\"}],\"Id\":\"81b2b10a-a4da-4266-847a-b7d88165550b\",\"WatsonEventType\":\"VisualStudioNonFatalErrors2\",\"BucketParameterFilters\":[\"(?i)microsoft.visualstudio.code.servicehost.exe\",null,\"(?i)vs.unittest.testwindowhost.fault_2\",\"(?i)streamjsonrpc.connectionlostexception\",\"(?i)system.private.corelib\",\"(?i)system.runtime.exceptionservices.exceptiondispatchinfo.throw\",null,null,null,null]}]}" 0 10 49368 C:\windows\system32\conhost.exe 0x4 0 10 28148 C:\windows\system32\conhost.exe 0x4 0 5 41868 "d:\Program Files\Git\cmd\git.exe" status -z -uall 0 9 39804 git.exe status -z -uall 0 10 55792 C:\windows\system32\conhost.exe 0x4 0 87 42664 electron-nodejs (languageserver.js ) 0 2 54096 "d:\Program Files\Git\cmd\git.exe" rev-parse --git-dir --git-common-dir 0 2 40092 C:\windows\system32\conhost.exe 0xffffffff -ForceV1 0 209 54592 c:\Users\dean\.vscode\extensions\ms-dotnettools.csharp-2.45.25-win32-x64\.razor\rzls.exe --logLevel 2 --DelegateToCSharpOnDiagnosticPublish true --UpdateBuffersForClosedDocuments true --SingleServerCompletionSupport true --telemetryLevel all --sessionId 0f383968-c111-41eb-8687-25b7e1e3bfea1726819600956 --telemetryExtensionPath c:\Users\dean\.vscode\extensions\ms-dotnettools.csharp-2.45.25-win32-x64\.razorDevKit\Microsoft.VisualStudio.DevKit.Razor.dll 0 5 57108 "d:\Program Files\Git\cmd\git.exe" -c core.longpaths=true rev-list --count --left-right refs/heads/master...refs/remotes/origin/master 0 10 44316 C:\windows\system32\conhost.exe 0x4 0 178 57000 gpu-process ```
Workspace Info ``` | Window (mycloud (工作区) - Visual Studio Code [管理员]) | Folder (mycloud): more than 20326 files | File types: py(4338) pyc(4195) png(1215) xml(834) java(832) class(696) | js(469) jpg(429) pyi(284) ts(230) | Conf files: package.json(11) settings.json(6) dockerfile(4) | tsconfig.json(4) webpack.config.js(3) | Folder (syzygroup): more than 20214 files | File types: java(3950) cs(1885) xml(1556) vue(1421) png(1319) js(1122) | html(1073) class(722) cshtml(186) svg(183) | Conf files: csproj(32) package.json(20) dockerfile(5) settings.json(4) | gulp.js(4) sln(2) | Folder (zxdp): 16519 files | File types: java(4189) class(3284) png(1368) xml(1128) html(936) | js(583) vue(502) jpg(368) css(356) meta(210) | Conf files: dockerfile(7) settings.json(3) package.json(2) | webpack.config.js(1) | Folder (syzy-exhibition-digitizing): 570 files | File types: xml(116) java(73) class(65) yml(13) properties(11) jar(9) | md(7) gitignore(6) sha1(5) log(5) | Conf files:; ```
Extensions (37) Extension|Author (truncated)|Version ---|---|--- vue-peek|dar|1.0.2 vscode-markdownlint|Dav|0.56.0 vscode-eslint|dba|3.0.10 githistory|don|0.6.20 json-tools|eri|1.0.2 prettier-vscode|esb|11.0.0 auto-close-tag|for|0.5.15 go|gol|0.42.1 gc-excelviewer|Gra|4.2.62 rest-client|hum|0.25.1 prettier-sql-vscode|inf|1.6.0 hive-sql|jos|0.0.4 markdown-shortcuts|mdi|0.12.0 dotenv|mik|1.0.1 vscode-language-pack-zh-hans|MS-|1.93.2024091109 csdevkit|ms-|1.10.18 csharp|ms-|2.45.25 vscode-dotnet-runtime|ms-|2.1.5 vscodeintellicode-csharp|ms-|2.1.11 debugpy|ms-|2024.10.0 python|ms-|2024.14.1 vscode-pylance|ms-|2024.9.1 remote-wsl|ms-|0.88.3 sqltools|mtx|0.28.3 vscode-vue2-snippets|Nic|2.3.0 indent-rainbow|ode|8.3.1 minapp-vscode|qiu|2.4.13 vs-code-prettier-eslint|rve|6.0.0 vue-vscode-snippets|sdr|3.1.1 markdown-preview-enhanced|shd|0.8.14 vscode-stylelint|sty|1.4.0 intellicode-api-usage-examples|Vis|0.2.8 vscode-concourse|vmw|1.55.0 vscode-manifest-yaml|vmw|1.55.0 vscode-icons|vsc|12.9.0 volar|Vue|2.1.6 markdown-all-in-one|yzh|3.6.2
A/B Experiments ``` vsliv368cf:30146710 vspor879:30202332 vspor708:30202333 vspor363:30204092 vswsl492cf:30256860 vscod805cf:30301675 binariesv615:30325510 vsaa593cf:30376535 py29gd2263:31024239 c4g48928:30535728 azure-dev_surveyone:30548225 a9j8j154:30646983 962ge761:30959799 pythongtdpath:30769146 pythonnoceb:30805159 asynctok:30898717 pythonmypyd1:30879173 2e7ec940:31000449 pythontbext0:30879054 dsvsc016:30899300 dsvsc017:30899301 dsvsc018:30899302 cppperfnew:31000557 dsvsc020:30976470 pythonait:31006305 dsvsc021:30996838 01bff139:31013167 a69g1124:31058053 dvdeprecation:31068756 dwnewjupyter:31046869 2f103344:31071589 impr_priority:31102340 nativerepl2:31139839 refactort:31108082 pythonrstrctxt:31112756 flightc:31134773 wkspc-onlycs-t:31132770 nativeloc2:31134642 wkspc-ranged-c:31125598 fje88620:31121564 iacca1:31138162 ```
IllusionMH commented 2 weeks ago

/needsMoreInfo

Where are you searching(editor or Find in files)? What is search string and modifiers?

vs-code-engineering[bot] commented 2 weeks ago

Thanks for creating this issue! We figured it's missing some basic information or in some other way doesn't follow our issue reporting guidelines. Please take the time to review these and update the issue.

Happy Coding!

imhager commented 2 weeks ago

/needsMoreInfo

Where are you searching(editor or Find in files)? What is search string and modifiers?

in windows(11) platform, ctrl+shift+f, and then searching anything.

imhager commented 2 weeks ago

/needsMoreInfo Where are you searching(editor or Find in files)? What is search string and modifiers?

in windows(11) platform, ctrl+shift+f, and then searching anything.

Additional information: If you're listening to a song (such as QQ Music), you can clearly feel the lag sound when you open VSCode or search.

sanskar-19 commented 2 weeks ago

+1 on this.

andreamah commented 2 weeks ago

Is this a recent regression? Does this happen with all extensions disabled?

imhager commented 2 weeks ago

Is this a recent regression? Does this happen with all extensions disabled?

i'm not sure. even if all extensions are disabled, it's still there. and Tested on version 1.86.2 and found no issues for the time being (Tips I restarted my computer).

andreamah commented 2 weeks ago

If you do the following, what do you get?

  1. Run Developer: Set Log Level in the command palette and set Debug.
  2. Do a search.
  3. In the bottom panel, check logs in the Extension Host channel in the Outputs tab.

Is there a line that starts sort of like this?

RipgrepSearchEH#search c:\Users\andreamah\AppData\Local\Programs\Microsoft VS Code\resources\app\node_modules.asar.unpacked\@vscode\ripgrep\bin\rg.exe 

Then, if you invoke rg.exe directly from the command line, what type of performance do you get?

urbinacity commented 1 week ago

I found the same issue when searching to multiple big files, I found an alternative solution by setting the numbers of threads:

Number of threads to use for searching. When set to 0, the engine automatically determines this value.

or you can also exclude certain folders from the search

"search.ripgrep.maxThreads": 1,
"search.exclude": {
    "**/datadir": true
}
ShaunaGordon commented 4 days ago

Is this a recent regression? Does this happen with all extensions disabled?

I don't think it's a recent regression. There are issues with the same symptoms dating back as far as 2020, and maybe even 2019.

Here is a small sampling of issues reported with these symptoms, if you search for rg, you'll get 20 pages of results, with probably close to half being these symptoms:

213511 Makes the number of ripgrep threads configurable, but doesn't seem to limit them by default for some unknown reason (as can be seen by the verification steps), and therefore doesn't fix the underlying issue that people keep running into.

The VSCode team keeps closing many if not most of them, saying it's either an upstream issue, or an extension issue, yet people keep tripping over it.

From what I can tell, setting the max threads to something other than 0 effectively eliminates this issue. That limit can be fairly high, from the looks of it, but the current default, for some reason, allows ripgrep to spin out of control. Is this a ripgrep issue? Maybe, though as I recall from a previous investigation I did into this, running ripgrep directly from the command line doesn't have the same issue, so maybe it's something in the way VSCode interfaces with it. Even if it is a ripgrep issue, VSCode users would benefit from a sane default that doesn't so easily send rg spiraling out of control.

andreamah commented 2 days ago

It's tough to estimate how many threads the user wants to use. Some people won't mind the large spike in CPU usage as long as they get their results faster. However, others want to keep their CPU usage low so that they can multitask (even if they get their results slower). Some might even never see the effects of a large number of threads being used. That's why there is a custom setting for ripgrep threads.