Skip to content
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

Unify managed runtime type name parsers #83484

Merged
merged 9 commits into from
Mar 25, 2023
Merged

Conversation

jkotas
Copy link
Member

@jkotas jkotas commented Mar 15, 2023

Contributes to #72833 and #77868

The performance effect of this change on typical use of Type.GetType like Type.GetType("MyType, MyAssembly") is in the noise range. The typical use of Type.GetType spends most of the time in assembly loader and type loader. The time spent by parsing the type name is small fraction of the total and the performance improvement is hardly noticeable.

When the type name parser performance is measured in isolation, it is several times faster compared to the existing unmanaged CoreCLR type name parser. For example:

Type.GetType("System.Object, System.Private.CoreLib",
       assemblyResolver: (an) => typeof(object).Assembly,
       typeResolver: (assembly, name, ignoreCase) => typeof(object));

is about 3x faster with this change on CoreCLR.

@ghost
Copy link

ghost commented Mar 15, 2023

Tagging subscribers to this area: @dotnet/area-system-reflection
See info in area-owners.md if you want to be subscribed.

Issue Details

null

Author: jkotas
Assignees: jkotas
Labels:

area-System.Reflection

Milestone: -

@jkotas jkotas changed the title Unity managed runtime type name parsers Unify managed runtime type name parsers Mar 19, 2023
@@ -401,11 +396,4 @@ class TypeName
Factory<InlineSString<128> > m_nestNameFactory;
Copy link
Member Author

Choose a reason for hiding this comment

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

I plan to delete the unmanaged type name parser and switch VM to use the managed one everywhere in a follow up change.

@jkotas jkotas marked this pull request as ready for review March 19, 2023 06:43
@jkotas
Copy link
Member Author

jkotas commented Mar 19, 2023

This is ready for review.

jkotas and others added 3 commits March 20, 2023 20:36
Co-authored-by: Aaron Robinson <arobins@microsoft.com>
Co-authored-by: Aaron Robinson <arobins@microsoft.com>
//
// Parser for type names passed to GetType() apis.
//
internal sealed class TypeParser
Copy link
Member Author

Choose a reason for hiding this comment

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

The unified implementation evolved from this native aot-specific implementation.

@jkotas
Copy link
Member Author

jkotas commented Mar 25, 2023

Known issues

@jkotas jkotas merged commit 91b93eb into dotnet:main Mar 25, 2023
@jkotas jkotas deleted the type-name-parser branch March 25, 2023 03:46
@jkotas
Copy link
Member Author

jkotas commented Mar 25, 2023

@AaronRobinsonMSFT Thank you for reviewing this PR!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants