Powershell initialization on linux is slow
See original GitHub issueSteps to reproduce
Launch powershell
Expected behavior
Usable prompt in milliseconds
Actual behavior
Usable prompt in seconds
Environment data
PS /> $PSVersionTable
Name Value
---- -----
PSVersion 6.0.0-alpha
PSEdition Core
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 3.0.0.0
GitCommitId v6.0.0-alpha.9
CLRVersion
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
For example:
[me@ipsum] ~
➜ cat test.ps1
#!/usr/bin/powershell
exit
[me@ipsum] ~
➜ time ./test.ps1
./test.ps1 1.30s user 0.12s system 138% cpu 1.035 total
Compared to:
[me@ipsum] ~
➜ cat test.sh
#/bin/bash
exit
[me@ipsum] ~
➜ time ./test.sh
./test.sh 0.00s user 0.00s system 0% cpu 0.002 total
The windows host I have available:
PS C:\Users\me> echo "exit" > test.ps1
PS C:\Users\me> Measure-Command {.\test.ps1}
Days : 0
Hours : 0
Minutes : 0
Seconds : 0
Milliseconds : 7
Ticks : 71141
TotalDays : 8.23391203703704E-08
TotalHours : 1.97613888888889E-06
TotalMinutes : 0.000118568333333333
TotalSeconds : 0.0071141
TotalMilliseconds : 7.1141
PS C:\Users\me> $PSVersionTable
Name Value
---- -----
PSVersion 3.0
WSManStackVersion 3.0
SerializationVersion 1.1.0.1
CLRVersion 4.0.30319.18033
BuildVersion 6.2.9200.16434
PSCompatibleVersions {1.0, 2.0, 3.0}
PSRemotingProtocolVersion 2.2
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:5 (4 by maintainers)
Top Results From Across the Web
[SOLVED] powershell extremely slow to load
Hello,. I am running powershell-bin from AUR, the current version 7.3.1. I find that it is extremely slow to launch the interactive shell ......
Read more >PowerShell steps to fix slow startup
When PowerShell starts to become slow at startup, an update of the .NET framework might be the cause. To speed up again, use...
Read more >Remote power shell very slow from Linux to Windows
Remote power shell very slow from Linux to Windows ... I'm running Ubuntu 20 and PowerShell 7.1, Apt upgrade comes up empty.
Read more >Optimizing your $Profile - PowerShell Team
Your PowerShell Profile allows you to customize your PowerShell session and runs at startup. Complex profiles can cause a significant delay ...
Read more >Calling powershell.exe is extremely slow
Try using ngen.exe (Native Image Generator) to precompile the assemblies that Powershell loads during startup.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
At least some of the perf issue will be addressed by #1846.
Note that your example on Windows:
does not accurately measure the startup costs of PowerShell because PowerShell has already started. It would be more accurate to use:
I did a ton of work in Windows PowerShell v5.1 on startup, and this scenario would run in the 200-300ms range, still a lot slower than I’d like, but a vast improvement over Windows PowerShell 5.0 which was closer to 900ms.
I just downloaded Beta2 AppImage and on my system the
user
times went down from 1.6s to 1.0s- huge improvements.Keep going!
PS: I’m confused by how linux time command works, I’d have thought user/sys times would be times spent in respective spaces and real would be a sum of the two.