X Tutup
Skip to content

Minor performance improvements for runspace initialization#10569

Merged
daxian-dbw merged 2 commits intoPowerShell:masterfrom
iSazonov:perf-startup-read-snapins
Oct 15, 2019
Merged

Minor performance improvements for runspace initialization#10569
daxian-dbw merged 2 commits intoPowerShell:masterfrom
iSazonov:perf-startup-read-snapins

Conversation

@iSazonov
Copy link
Collaborator

@iSazonov iSazonov commented Sep 18, 2019

PR Summary

Comments says that the code was optimized in Windows PowerShell but there is still room for improvements that is important for scenarios actively using runspaces and startup.

  1. Remove check that file exist.
    The code came from Windows PowerShell but now all the standard dlls is placed in $PSHome and we have no need to search them in other paths by the dll name.
    image

  2. Remove some obvious allocations

  • Assembly.GetName() allocates - put it in temp variable.
  • Move Version.ToString() out of the cycle.

PR Context

PR Checklist

@iSazonov iSazonov added the CL-Performance Indicates that a PR should be marked as a performance improvement in the Change Log label Sep 18, 2019
@iSazonov iSazonov added this to the 7.0.0-preview.5 milestone Sep 18, 2019
@daxian-dbw daxian-dbw self-assigned this Sep 26, 2019
Copy link
Member

@daxian-dbw daxian-dbw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perf win ~2.3%

This comment is not accurate. This code path is hit 4 or 5 times at most when Runspace opens. There are many other places checks for file existence, such as in PowerShellConfig when reading the config json file. So removing this check won't eliminate all FileSystem.FileExist calls.

@daxian-dbw
Copy link
Member

daxian-dbw commented Oct 10, 2019

Can you update your PR description to not say a 2.3% perf win?
Also, when having a screenshot of profiling result, I suggest to describe what was profiled (e.g. the command executed by PerfView->Run), so there is more context.

@iSazonov
Copy link
Collaborator Author

PerfView shows follow code paths:
image

So expected win is up to 1.8%.

I tested Runspace.Open() if I remember right three weeks later :-)

@daxian-dbw
Copy link
Member

It's still not accurate as there may be other calls to File.Exist within the code paths hit by RunspaceFactory.CreateRunspace. I suggest to remove the Perf Win part in the PR description.

@iSazonov
Copy link
Collaborator Author

Done.

@iSazonov
Copy link
Collaborator Author

@daxian-dbw Could you please merge?

@daxian-dbw daxian-dbw merged commit c76e122 into PowerShell:master Oct 15, 2019
@daxian-dbw
Copy link
Member

@iSazonov Sorry I forgot this :)

@iSazonov iSazonov deleted the perf-startup-read-snapins branch October 16, 2019 03:01
@ghost
Copy link

ghost commented Oct 23, 2019

🎉v7.0.0-preview.5 has been released which incorporates this pull request.:tada:

Handy links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-Performance Indicates that a PR should be marked as a performance improvement in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

X Tutup