Skip to content

Conversation

@kapilmb
Copy link

@kapilmb kapilmb commented Jan 24, 2017

Before

PS> 1..5 | % {measure-command {Invoke-ScriptAnalyzer ~\Source\Repos\PowerShellGet\PowerShellGet\PSModule.psm1}} | select TotalSeconds

TotalSeconds
------------
  25.9780775
   25.881099
  27.8301631
  28.9696967
  28.2952561

After

PS> 1..5 | % {measure-command {Invoke-ScriptAnalyzer ~\Source\PowerShellGet\PowerShellGet\PSModule.psm1}} | select
 TotalSeconds

TotalSeconds
------------
  28.1845615
   2.9607327
   3.1941642
   3.8798161
   3.0282973

This change is Reviewable

Kapil Borle added 2 commits January 23, 2017 15:44
This reverts commit 210d904.

We revert this because, this allows the instance to persist
through a powershell session across multiple pssa invocations.
This is allows us to reuse the command info cache across
multiple pssa invocations.
Since, helper is a singleton that persists through multiple
pssa invocation, in a given powershell session, this
helps us reuse the commandinfo cache created during
the first pssa invocation. Results in significant perf
improvement for subsequent pssa invocations.
lock (syncRoot)
{
instance = value;
if (instance == null)
Copy link
Contributor

Choose a reason for hiding this comment

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

Didn't this null check cause some other bug we saw recently?

Copy link
Author

Choose a reason for hiding this comment

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

Yes it did cause some issue earlier - Get-ScriptAnalyzer command would instantiate Helper.Instance to new Helper() and when Invoke-ScriptAnalyzer would try to set the instance again, it would ignore the setter, which cause Invoke-ScriptAnalyzer to crash.

But after adding this, that bug was resolved and the removing this null check was redundant.

Copy link
Contributor

Choose a reason for hiding this comment

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

Great!

@kapilmb
Copy link
Author

kapilmb commented Jan 24, 2017

Thanks @daviwil

@kapilmb kapilmb merged commit c23d0ae into development Jan 24, 2017
@kapilmb kapilmb deleted the kapilmb/FixPerformance branch January 24, 2017 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants