Bad performance feedback loop with slow PSScriptAnalyzer rules
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 45/100
- Tipo de issue
- Bug
- Clareza
- Razoavelmente clara
- Status de atividade
- Estagnada
- Stack de tecnologia
- csharp, powershell
- Domínio
- performance, tooling
Direção de pesquisa
Comece pelo caminho de agendamento da análise de scripts em torno de Invoke-ScriptAnalyzer e do pssaRunspacePool de concorrência única descrito na issue. Reproduza as quatro edições atrasadas com uma regra personalizada que leve cerca de cinco segundos e, em seguida, acompanhe como as varreduras pendentes são colocadas na fila. Está concluído quando alterações mais recentes no documento têm prioridade sobre varreduras que ainda não começaram e os resultados convergem para o documento atual sem retornar todas as versões intermediárias.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Prerequisites
- I have written a descriptive issue title.
- I have searched all open and closed issues to ensure it has not already been reported.
- I have read the troubleshooting guide.
- I am sure this issue is with PowerShell Editor Services itself and does not reproduce in a standalone PowerShell instance, and is not an issue with my editor.
- I have verified that I am using the latest version of PowerShell Editor Services.
- If this is a security issue, I have read the security issue reporting guidance.
Summary
I'm running into a script analysis performance issue in my environment. We have a decent number of custom PSScriptAnalyzer rules that can take more than several seconds to complete with larger scripts.
As you're typing in a PowerShell document, the responsiveness of script analysis deteriorates to the point were you have to wait many times more than the usual run duration of the rules to see most up-to-date analysis results.
This is happening because every time you stop typing for >750ms PSES fires off another multi-second Invoke-ScriptAnalyzer run into the pssaRunspacePool (which has a concurrency of 1). So with a lot of furious typing, script analysis service can end up with tens of seconds of work just to catch-up to the document contents that are on the screen at the moment.
I've come up with a fix that boils down to holding off Invoke()'ing a new scan until the currently running one completes. That gives a chance for any more incoming document changes to pre-empt ones that have not started scanning yet. As a result, the scanning results delay is more or less stable and not worse than the runtime of all of the rules.
I need to do more testing of the fix, but was wondering if anyone else has run into this? Maybe there would be a better way to fix it? Planning to submit a PR for this at some point.
PowerShell Version
ame Value
---- -----
PSVersion 7.4.11
PSEdition Core
GitCommitId 7.4.11
OS Microsoft Windows 10.0.22631
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Editor Version
VSCode
------
Version: 1.104.3 (system setup)
Commit: 385651c938df8a906869babee516bffd0ddb9829
Date: 2025-10-02T12:30:51.747Z
Electron: 37.3.1
ElectronBuildId: 12404162
Chromium: 138.0.7204.235
Node.js: 22.18.0
V8: 13.8.258.31-electron.0
OS: Windows_NT x64 10.0.22631
PowerShell Editor Services Version
Major Minor Build Revision
----- ----- ----- --------
4 3 0 0
Steps to Reproduce
- Create a custom PSScriptAnalyzer rule that takes 5s to run (easier to reproduce the issue with longer delays).
- Type, wait 1 second, type, wait 1 second, type, wait 1 second, type.
- Observe that after stopping typing script analysis will continue running for the next ~15s and will return all of the intermediate results as you were typing. As an interactive user I only care about analysing the document that is on the screen now.
Visuals
No response
Logs
No response
- Linguagem predominante
- C#
- Estrelas
- 767
- Forks
- 266
- Merge médio
- 3d 16h
- PRs com merge (30d)
- 1
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de PowerShell/PowerShellEditorServices
-
[Bug] None of the string overloads of `EditorExtensionServiceProvider.GetService()` work on .NET. Aberta
PowerShell/PowerShellEditorServices#2331 · 1 reação · 2 responsáveis ·
-
Area-Language Server Issue-Enhancement
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 48/100
PowerShell/PowerShellEditorServices#2315 · 1 comentário ·
-
Area-Debugging Issue-Enhancement
PowerShell/PowerShellEditorServices#2294 · 1 reação · 2 responsáveis ·
-
Issue-Bug Needs: Triage
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 48/100
PowerShell/PowerShellEditorServices#2293 · 1 comentário ·
-
PowerShell/PowerShellEditorServices#2282 · 1 comentário · 1 reação · 2 responsáveis ·
Todas as issues de PowerShell/PowerShellEditorServices
Issues semelhantes
-
effort:S P3 refactor
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
nightscout/nocturne#1532 ·
-
core dependencies
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 80/100
-
documentation
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
-
C#/.NET Roslyn LSP Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
-
Suspicious code fragments Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
DotNetNext/SqlSugar#1458 ·