-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Some more changes and cleanup to reduce the startup time #8396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…implify 'HelperSecurity.psm1'
…IoT' at startup time
…riptBlockInFactASafeHashtable' runs
9f718e0 to
d32458e
Compare
Currently runtime has |
PaulHigin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@iSazonov I don't think |
PR Summary
This PR includes some changes and cleanups that will reduce the startup time. Each commit is self-contained, and the commit message serves as a summary of the changes in the commit.
s_wasSystemPolicyDebugPolicytos_allowDebugOverridePolicyto make it less confusing. Also slightly refactorHelperSecurity.psm1andConstrainedLanguageDebugger.Tests.ps1to remove unneeded code. There is no functional change in this commit.IsInbox, as PowerShell Core won't be shipped in-box with Windows in the foreseeable feature. Even if we do in future, we won't be needing it because Windows PowerShell will probably be gone by that time.$env:PSModulePath, and it will in turn causeIsNanoServerandIsIoTto be evaluated, all of which will trigger access to the Registry. By removingIsInbox, that can be all avoided.BindRunspaceretrieves all available commands from the session state, but for the most common scenario of creating/opening a Runspace, the retrieved commands are never get used afterwards. The method is updated to avoid retrieving all commands unless it's necessary.ProcessXXXmethod, so that we can avoid some unneeded method calls.IsSafeValueVisitorevery time whenIsScriptBlockInFactASafeHashtableruns.IsSafeValueVisitor.IsAstSafecreates an instance ofIsSafeValueVisitorevery time it runs. Given thatIsScriptBlockInFactASafeHashtablegets called relatively frequently inPerformSecurityCheck, this will result in some GC pressure as it will generate transient objects. This is updated to reuse aIsSafeValueVisitorsingleton with the defaultSafeValueContext.Defaultand_safeValueContextfields are madereadonly, so it cannot be changed by reflection._visitCountis changed touinttype, so an attacker cannot change the value of it to a negative number in order to practically increase the max visit count limit.PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:to the beginning of the title and remove the prefix when the PR is ready.[feature]if the change is significant or affects feature tests