Skip to content

PSScriptAnalyzer is consuming one core #1739

Closed
@dronkoff

Description

@dronkoff

Issue Type: Performance Issue

Take a big (more than 1500 lines) PowerShell 5.1 script,
Change something,
A PowerShell.exe process will start consuming CPU. It can consume 25% (1 out if 4 cores) for minutes.
I took couple of dumps and traces and everything points to the Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.AvoidAlias+d__7.MoveNext() method.

Disabling PSAvoidUsingCmdletAliases rule makes things a bit better. PowerShell.exe starts after saving the script, doing something but calms down much faster.

Extension version: 1.11.0
VS Code version: Code 1.30.2 (61122f88f0bf01e2ac16bdb9e1bc4571755f5bd8, 2019-01-07T22:54:13.295Z)
OS version: Windows_NT x64 10.0.17763

System Info
Item Value
CPUs Intel(R) Core(TM) i7-6600U CPU @ 2.60GHz (4 x 2808)
GPU Status 2d_canvas: enabled
checker_imaging: disabled_off
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
rasterization: enabled
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
Memory (System) 15.83GB (4.33GB free)
Process Argv
Screen Reader no
VM 0%
Process Info
CPU %	Mem MB	   PID	Process
    1	    77	 19400	code main
    0	    66	 10716	   shared-process
    0	   163	 18284	   window (EGPO_Config_Inventory.ps1 - Visual Studio Code)
    0	    54	 13752	     extensionHost
    0	    12	 16708	     electron-crash-reporter
    0	     5	 18304	     winpty-process
    0	     8	 11932	       console-window-host (Windows internal process)
   22	   161	 20124	       C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass -Command "& 'C:\Users\vdronov\.vscode\extensions\ms-vscode.powershell-1.11.0\modules\PowerShellEditorServices\Start-EditorServices.ps1' -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '1.11.0' -AdditionalModules @('PowerShellEditorServices.VSCode') -BundledModulesPath 'C:\Users\vdronov\.vscode\extensions\ms-vscode.powershell-1.11.0\modules' -EnableConsoleRepl -LogLevel 'Normal' -LogPath 'C:\Users\vdronov\.vscode\extensions\ms-vscode.powershell-1.11.0\logs\1548769107-e5d0206d-d579-4e28-92f6-723cac8ef1511548769100719\EditorServices.log' -SessionDetailsPath 'C:\Users\vdronov\.vscode\extensions\ms-vscode.powershell-1.11.0\sessions\PSES-VSCode-19400-497548' -FeatureFlags @()"
    3	    63	 19500	   window (Issue Reporter)
    0	   226	 19668	   window (EGPO_Config_Inventory.ps1 - Scripts - Visual Studio Code)
    0	    95	  2980	     extensionHost
    0	     3	 18100	       cmd /s /c "C:\Users\vdronov\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\OmniSharp.exe -s c:\SRC\SBRF\Scripts\CMScheduleConverter\ExcelToLocalDb\ExcelToLocalDb.sln --hostPID 2980 --stdio DotNet:enablePackageRestore=false --encoding utf-8 --loglevel information --plugin C:\Users\vdronov\.vscode\extensions\ms-vscode.csharp-1.17.1\.razor\OmniSharpPlugin\Microsoft.AspNetCore.Razor.OmniSharpPlugin.dll formattingOptions:useTabs=false formattingOptions:tabSize=4 formattingOptions:indentationSize=4"
    0	    65	 17488	         C:\Users\vdronov\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\OmniSharp.exe  -s c:\SRC\SBRF\Scripts\CMScheduleConverter\ExcelToLocalDb\ExcelToLocalDb.sln --hostPID 2980 --stdio DotNet:enablePackageRestore=false --encoding utf-8 --loglevel information --plugin C:\Users\vdronov\.vscode\extensions\ms-vscode.csharp-1.17.1\.razor\OmniSharpPlugin\Microsoft.AspNetCore.Razor.OmniSharpPlugin.dll formattingOptions:useTabs=false formattingOptions:tabSize=4 formattingOptions:indentationSize=4
    0	     6	 17520	         console-window-host (Windows internal process)
    0	    26	 19672	       C:\Users\vdronov\.vscode\extensions\ms-vscode.csharp-1.17.1\.razor\rzls.exe -lsp --logLevel None
    0	     5	 19292	         console-window-host (Windows internal process)
    0	    35	  3632	     searchService
    0	    13	 19724	     watcherService 
    0	     5	 17236	       console-window-host (Windows internal process)
    0	     6	 20084	     winpty-process
    0	     8	  6292	       console-window-host (Windows internal process)
   21	   419	 19108	       C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass -Command "& 'C:\Users\vdronov\.vscode\extensions\ms-vscode.powershell-1.11.0\modules\PowerShellEditorServices\Start-EditorServices.ps1' -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '1.11.0' -AdditionalModules @('PowerShellEditorServices.VSCode') -BundledModulesPath 'C:\Users\vdronov\.vscode\extensions\ms-vscode.powershell-1.11.0\modules' -EnableConsoleRepl -LogLevel 'Normal' -LogPath 'C:\Users\vdronov\.vscode\extensions\ms-vscode.powershell-1.11.0\logs\1548769190-555c02bb-a6aa-4962-a3b9-93bc1e15a5ef1548769183730\EditorServices.log' -SessionDetailsPath 'C:\Users\vdronov\.vscode\extensions\ms-vscode.powershell-1.11.0\sessions\PSES-VSCode-19400-527039' -FeatureFlags @()"
    2	   247	 20448	   gpu-process
Workspace Info
|  Window (EGPO_Config_Inventory.ps1 - Scripts - Visual Studio Code)
|    Folder (Scripts): 371 files
|      File types: exe(136) ini(30) ps1(27) msi(19) vbs(18) cmd(16) txt(14)
|                  dll(13) xml(13) log(10)
|      Conf files: sln(1) csproj(1);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions