-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Optimize assembly/namespace pair creation and updating in XamlSchema #9926
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
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
a1c2ab7
to
2e0f1d6
Compare
@harshit7962 @himgoyalmicro I've fixed the dummy NRE mistake in the last commit, so this could finally go through tests. |
@h3xds1nz, this PR looks good to me. Can you resolve the merge conflicts here ? PS: From what I gather, copying a List is heavier as compared to array and that's why the shift ? If yes, then maybe we can add this as a comment where AssemblyNamespacePair[] array is defined. |
@dipeshmsft This is a special case, or rather, lazy misuse of
This means you're here initializing the Therefore exploiting the fact that we only add 1 item, we can just allocate an array with Plus we get better control of the sizing (empty list on first addition allocates array or 4 vs our array of 1) and then we don't grow by * 2 number of items but by 1. |
Okay, so now using array, we pre-allocate the extra space for the 1 extra element, preventing the extra copy. Thanks a lot for the explaination. |
2e0f1d6
to
339993a
Compare
@dipeshmsft Anytime :) (though usually it is better to answer questions regarding PRs in the next few weeks than 8 months later, one might miss context after that time if its something complicated, which isn't the case here but couldn't help myself to nitpick about the timeline 😀) Conflicts resolved. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #9926 +/- ##
===================================================
- Coverage 13.62756% 13.47617% -0.15140%
===================================================
Files 3316 3317 +1
Lines 664822 664751 -71
Branches 74651 74643 -8
===================================================
- Hits 90599 89583 -1016
- Misses 571523 572569 +1046
+ Partials 2700 2599 -101
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
Description
Adjusts inefficient
List<AssemblyNamespacePair>
copies inAddAssemblyNamespacePair
that result in up to double gen0 allocations needed for the job, offering perf benefit and decreased allocations.readonly struct
, there's like zero benefit but I think it serves better purpose.WeakReference
is now generic to prevent unnecessary casting._assemblyNamespaces
is under a write-lock and copies are created each time to allow reading concurrently by multiple readers, we can just swap to an array for overall efficiency since only 1 item is added each time.Initial creation
Initial creation plus 9x AddAssemblyNamespacePair
Customer Impact
Improved performance, decreased allocations.
Regression
No.
Testing
Local build, basic method testing.
Risk
Low, there's only a swap from class to readonly struct being stored in a private array (that was originally a list).
Microsoft Reviewers: Open in CodeFlow