Bad performance feedback loop with slow PSScriptAnalyzer rules
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 45/100
- Issue 類型
- 缺陷
- 描述清晰度
- 基本清楚
- 活躍度
- 停滯
- 技術堆疊
- csharp, powershell
- 領域
- performance, tooling
研究方向
從 Invoke-ScriptAnalyzer 周圍的腳本分析排程路徑,以及 issue 中描述的單一並行 pssaRunspacePool 開始。使用一個約需五秒的自訂規則重現四次延遲編輯,然後追蹤擱置中的掃描如何排入佇列。當較新的文件變更能夠搶先處理尚未開始的掃描,且結果在不回傳每個中間版本的情況下收斂到目前的文件時,即表示完成。
由索引模型根據 Issue 內容生成。
描述
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
- 主要語言
- C#
- 星號
- 772
- 分支
- 268
- 平均合併
- 3 天 16 小時
- 30 天內合併 PR
- 1
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
PowerShell/PowerShellEditorServices 的其他 Issue
-
[Bug] None of the string overloads of `EditorExtensionServiceProvider.GetService()` work on .NET.可能重新可做 @andyleejordan 於 102 天前認領,目前沒有進行中的 PR。 未關閉
PowerShell/PowerShellEditorServices#2331 · 1 個 reaction · 已指派 2 人 ·
-
Area-Language Server Issue-Enhancement
難度 4/5 3-5 天 新手友好度 48/100
PowerShell/PowerShellEditorServices#2315 · 1 則留言 ·
-
Improve Constrained Runspace Debug Experience可能已有人在做 @JustinGrote 於 125 天前認領。 未關閉Area-Debugging Issue-Enhancement
PowerShell/PowerShellEditorServices#2294 · 1 個 reaction · 已指派 2 人 ·
-
Issue-Bug Needs: Triage
難度 4/5 3-5 天 新手友好度 48/100
PowerShell/PowerShellEditorServices#2293 · 1 則留言 ·
-
Document outline drops child variables when a function/filter reuses a variable name declared earlier (scope-blind declaration dedup)可能已有人在做 @JustinGrote 於 153 天前認領。 未關閉
PowerShell/PowerShellEditorServices#2282 · 1 則留言 · 1 個 reaction · 已指派 2 人 ·
查看 PowerShell/PowerShellEditorServices 的全部 Issue
相似的 Issue
-
bug
難度 2/5 1-3 小時 新手友好度 80/100
維護者通常 1 天內回覆
-
:watch: Not Triaged aspnet-core/svc fundamentals/subsvc Source - Docs.ms
難度 1/5 1 小時以內 新手友好度 85/100
dotnet/AspNetCore.Docs#37785 ·
維護者通常 1 天內回覆
-
needs-triage
難度 2/5 1-3 小時 新手友好度 70/100
維護者通常 1 天內回覆
-
needs-triage
難度 2/5 1-3 小時 新手友好度 66/100
Azure/azure-sdk-tools#17204 ·
維護者通常 1 天內回覆
-
area-tutorials needs-triage
難度 2/5 1-3 小時 新手友好度 75/100
dotnet/website-feedback#1779 ·