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

[linker] use Java.Interop's TypeDefinitionCache #4316

Merged
merged 1 commit into from
Feb 26, 2020

Conversation

jonathanpeppers
Copy link
Member

Context: dotnet/java-interop@b81cfbb

Similar to aff3b52, we can use TypeDefinitionCache in a few places
in the linker. My approach was to make each linker step require a
TypeDefinitionCache for its constructor as needed. This made a
single TypeDefinitionCache used throughout a linker Pipeline. The
<LinkAssembliesNoShrink/> MSBuild task could also control the
lifetime of the TypeDefinitionCache.

The results of building the Xamarin.Forms integration project on
Windows:

Before:
706 ms  LinkAssembliesNoShrink                     1 calls
After:
695 ms  LinkAssembliesNoShrink                     1 calls

On macOS / mono:

Before:
1248 ms  LinkAssembliesNoShrink                     1 calls
After:
1228 ms  LinkAssembliesNoShrink                     1 calls

This saves ~20ms for a small app, but is probably worth it to get rid
of the [Obsolete] warnings caused by:

https://github.com/xamarin/java.interop/blob/4f47ec82c14ae6ca23c1dcde3f7b5c8b93b6a4f7/src/Java.Interop.Tools.Cecil/Java.Interop.Tools.Cecil/TypeDefinitionRocks.cs#L70-L72

Context: dotnet/java-interop@b81cfbb

Similar to aff3b52, we can use `TypeDefinitionCache` in a few places
in the linker. My approach was to make each linker step require a
`TypeDefinitionCache` for its constructor as needed. This made a
single `TypeDefinitionCache` used throughout a linker `Pipeline`. The
`<LinkAssembliesNoShrink/>` MSBuild task could also control the
lifetime of the `TypeDefinitionCache`.

The results of building the Xamarin.Forms integration project on
Windows:

    Before:
    706 ms  LinkAssembliesNoShrink                     1 calls
    After:
    695 ms  LinkAssembliesNoShrink                     1 calls

On macOS / mono:

    Before:
    1248 ms  LinkAssembliesNoShrink                     1 calls
    After:
    1228 ms  LinkAssembliesNoShrink                     1 calls

This saves ~20ms for a small app, but is probably worth it to get rid
of the `[Obsolete]` warnings caused by:

https://github.com/xamarin/java.interop/blob/4f47ec82c14ae6ca23c1dcde3f7b5c8b93b6a4f7/src/Java.Interop.Tools.Cecil/Java.Interop.Tools.Cecil/TypeDefinitionRocks.cs#L70-L72
@jonpryor jonpryor merged commit 767047a into dotnet:master Feb 26, 2020
jonpryor pushed a commit that referenced this pull request Feb 26, 2020
Context: dotnet/java-interop@b81cfbb

Similar to aff3b52, we can use `TypeDefinitionCache` in a few places
in the linker. My approach was to make each linker step require a
`TypeDefinitionCache` for its constructor as needed. This made a
single `TypeDefinitionCache` used throughout a linker `Pipeline`. The
`<LinkAssembliesNoShrink/>` MSBuild task could also control the
lifetime of the `TypeDefinitionCache`.

The results of building the Xamarin.Forms integration project on
Windows:

    Before:
    706 ms  LinkAssembliesNoShrink                     1 calls
    After:
    695 ms  LinkAssembliesNoShrink                     1 calls

On macOS / mono:

    Before:
    1248 ms  LinkAssembliesNoShrink                     1 calls
    After:
    1228 ms  LinkAssembliesNoShrink                     1 calls

This saves ~20ms for a small app, but is probably worth it to get rid
of the `[Obsolete]` warnings caused by:

https://github.com/xamarin/java.interop/blob/4f47ec82c14ae6ca23c1dcde3f7b5c8b93b6a4f7/src/Java.Interop.Tools.Cecil/Java.Interop.Tools.Cecil/TypeDefinitionRocks.cs#L70-L72
@jonathanpeppers jonathanpeppers deleted the linker-typedefinitioncache branch February 26, 2020 03:29
@github-actions github-actions bot locked and limited conversation to collaborators Jan 24, 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.

4 participants