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

[Java.Interop] optimize JniTypeManager.AssertSimpleReference() #1001

Merged
merged 2 commits into from Jun 30, 2022

Conversation

jonathanpeppers
Copy link
Member

We noticed dotnet trace output was showing:

21.28ms (0.45%) java.interop!Java.Interop.JniRuntime.JniTypeManager.AssertSimpleReference(string,string)

This code path was introduced by a new feature in 1f27ab5.

For now, I think we can rewrite this to use the char overload of
IndexOf, as well as the regular indexer on string.

After these changes, I get a better time:

1.21ms java.interop!Java.Interop.JniRuntime.JniTypeManager.AssertSimpleReference(string,string)

We may have just moved the location that ICU is loaded, but this
change is good regardless.

We noticed `dotnet trace` output was showing:

    21.28ms (0.45%) java.interop!Java.Interop.JniRuntime.JniTypeManager.AssertSimpleReference(string,string)

This code path was introduced by a new feature in 1f27ab5.

For now, I think we can rewrite this to use the `char` overload of
`IndexOf`, as well as the regular indexer on `string`.

After these changes, I get a better time:

    1.21ms java.interop!Java.Interop.JniRuntime.JniTypeManager.AssertSimpleReference(string,string)

We may have just *moved* the location that ICU is loaded, but this
change is good regardless.
@jonathanpeppers
Copy link
Member Author

The next place that is loading ICU, is back to .NET 6 behavior:

image

Probably not avoidable:

https://github.com/xamarin/xamarin-android/blob/e1611871aa84d25a47e7f71a7b8b87bf5f19932b/src/Mono.Android/Java.Interop/TypeManager.cs#L26

@jonpryor
Copy link
Member

StringComparer.Ordinal brings in ICU?!

That feels like dotnet/runtime should be fixed.

    src/Java.Interop/Java.Interop/JniTypeSignatureAttribute.cs:                     JniRuntime.JniTypeManager.AssertSimpleReference (simpleReference, nameof (simpleReference));

Not all codepaths use `jniSimpleReference`.  Use `argumentName` for the argument name.
@jonpryor jonpryor merged commit 920ea64 into main Jun 30, 2022
@jonpryor jonpryor deleted the AssertSimpleReference branch June 30, 2022 01:05
@github-actions github-actions bot locked and limited conversation to collaborators Apr 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants