[Mono.Android] fix Type.GetType() performance issue
#10416
Merged
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.
Comparing performance of .NET 9 vs .NET 10, I noticed something very odd stand out!
Was
Type.GetType()really that much slower in .NET 10?After some testing, my tests found that this was not the case when I tested
Type.GetType()in isolation.So I added some logging to
JNIEnvInitto see what was going on:And got this result!
37ms is a lot!
Then I noticed the string has the full assembly identity:
But it should actually be:
The stack trace of
Type.GetType()shows that there must be some new assembly name validation going on. This certainly doesn't match, so we must be hitting a slow path!I just removed the assembly identity from the string, and now we get:
It appears we always had this code, but maybe in the past no assembly validation was done? That is my current theory.