| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
Hi Staffan Gustafsson (@powercode), I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution! The agreement was validated by Microsoft and real humans are currently evaluating your PR. TTYL, MSBOT; |
Sorry, something went wrong.
There was a problem hiding this comment.
Seems this should be in #if !UNIX
Sorry, something went wrong.
There was a problem hiding this comment.
Yes, you are correct. Fixing.
Sorry, something went wrong.
There was a problem hiding this comment.
Fixed
Sorry, something went wrong.
There was a problem hiding this comment.
PG do not accept formatting without code changes. It would be good to revert this.
Sorry, something went wrong.
There was a problem hiding this comment.
Unneeded empty line.
Sorry, something went wrong.
There was a problem hiding this comment.
It would be good to mention here about main - use caching dramatically accelerated GetParentProcess.
Sorry, something went wrong.
|
Staffan Gustafsson (@powercode) - it looks like these changes cause the test failures. Lee Holmes (@LeeHolmes) - can you review these changes? |
Sorry, something went wrong.
|
It is my bad. Fixing now. |
Sorry, something went wrong.
There was a problem hiding this comment.
s_currentProcessId never changes. It seems unnecessary.
Sorry, something went wrong.
There was a problem hiding this comment.
Good point. Refactoring...
Sorry, something went wrong.
There was a problem hiding this comment.
It is there to avoid creating a new process object every time the id of the current process is needed
Sorry, something went wrong.
There was a problem hiding this comment.
Agree!
Sorry, something went wrong.
There was a problem hiding this comment.
I maybe stupid here but why you check s_currentProcessId instead of s_currentParentProcessId.HasValue?
Sorry, something went wrong.
There was a problem hiding this comment.
Clear - "current" != "current" 😊
Sorry, something went wrong.
There was a problem hiding this comment.
This conditional is the opposite of what I think you intended.
Sorry, something went wrong.
There was a problem hiding this comment.
Yes, fixed in the updated pull request
Sorry, something went wrong.
There was a problem hiding this comment.
Our coding style puts a newline above comment blocks, as it represents a paragraph of thought.
Sorry, something went wrong.
There was a problem hiding this comment.
Fixed
Sorry, something went wrong.
|
Fixing |
Sorry, something went wrong.
There was a problem hiding this comment.
This would be an error condition (taking a snapshot with no processes), so returning 'parentPid' is misleading. Instead, we should return 0.
Sorry, something went wrong.
There was a problem hiding this comment.
Good point. Fixed.
Sorry, something went wrong.
There was a problem hiding this comment.
This is very close to being a duplication of GetParentProcess(). I think it'd be OK to add the caching logic to GetParentProcessIdNative. Also, it doesn't have the start time validation that GetParentProcess has, so we should make sure we don't expose anything that looks like a useful helper function without this validation.
Sorry, something went wrong.
|
Pushed new version with |
Sorry, something went wrong.
|
Staffan Gustafsson (@powercode) Can you please rebase this PR to the latest from master and push an update? It looks like it is ready to merge and just needs final code review sign off. Lee Holmes (@LeeHolmes) - Please take another look at this PR and provide feedback as appropriate. |
Sorry, something went wrong.
There was a problem hiding this comment.
I looked through the code changes and comments. I agree with Lee's comments but I notice that two have not yet been addressed:
Sorry, something went wrong.
In certain scenarios, like a domain joined machine with an executionpolicy set via GPO, a lot of checks are done for the ExecutionPolicy, and this is in the hot path.
It is expensive to determine if a script was run as a result of applying a group policy. This does not change during the lifetime of a process. This only affect the scenario when an execution policy has been set by a group policy.
|
Paul Higinbotham (@PaulHigin) We now have an implementation of GetParentPid available. Using it instead, and inlining the caching as suggested. |
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM
Sorry, something went wrong.
…n effect for ExecutionPolicy (PowerShell#2588) * Caching the parent id of the current process In certain scenarios, like a domain joined machine with an executionpolicy set via GPO, a lot of checks are done for the ExecutionPolicy, and this is in the hot path. * Caching HasGPScriptParent. It is expensive to determine if a script was run as a result of applying a group policy. This does not change during the lifetime of a process. This only affect the scenario when an execution policy has been set by a group policy. * Using available Microsoft.PowerShell.ProcessCodeMethods.GetParentPid
| Back | FazBrowse Home | New Git URL |
Fixes #2578
When group policies are in effect for execution policy, a check is made to determine if the current process has been launched by gpscript.exe, and in that case, ignore the execution policy.
This is expensive to determine, is done over and over again, and has resulted in very long load times for scripts and modules.
One of the things that is checked (in an expensive way) is the parent id of the current process. That never changes, and is now cached.
The other change is to check once if we are launched by gpscript.exe or not and save that value.
This results in speedups in the order of a magnitude for module loads.