-
Notifications
You must be signed in to change notification settings - Fork 125
Description
Description
npm run lint:ps takes approximately 35 minutes to complete in WSL2 environments, making local development iteration impractical. The expected runtime for 52 PowerShell files is under 1 minute.
Root Causes
1. Recursive file discovery via Get-ChildItem
Get-FilesRecursive in LintingHelpers.psm1 uses Get-ChildItem -Recurse to find PowerShell files. This traverses the entire filesystem tree (12,040+ items including node_modules/, .git/, and other irrelevant directories) to locate 52 PowerShell files. The gitignore filtering happens after enumeration, so the full traversal cost is always paid.
2. WSL2 PATH containing Windows mount points
WSL2 environments typically have 30+ /mnt/* entries in $env:PATH (Windows system directories shared via Plan 9/9P protocol over Hyper-V AF_VSOCK sockets). PSScriptAnalyzer/.NET resolves commands by scanning every PATH directory for each file analyzed. Each /mnt/* lookup triggers a cross-filesystem openat syscall through the 9P protocol, adding ~0.5-1 second per file analyzed.
Combined, these cause ~5,600 slow cross-filesystem syscalls per linting run, confirmed via strace.
Fix
PR #667 addresses both root causes:
Get-FilesRecursive: Usesgit ls-files --cached --others --exclude-standard(scoped to the$Pathparameter) with fallback toGet-ChildItem -Recursefor non-git contextsInvoke-PSScriptAnalyzer.ps1: Strips/mnt/*entries from PATH before running analysis (guarded by the direct-invocation check so it does not affect dot-sourced test imports)
Validation
After fix: 52 files analyzed, 0 issues, ~40 seconds (down from ~35 minutes).