Skip to content

Conversation

@iSazonov
Copy link
Collaborator

@iSazonov iSazonov commented Nov 1, 2021

PR Summary

Rid of TypeResolver.ResolveType() call from Process_Types_Ps1Xml().

Perf win at startup scenario is ~9%.

All static methods from SecurityDescriptorCommandsBase class are moved to new SecurityDescriptorCommandsHelperBase class in SMA. This allows to directly reference the static methods from Process_Types_Ps1Xml().

PR Context

I was very surprised to discover that there is only one call of TypeResolver.ResolveType() in Process_Types_Ps1Xml which does the huge delay at startup scenario.

Before the PR:
image

After the PR:
image


In future I think it makes sense to improve a performance of TypeResolver.ResolveType() itself. While a cache is empty the method does very expensive assembly enumeration. I guess we could pre-build the cache at compile time for well-known assemblies and get perf wins for some scenarios.


PR Checklist

@iSazonov iSazonov added the CL-Performance Indicates that a PR should be marked as a performance improvement in the Change Log label Nov 1, 2021
try
{
IdentityReference? ir = sd.GetOwner(typeof(NTAccount));
return ir?.ToString();
Copy link
Collaborator Author

@iSazonov iSazonov Nov 1, 2021

Choose a reason for hiding this comment

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

Now it can return a null instead of null reference exception. What is original design here?

try
{
IdentityReference? ir = sd.GetGroup(typeof(NTAccount));
return ir?.ToString();
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Now it can return a null instead of null reference exception. What is original design here?

}
}

#if !CORECLR
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Makes sense to remove the code?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Or enable for IsWindowsDesktop?

Copy link
Member

Choose a reason for hiding this comment

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

The code shouldn't be removed. It was enclosed by CORECLR because the Win32 API LsaQueryCAPs was not available on NanoServer. Now it should be enabled in theory. I think we need @TravisEz13 or @PaulHigin to take a look.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks! Docs say the API is on Windows 8/2012+ desktop apps only.
https://docs.microsoft.com/en-us/windows/win32/api/ntlsa/nf-ntlsa-lsaquerycaps

@iSazonov iSazonov requested a review from SteveL-MSFT November 1, 2021 17:24
@daxian-dbw
Copy link
Member

I don't think this is what we want. We want to split S.M.A, instead of moving more stuff to it. Resolving types and thus loading an assembly like this is inevitable when getting S.M.A.dll leaner.

@iSazonov
Copy link
Collaborator Author

iSazonov commented Nov 1, 2021

This is the easiest thing I could do quickly with hope to get this in 7.2. :-)
It's more of a workaround. These classes are hardly a public contract and since the gain is very significant, it could have been taken until more complex fix is made in TypeResolver.ResolveType()

@pull-request-quantifier-deprecated

This PR has 451 quantified lines of changes. In general, a change size of upto 200 lines is ideal for the best PR experience!


Quantification details

Label      : Extra Large
Size       : +229 -222
Percentile : 81.7%

Total files changed: 5

Change summary by file extension:
.cs : +229 -221
.ps1 : +0 -1

Change counts above are quantified counts, based on the PullRequestQuantifier customizations.

Why proper sizing of changes matters

Optimal pull request sizes drive a better predictable PR flow as they strike a
balance between between PR complexity and PR review overhead. PRs within the
optimal size (typical small, or medium sized PRs) mean:

  • Fast and predictable releases to production:
    • Optimal size changes are more likely to be reviewed faster with fewer
      iterations.
    • Similarity in low PR complexity drives similar review times.
  • Review quality is likely higher as complexity is lower:
    • Bugs are more likely to be detected.
    • Code inconsistencies are more likely to be detetcted.
  • Knowledge sharing is improved within the participants:
    • Small portions can be assimilated better.
  • Better engineering practices are exercised:
    • Solving big problems by dividing them in well contained, smaller problems.
    • Exercising separation of concerns within the code changes.

What can I do to optimize my changes

  • Use the PullRequestQuantifier to quantify your PR accurately
    • Create a context profile for your repo using the context generator
    • Exclude files that are not necessary to be reviewed or do not increase the review complexity. Example: Autogenerated code, docs, project IDE setting files, binaries, etc. Check out the Excluded section from your prquantifier.yaml context profile.
    • Understand your typical change complexity, drive towards the desired complexity by adjusting the label mapping in your prquantifier.yaml context profile.
    • Only use the labels that matter to you, see context specification to customize your prquantifier.yaml context profile.
  • Change your engineering behaviors
    • For PRs that fall outside of the desired spectrum, review the details and check if:
      • Your PR could be split in smaller, self-contained PRs instead
      • Your PR only solves one particular issue. (For example, don't refactor and code new features in the same PR).

How to interpret the change counts in git diff output

  • One line was added: +1 -0
  • One line was deleted: +0 -1
  • One line was modified: +1 -1 (git diff doesn't know about modified, it will
    interpret that line like one addition plus one deletion)
  • Change percentiles: Change characteristics (addition, deletion, modification)
    of this PR in relation to all other PRs within the repository.


Was this comment helpful? 👍  :ok_hand:  :thumbsdown: (Email)
Customize PullRequestQuantifier for this repository.

@daxian-dbw
Copy link
Member

daxian-dbw commented Nov 1, 2021

Performance changes won't meet the bar to be ported to the 7.2 GA release branch at this point. Only fix to regressions or build-n-packaging will be considered.

@iSazonov
Copy link
Collaborator Author

iSazonov commented Nov 4, 2021

@daxian-dbw Could you please look my questions above for the old code? Makes sense to fix this?

@CMCCO

This comment has been minimized.

@CMCCO

This comment has been minimized.

@iSazonov iSazonov deleted the perf-startup-psxml branch November 26, 2022 11:33
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 Extra Large

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants