-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Avoid caching ProviderInfo.FullName at init time #11761
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
|
@iSazonov Could you please update your PR description to include the summary and context? |
|
@daxian-dbw Done. |
|
Looking at the issue described, we might want to consider this for GA |
| moduleName, | ||
| name); | ||
| } | ||
| internal string GetFullName() => EvaluateFullName(Name, PSSnapInName, ModuleName); |
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.
It doesn't seem necessary to have the GetFullName function. You can call EvaluateFullName(Name, PSSnapInName, ModuleName) directly instead, no?
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.
It is called in SessionStatePrividerAPIs too.
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.
If that's the case, can you maybe do this?
internal string GetFullName()
{
string result = Name;
if (!string.IsNullOrEmpty(PSSnapInName))
{
result =
string.Format(
System.Globalization.CultureInfo.InvariantCulture,
"{0}\\{1}",
PSSnapInName,
Name);
}
// After converting core snapins to load as modules, the providers will have Module property populated
else if (!string.IsNullOrEmpty(ModuleName))
{
result =
string.Format(
System.Globalization.CultureInfo.InvariantCulture,
"{0}\\{1}",
ModuleName,
Name);
}
return result;
}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.
Yes, I can. Will do.
| psSnapInName, | ||
| name); | ||
| } | ||
| return _fullName ?? (_fullName = GetFullName()); |
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.
The name is still cached. But does it make sens to caching this name at all?
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.
This comes from #8831 where we add the optimization. It is amazing to calculate the full name for every provider operation. I'd do not revert the optimization.
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.
So it's not a problem to use the cached name in other places but only those 2 spots you changed in this PR?
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.
It is important to do not cache the provider full name in the submodule until we set root module name.
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.
Then it would be very helpful to add comments to the place where you use GetFullName() instead of the cached fullname, otherwise, another refactoring in future might change it back to use the cached value.
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.
The comment is already there "Use GetFullName() to avoid caching full name at init time."
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.
Ah, yes, I missed that. Can you please also add the information about why to avoid the cached name?
|
@iSazonov Please add tests for the change. There is no urgency to take this in 7.0 GA since it is not a regression from 6.2. We will consider this for GA if there are tests added to this PR and its merged by 10 am PDT on 02/12/2020. Otherwise we will consider this for the next servicing release of 7. /cc @SteveL-MSFT |
|
@adityapatwardhan @daxian-dbw @rjmholt Current fix is not reliable - later someone might accidentally violate these implicit conditions for using the cached name. I make more reliable fix in #11813 and add a test. |
rjmholt
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.
To be closed in favour of #11813
|
@iSazonov Can this PR be closed? |
|
removing from GA-Consider to remove to from triage until it is ready to review |
|
I think #11813 is better fix. |
PR Summary
Address #9840
In #8831 we added caching for ProviderInfo.FullName. It came a problem in scenario of loading nested module. PowerShell change nested module name to root module name after it is loaded the nested module. In the scenario ProviderInfo.FullName is cached with nested module name and not updated to root module name.
The fix is to do not cache ProviderInfo.FullName at init time. After modules are loaded and cached name is safely used.
PR Context
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.