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

[Xamarin.Android.Build.Tasks] use typemaps when EmbedAssembliesIntoApk=False #3692

Merged

Conversation

jonathanpeppers
Copy link
Member

@jonathanpeppers jonathanpeppers commented Sep 25, 2019

This is a first step to use the typemap.mj and typemap.jm files
for Fast Deployment. We will eventually generate these files on a
per-assembly basis, but can get some small perf improvements for
Debug builds:

  • When $(EmbedAssembliesIntoApk) is True use the native assembly
    in typemap.*.inc and the current behavior.
  • When $(EmbedAssembliesIntoApk) is False don't generate any
    typemap.*.inc files at all, but still use the native assembly for
    environment variables.
  • We have to still generate typemap.*.s files with empty values.

typemap.*.s changes

Before:

  jm_typemap_header:
    /* version */
    .long	1
    /* entry-count */
    .long	1324
    /* entry-length */
    .long	262
    /* value-offset */
    .long	117
    .size	jm_typemap_header, 16

    /* Mapping data */
    .type	jm_typemap, %object
    .global	jm_typemap
  jm_typemap:
    .size	jm_typemap, 346889
    .include	"typemap.jm.inc"

After:

  jm_typemap_header:
    /* version */
    .long	1
    /* entry-count */
    .long	0
    /* entry-length */
    .long	0
    /* value-offset */
    .long	0
    .size	jm_typemap_header, 16

    /* Mapping data */
    .type	jm_typemap, %object
    .global	jm_typemap
  jm_typemap:
    .size	jm_typemap, 0

The result is I don't get a crash at runtime and the typemap.mj and
typemap.jm files are used.

Results

I timed the Xamarin.Forms integration project in this repo.

An initial build:

Before:
2860 ms  GenerateJavaStubs                          1 calls
  84 ms  CompileNativeAssembly                      1 calls
After:
2595 ms  GenerateJavaStubs                          1 calls
  46 ms  CompileNativeAssembly                      1 calls

On an incremental build where MainActivity.cs was changed:

Before:
 543 ms  GenerateJavaStubs                          1 calls
After:
 323 ms  GenerateJavaStubs                          1 calls

CompileNativeAssembly is skipped for MainActivity.cs changes.

When comparing startup performance:

Before:
ActivityTaskManager: Displayed Xamarin.Forms_Performance_Integration/xamarin.forms.performance.integration.MainActivity: +1s302ms
After:
ActivityTaskManager: Displayed Xamarin.Forms_Performance_Integration/xamarin.forms.performance.integration.MainActivity: +1s341ms

As expected, startup is ~50ms worse.

I would say this change saves ~250ms on the full dev-loop in cases
where <GenerateJavaStubs/> needs to run.

@grendello
Copy link
Contributor

@jonathanpeppers out of curiosity, what was the crash you got that this PR fixes?

@jonathanpeppers
Copy link
Member Author

@grendello oh the crash was when I was trying to get this to work, sorry. It was before I made the right typemap.*.s changes.

@jonathanpeppers jonathanpeppers marked this pull request as ready for review October 16, 2019 16:30
…k=False

Bumps to xamarin/monodroid@ab054acc

Changes: xamarin/monodroid@6f77f15...ab054ac

This is a first step to use the `typemap.mj` and `typemap.jm` files
for Fast Deployment. We will eventually generate these files on a
per-assembly basis, but can get some small perf improvements for
`Debug` builds:

* When `$(EmbedAssembliesIntoApk)` is `True` use the native assembly
  in `typemap.*.inc` and the current behavior.
* When `$(EmbedAssembliesIntoApk)` is `False` don't generate any
  `typemap.*.inc` files at all, but still use the native assembly for
  environment variables.
* We have to still generate `typemap.*.s` files with empty values.

~~ typemap.*.s changes ~~

Before:

  jm_typemap_header:
    /* version */
    .long	1
    /* entry-count */
    .long	1324
    /* entry-length */
    .long	262
    /* value-offset */
    .long	117
    .size	jm_typemap_header, 16

    /* Mapping data */
    .type	jm_typemap, %object
    .global	jm_typemap
  jm_typemap:
    .size	jm_typemap, 346889
    .include	"typemap.jm.inc"

After:

  jm_typemap_header:
    /* version */
    .long	1
    /* entry-count */
    .long	0
    /* entry-length */
    .long	0
    /* value-offset */
    .long	0
    .size	jm_typemap_header, 16

    /* Mapping data */
    .type	jm_typemap, %object
    .global	jm_typemap
  jm_typemap:
    .size	jm_typemap, 0

The result is I don't get a crash at runtime and the `typemap.mj` and
`typemap.jm` files are used.

~~ Results ~~

I timed the Xamarin.Forms integration project in this repo.

An initial build:

    Before:
    2860 ms  GenerateJavaStubs                          1 calls
      84 ms  CompileNativeAssembly                      1 calls
    After:
    2595 ms  GenerateJavaStubs                          1 calls
      46 ms  CompileNativeAssembly                      1 calls

On an incremental build where `MainActivity.cs` was changed:

    Before:
     543 ms  GenerateJavaStubs                          1 calls
    After:
     323 ms  GenerateJavaStubs                          1 calls

`CompileNativeAssembly` is skipped for `MainActivity.cs` changes.

When comparing startup performance:

    Before:
    ActivityTaskManager: Displayed Xamarin.Forms_Performance_Integration/xamarin.forms.performance.integration.MainActivity: +1s302ms
    After:
    ActivityTaskManager: Displayed Xamarin.Forms_Performance_Integration/xamarin.forms.performance.integration.MainActivity: +1s341ms

As expected, startup is ~50ms worse.

I would say this change saves ~250ms on the full dev-loop in cases
where `<GenerateJavaStubs/>` needs to run.
@jonathanpeppers
Copy link
Member Author

The only two test failures are zipalign on macOS and one related to lint on Windows. These should be unrelated, so merging.

@jonathanpeppers jonathanpeppers merged commit 5f3b68e into dotnet:master Oct 17, 2019
@jonathanpeppers jonathanpeppers deleted the typemap-embedassemblies branch October 17, 2019 02:08
@github-actions github-actions bot locked and limited conversation to collaborators Jan 29, 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

4 participants