Startup performance PowerShell 7.2.0-Preview.1
See original GitHub issueHere PerfView trace https://ru.files.fm/u/n2hqqsr7z
- ~GetFileAttributesExW() reported to .Net Runtime. I hope they can reduce these operations https://github.com/dotnet/runtime/issues/44545~ The referenced .NET issue was addressed.
- PR #14411 newtonsoft.json It read powershell.config.json Expected perf win 50-100 ms.
- There is an idea to use defaults and exclude the file at all in release version. (We still need the file for preview versions for experimental features turn on/off.)
- We should migrate to .Net System.Text.Json API. It is expected being faster.
- ~CreateManifestAndDescriptors() I don’t know if it’s possible to remove this delay. Tracking issue https://github.com/dotnet/runtime/issues/45466~ This only appears when collecting ETW traces. See https://github.com/PowerShell/PowerShell/issues/14268#issuecomment-739464805
- ~PR #14320. SemanticVersion.op_Implicit There is dead code that we need to remove because we haven’t received any feedback that it is needed. Expected perf win about 50 ms.~ PR closed because it’s not dead code.
- ~microsoft.applicationinsights Perhaps we could lazy the initialization. PR #14281 - perf win from 30 to 100 ms.~
- PR #14283. InitialSessionState…cctor() See GetAppLockerPolicy() method. Perf win ~10-30 ms
- ~Creation of explorer menu should be moved to right place (from line 184 to line 220) - it makes no sense to run the code in server mode - and be probably runned in background.~ Answered in https://github.com/PowerShell/PowerShell/issues/14268#issuecomment-740353164
- Use
StringComparison.Ordinal
insted ofStringComparison.CurrentCulture
instring.StartsWith()
inConsoleHost.Start()
. It is slow ICU initialization. PR #14298 - perf win ~5 ms. - We use
string.ToLowerInvariant()
inCommandLineParser.GetSwitchKey()
. It is slow ICU initialization - 26 ms! Reported to https://github.com/dotnet/runtime/issues/40942#issuecomment-735383698 - PR #14298. Use
StringComparison.Ordinal
instead ofStringComparison.CurrentCulture
at startup time. It removes early Culture initialization. - PR #14303. Use
OrdinalIgnoreCase
inCommandLineParser
. It removes early Culture initialization. - PR #14323. Exclude
string.ToLowerInvariant()
inGetEnvironmentVariableAsBool()
. It is slow ICU initialization. - Exclude loading
System.Diagnostics.FileVersionInfo.dll
on Windows inAmsiUtils.Init()
. https://github.com/PowerShell/PowerShell/pull/14332#issuecomment-739549844 - ~Review how we use (1) Jit paramteters, (2) crossgen.exe for same assemblies (Build.psm1) - it seems no effect on startup scenario~ Use .NET crossgen properties in
.csproj
files. All shipped assemblies are R2R images now. - Benefit from modern CrossGen2 and dotnet-pgo https://github.com/dotnet/runtime/tree/master/src/coreclr/tools/dotnet-pgo
Environment data
Name Value
---- -----
PSVersion 7.2.0-preview.1
PSEdition Core
GitCommitId 7.2.0-preview.1-62-g15e4e8a6af2f120bbd1eef8607131d878677c0ad
OS Microsoft Windows 10.0.18363
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Issue Analytics
- State:
- Created 3 years ago
- Reactions:12
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Optimizing your $Profile - PowerShell Team
Optimizing your $Profile. Your PowerShell Profile allows you to customize your PowerShell session and runs at startup.
Read more >PowerShell 7.2.X Almost Always Hangs When Launched
Summary: The vast majority of the time, launching pwsh.exe v7.2.X doesn't work under any conditions I've tried.
Read more >PowerShell 7.2.0 Preview 3, v7.1.2 and v7.0.5 are ...
Performance : Get PowerShell version in PSVersionInfo using assembly attribute instead of FileVersionInfo . ✓ Fix: Get-Date -UFormat %u ...
Read more >skip powershell startup check for new version
I'm having the issue with 7.2.6 on a server with no Internet connection even after adding the UPDATE and OPTOUT system environment variables: ......
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 >
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
Question from https://github.com/PowerShell/PowerShell/issues/6443:
Thank you in advance.
Regarding point 7: Feel free to move the code to a more appropriate place but just to let you know that inside it, it creates a non-blocking thread so it should incur hardly any cost, there is also low level code making the procedure a no-op in the case of non-interactive shell