GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Improve powershell startup time by daxian-dbw · Pull Request #8341 · PowerShell/PowerShell Conversation
|
| Windows PowerShell Assembly Name | JitTime msec | Num Compilations | IL Size | Native Size | Foreground msec | Multicore JIT Background msec | Tiered Compilation Background msec |
|---|---|---|---|---|---|---|---|
| TOTAL | 24.7 | 83 | 1,506 | 16,149 | 24.7 | 0.0 | 0.0 |
| Anonymously Hosted DynamicMethods Assembly | 19.3 | 44 | 0 | 12,517 | 19.3 | 0.0 | 0.0 |
| C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL...\System.Management.Automation.dll | 4.3 | 38 | 1,181 | 2,782 | 4.3 | 0.0 | 0.0 |
| C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL...\System.Core.dll | 1.1 | 1 | 325 | 850 | 1.1 | 0.0 | 0.0 |
Microsoft.ApplicationInsights.dll and applying tiered compilation| PWSH Assembly Name | JitTime msec | Num Compilations | IL Size | Native Size | Foreground msec | Multicore JIT Background msec | Tiered Compilation Background msec |
|---|---|---|---|---|---|---|---|
| TOTAL | 191.6 | 488 | 43,105 | 140,540 | 151.2 | 40.4 | 0.0 |
| E:\PowerShell\bin\latest\Microsoft.ApplicationInsights.dll | 51.6 | 147 | 9,866 | 30,735 | 51.6 | 0.0 | 0.0 |
| E:\PowerShell\bin\latest\System.Management.Automation.dll | 44.4 | 25 | 14,661 | 44,123 | 4.0 | 40.4 | 0.0 |
| E:\PowerShell\bin\latest\System.Private.CoreLib.dll | 36.0 | 143 | 11,947 | 20,691 | 36.0 | 0.0 | 0.0 |
| E:\PowerShell\bin\latest\Microsoft.PowerShell.CoreCLR.Eventing.dll | 22.1 | 80 | 0 | 23,342 | 22.1 | 0.0 | 0.0 |
| E:\PowerShell\bin\latest\System.Collections.Concurrent.dll | 17.6 | 34 | 4,018 | 12,261 | 17.6 | 0.0 | 0.0 |
| E:\PowerShell\bin\latest\System.Collections.dll | 9.3 | 34 | 1,317 | 3,542 | 9.3 | 0.0 | 0.0 |
| E:\PowerShell\bin\latest\System.Linq.dll | 7.6 | 17 | 1,085 | 4,911 | 7.6 | 0.0 | 0.0 |
| Anonymously Hosted DynamicMethods Assembly | 1.4 | 6 | 0 | 543 | 1.4 | 0.0 | 0.0 |
| E:\PowerShell\bin\latest\Newtonsoft.Json.dll | 0.8 | 1 | 196 | 357 | 0.8 | 0.0 | 0.0 |
| E:\PowerShell\bin\latest\pwsh.dll | 0.7 | 1 | 15 | 35 | 0.7 | 0.0 | 0.0 |
Microsoft.ApplicationInsights.dll and applying tiered compilation| Updated PWSH Assembly Name | JitTime msec | Num Compilations | IL Size | Native Size | Foreground msec | Multicore JIT Background msec | Tiered Compilation Background msec |
|---|---|---|---|---|---|---|---|
| TOTAL | 98.9 | 422 | 34,500 | 144,231 | 78.3 | 20.5 | 0.0 |
| E:\PowerShell\bin\base\System.Private.CoreLib.dll | 26.7 | 181 | 12,442 | 36,649 | 26.7 | 0.0 | 0.0 |
| E:\PowerShell\bin\base\System.Management.Automation.dll | 22.7 | 25 | 14,661 | 51,754 | 2.4 | 20.3 | 0.0 |
| E:\PowerShell\bin\base\Microsoft.PowerShell.CoreCLR.Eventing.dll | 22.1 | 80 | 0 | 22,778 | 22.1 | 0.0 | 0.0 |
| E:\PowerShell\bin\base\System.Collections.Concurrent.dll | 9.9 | 53 | 4,429 | 19,337 | 9.6 | 0.3 | 0.0 |
| E:\PowerShell\bin\base\System.Collections.dll | 7.0 | 52 | 1,546 | 6,856 | 7.0 | 0.0 | 0.0 |
| E:\PowerShell\bin\base\System.Linq.dll | 5.3 | 23 | 1,211 | 5,770 | 5.3 | 0.0 | 0.0 |
| Anonymously Hosted DynamicMethods Assembly | 4.1 | 6 | 0 | 543 | 4.1 | 0.0 | 0.0 |
| E:\PowerShell\bin\base\pwsh.dll | 0.7 | 1 | 15 | 51 | 0.7 | 0.0 | 0.0 |
| E:\PowerShell\bin\base\Newtonsoft.Json.dll | 0.3 | 1 | 196 | 493 | 0.3 | 0.0 | 0.0 |
// * Detailed results *
PSStartupTime.Pwsh61: Core(Runtime=Core)
Runtime = .NET Core 2.1.6 (CoreCLR 4.6.27019.06, CoreFX 4.6.27019.05), 64bit RyuJIT; GC = Concurrent Workstation
Mean = 540.5245 ms, StdErr = 2.2226 ms (0.41%); N = 14, StdDev = 8.3163 ms
Min = 528.3226 ms, Q1 = 535.3209 ms, Median = 538.9606 ms, Q3 = 544.9347 ms, Max = 559.4117 ms
IQR = 9.6138 ms, LowerFence = 520.9002 ms, UpperFence = 559.3554 ms
ConfidenceInterval = [531.1432 ms; 549.9058 ms] (CI 99.9%), Margin = 9.3813 ms (1.74% of Mean)
Skewness = 0.66, Kurtosis = 2.66, MValue = 2
-------------------- Histogram --------------------
[525.303 ms ; 539.307 ms) | @@@@@@@
[539.307 ms ; 562.431 ms) | @@@@@@@
---------------------------------------------------
PSStartupTime.WinPS: Core(Runtime=Core)
Runtime = .NET Core 2.1.6 (CoreCLR 4.6.27019.06, CoreFX 4.6.27019.05), 64bit RyuJIT; GC = Concurrent Workstation
Mean = 332.9168 ms, StdErr = 1.8044 ms (0.54%); N = 35, StdDev = 10.6749 ms
Min = 316.7778 ms, Q1 = 323.8313 ms, Median = 330.4381 ms, Q3 = 340.1557 ms, Max = 356.9562 ms
IQR = 16.3244 ms, LowerFence = 299.3447 ms, UpperFence = 364.6423 ms
ConfidenceInterval = [326.4197 ms; 339.4139 ms] (CI 99.9%), Margin = 6.4971 ms (1.95% of Mean)
Skewness = 0.47, Kurtosis = 2.28, MValue = 2.2
-------------------- Histogram --------------------
[313.922 ms ; 324.935 ms) | @@@@@@@@@@
[324.935 ms ; 332.120 ms) | @@@@@@@@@
[332.120 ms ; 341.104 ms) | @@@@@@@@@
[341.104 ms ; 348.303 ms) | @@@
[348.303 ms ; 359.812 ms) | @@@@
---------------------------------------------------
PSStartupTime.pwsh62_optimized: Core(Runtime=Core)
Runtime = .NET Core 2.1.6 (CoreCLR 4.6.27019.06, CoreFX 4.6.27019.05), 64bit RyuJIT; GC = Concurrent Workstation
Mean = 408.2847 ms, StdErr = 2.2256 ms (0.55%); N = 17, StdDev = 9.1764 ms
Min = 387.1787 ms, Q1 = 403.7134 ms, Median = 409.1181 ms, Q3 = 414.1094 ms, Max = 428.8114 ms
IQR = 10.3960 ms, LowerFence = 388.1194 ms, UpperFence = 429.7034 ms
ConfidenceInterval = [399.3489 ms; 417.2204 ms] (CI 99.9%), Margin = 8.9358 ms (2.19% of Mean)
Skewness = -0.18, Kurtosis = 3.46, MValue = 2
-------------------- Histogram --------------------
[384.056 ms ; 395.103 ms) | @
[395.103 ms ; 403.504 ms) | @@@
[403.504 ms ; 418.618 ms) | @@@@@@@@@@@@
[418.618 ms ; 431.934 ms) | @
---------------------------------------------------
// * Summary *
BenchmarkDotNet=v0.11.2, OS=Windows 10.0.17763.134 (1809/October2018Update/Redstone5)
Intel Core i7-6700 CPU 3.40GHz (Skylake), 1 CPU, 8 logical and 4 physical cores
.NET Core SDK=2.1.500
[Host] : .NET Core 2.1.6 (CoreCLR 4.6.27019.06, CoreFX 4.6.27019.05), 64bit RyuJIT
Core : .NET Core 2.1.6 (CoreCLR 4.6.27019.06, CoreFX 4.6.27019.05), 64bit RyuJIT
Job=Core Runtime=Core
Method | Mean | Error | StdDev |
----------------- |---------:|---------:|----------:|
Pwsh61 | 540.5 ms | 9.381 ms | 8.316 ms |
WinPS | 332.9 ms | 6.497 ms | 10.675 ms |
pwsh62_optimized | 408.3 ms | 8.936 ms | 9.176 ms |
// * Hints *
Outliers
PSStartupTime.Pwsh61: Core -> 1 outlier was removed
PSStartupTime.pwsh62_optimized: Core -> 1 outlier was detected
// * Legends *
Mean : Arithmetic mean of all measurements
Error : Half of 99.9% confidence interval
StdDev : Standard deviation of all measurements
1 ms : 1 Millisecond (0.001 sec)
// ***** BenchmarkRunner: End *****
Run time: 00:00:38 (38.84 sec), executed benchmarks: 3
.h, .cpp, .cs, .ps1 and .psm1 files have the correct copyright headerWIP: to the beginning of the title and remove the prefix when the PR is ready.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Do you continue in the PR?
I don't see Microsoft.ApplicationInsights.dll in the table - no jitting? I searched "Insights" in our code base and have questions:
If having
I think that an ordinary user computer is 2 physical cores and it would be correct to limit the test to two physical cores. (This may be related to tied compilation) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I restarted CI-MacOs. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Ilya (@iSazonov) Reply to your comment here:
No, that will be in a new PR. The planned work are as follows:
After the change, no IL code needs to be jitted for this dll at startup time.
Yes we do. Type conversion depends on the type catalog. Not all .NET Core assemblies shipped with PS Core are loaded at startup. Today, user can use a type even it's from an assembly that is not loaded yet, because powershell knows which assembly the type is from by looking in the type catalog. Without it, the user needs to know which assembly the type is in, and then load the assembly first before using the type. The type catalog is also used in tab completion, so that powershell can tab complete types that are not loaded yet.
ApplicationInsight telemetry is done in console.dll at startup, as long as the user hasn't opted out.
The work that is done in this PR are based on the analysis of Reference Set and Jitting time. Some ad-hoc analysis on the static members might be useful, but I think our efforts should be guided by the measurement data, so our time can be spent on things that matters most.
The reason to change
There is no interference from other pwsh processes when running the tests.
The baseline is the same, and here we care most about the percentage of improvement instead of the actual startup time. As for multi-core background jitting, with changes in this PR, only |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
The macOS failure appears to be a test code issue: (note that |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
For the logging test that was failing in previous macOS CI, it's caused by removing |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
But the dll is loaded at startup. Only "Type conversion depends on the type catalog" prevents us from removing the dll from TypeCatalog?
I understand. My request is - Does the telemetry delay startup or no? If yes we could postpone the telemetry call and loading the dll.
I think these outlies is important to investigate in the startup context. Outlier is unexpected delay. Why we see unexpected delay in the tests? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Not sure what you mean by "But the dll is loaded at startup". Most of the assemblies included in the type catalog file are not loaded at startup. Even for the dlls that are loaded at startup, type resolution would be much faster for a type from those dlls because we can avoid the effort to search types from all loaded assemblies to find the one.
The telemetry definitely play a role in the startup time, but I don't know how much after crossgen'ing the dll because I'm not able to analyze the stack info in PerfView/WPA with crossgen'ed assemblies yet.
Every run of the test starts those processes many times for measurement, including the warm-up. Not every test has outliers in it. I think it's more related to the factors that is out of our control, such as the OS. BTW, I replaced the detailed test record with a most recent run (after |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Jason Shirk (@lzybkr) Paul Higinbotham (@PaulHigin) Travis Plunk (@TravisEz13) Can you please look at the new changes to Major change is on how we decide to skip AMSI/malicious code scan. The previous way to check for skipping An attacker can put arbitrary content in a The skip-scan condition is changed to:
The API |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
We have many comments in the PR that is a problem for GitHub web interface. If security concerns have been fixed we could merge and continue with hash function in follow PR. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LTGM. Just minor comments.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Major change is about how we decide to skip AMSI/malicious code scan. A script block may comes from a .psd1 file but still has arbitrary code in it. An attacker can parse an .psd1 file to get an Ast and call Ast.GetScriptBlock() to create a script block. That script block comes from a .psd1 file that may contain arbitrary content. The skip-scan condition is changed to: - the script block should come from a .psd1 file - the script block is essentially a HashtableAst - the HashtableAst is safe.
202535c to
51733c4
Compare
|
Attempt to address comments + rebased to resolve the conflict in |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
The failed test is most likely caused by #8346. It's a feature-level test, but the commits in that PR don't have the Here is the failure: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Did we lose a bit of performance with latest commits? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Yeah, it looks so to me. The average startup time improvement compared with PS Core 6.1 drops to It's the price for security, I guess :/ But I think we can possibly further improve it by having an internal overload of |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Can you elaborate a bit on the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Dongbo Wang (@daxian-dbw) See here for the discussion on that: #8120 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I want to use Convertfrom-sddlstring in c# ? what is the equivalent method in c# and what library? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Major changes are as follows: - Avoid `SecuritySupport.IsProductBinary` and unnecessary AMSI/suspicious code scan at startup time - Update `CompiledScriptBlockData.IsProductCode` to avoid unnecessary calls to `IsProductBinary`, which attempts to retrieve catalog signature of the target file. - Update `PerformSecurityChecks` to skip AMSI and suspicious code scan for the `.psd1` file that contains a safe `HashtableAst` only. - Use customized `ReadOnlyBag` instead of `ImmutableHashSet` so that we can avoid loading the `System.Collections.Immutable.dll` completely. - Replace `SHA1` with `CRC32` when generating module analysis cache file name - This remove the loading of `System.Security.Cryptography.Algorithms.dll` at startup - Move `ConvertFrom-SddlString` to C# to remove the `Utility.psm1` file. - Crossgen `Microsoft.ApplicationInsights.dll` and enable tiered compilation - Even pwsh with crossgen assemblies spends a lot time in jitting at the startup, about `191.6ms` comparing with `24.7ms` for Windows PowerShell. - Jitting `Microsoft.ApplicationInsights.dll` takes about `51.6ms`. - By crossgen `Microsoft.ApplicationInsights.dll` and enable tiered compilation, the jitting time drops to about `98.9ms`.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.