This repository was archived by the owner on Jan 23, 2023. It is now read-only.
[release/3.1] Port cache polymorphic properties (#41753)#42057
Merged
Conversation
* Cache polymorphic properties * Move RuntimePropertyCache to JsonClassInfo * Added test of RuntimePropertyCache using properties with different attributes * Fixed typo Co-Authored-By: Ahson Khan <ahkha@microsoft.com> * Use allocating overload of GetOrAdd on .Net Standard 2.0
ahsonkhan
approved these changes
Oct 23, 2019
Member
|
Approved. Customer reported performance concern, substantial impact, relatively localized change. Please merge by 4pm. |
|
Fixes https://github.com/dotnet/corefx/issues/41638 for release/3.1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
note: this PR was created and made stand-alone since the previous PR that included this fix takes a dependency on collection PR that will likely not be accepted.
Ports #41753
Issue
With the PR there is significant performance improvement when using polymorphic serialization. The issue was created and fixed by a community member by adding a dictionary-based cache and reports real-world gains of 68x.
Description
When a property of type of System.Object is serialized, the serializer enters a polymorphic mode where it obtains the actual run-time type to serialize. Getting the appropriate infrastructure (including looking up a converter for that type and generating IL for the setter) is expensive and was not cached. This PR caches that information.
Customer Impact
Regression?
No.
Risk
Low.
The performance issue is very specific to polymorphic serialization which was already tested. An additional test was added to verify the cache is properly keying.