Skip to content

Conversation

@ladipro
Copy link
Member

@ladipro ladipro commented Jul 17, 2023

#8916 broke some .NET Framework scenarios and was reverted. This PR is a redo of the change with the bug fixed. It turned out that the destination of the optimized CopyMetadataTo may be a transparent proxy, typically a TaskItem object living in another appdomain, which does not work well with Linq. The fix and the test coverage are in their own commits.

Context

Low-hanging fruit is showing in RAR performance profiles.

Changes Made

  1. Avoided constructing AssemblyName on a hot path as the constructor makes expensive Fusion calls on .NET Framework. The problematic code was introduced in [RAR] Don't do I/O on SDK-provided references #8688.

  2. Added a metadata bulk-set operation to the internal IMetadataContainer interface. Calling SetMetadata for more than a couple of metadata is slow if ImmutableDictionary is used as its backing storage. RAR is heavy on metadata manipulation and switching to the new operation saves about 10% of RAR run-time when building OrchardCore.

Testing

Existing and new unit tests. Measured the perf impact by building OC.

@ladipro ladipro requested a review from rokonec July 18, 2023 07:56
@ladipro
Copy link
Member Author

ladipro commented Jul 18, 2023

@rokonec can you please review? The first commit was already reviewed as #8916 by Rainer and Jan but Jan is out this week.

Copy link
Member

@JanKrivanek JanKrivanek left a comment

Choose a reason for hiding this comment

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

Looks good (unless there is other changes compared to #8916 other then the x-app-domain linq handling)

@JaynieBai JaynieBai merged commit c8db2ed into dotnet:main Jul 27, 2023
@ladipro ladipro deleted the rar-cpu-optimizations-take2 branch July 27, 2023 08:30
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