Remove allocations in BaseUriHelper, improve resource resolution performance #10328
+374
−686
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently blocked by #9822, hence draft.
Description
Optimizes methods in
BaseUriHelper
, removes most of the allocations directly in this class and opens up more optimization possibilities; directly builds upon #9739 and #9822.IsSameKeyToken
from SecurityHelper in favour ofReflectionUtils.IsSamePublicKeyToken
.BaseUriHelper.GetAssemblyNameAndPart
is now fully allocation free.AssemblyPackageInfo
ref struct
.FontResourceCache
, we can now useAlternateLookup
to benefit from this change as well.BaseUriHelper.BaseUri
was never set outside static constructor, where it was initialized to thes_packAppBaseUri
value,hence I've removed the property altogether, which also led to removal of
BindUriHelper.BaseUri
which was just proxy.CF_Envelope_Activation_Enabled
macro was removed, most of the code is already missing in .NET Core than what was in reference files for .NET 3.5 and it is never compiled on NetFX nor on .NET Core.GetLoadedAssembly
bring a bit of an improvement but there's more benchmarking needed on how to handle this chain most efficiently, so keeping as it is right now.Cherry-picking some cases:
GetAssemblyNameAndPart
AssemblyMatchesKeyString vs ComparePublicKeyTokens
Customer Impact
Improved performance, decrased allocations.
Regression
No.
Testing
Local build, some assert testing; I'll provide tests before this goes out of draft.
Risk
Low to medium, there are quite a few changes but most of them are rather straightforward.
Microsoft Reviewers: Open in CodeFlow