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] precompile SetVsMonoAndroidRegistryKey #2130

Merged

Conversation

jonathanpeppers
Copy link
Member

In Xamarin.Android.Sdk.props we have some inline C# code for a
MSBuild task named SetVsMonoAndroidRegistryKey. Which is
understandable, since the code needed is so simple. But thinking about
it, MSBuild has to compile this code to run it. Which seems
inherently slower than if we compiled the code during our build.

Currently its entire parent target, RedirectMonoAndroidSdkPaths,
takes:

157 ms  RedirectMonoAndroidSdkPaths                1 calls

I moved this task inside Xamarin.Android.Build.Tasks.dll, and we
appear to get some improvements "for free":

76 ms  RedirectMonoAndroidSdkPaths                1 calls

I looked at some past logs, and there are some times where the
RedirectMonoAndroidSdkPaths target was taking over 200ms. I suspect
MSBuild might also have some caching functionality for inlined C#
code. There might be a cached assembly somewhere? Not sure.

What makes this a better fix is that this target runs for all
builds--even builds with no changes.

General changes:

  • The <UsingTask /> doesn't need a condition, since it will be
    lazily evaluated anyways.
  • Used string interpolation where it looked nicer.
  • Used LogDebugMessage and improved the log message.

In `Xamarin.Android.Sdk.props` we have some inline C# code for a
MSBuild task named `SetVsMonoAndroidRegistryKey`. Which is
understandable, since the code needed is so simple. But thinking about
it, MSBuild has to *compile* this code to run it. Which seems
inherently slower than if we compiled the code during our build.

Currently its entire parent target, `RedirectMonoAndroidSdkPaths`,
takes:

    157 ms  RedirectMonoAndroidSdkPaths                1 calls

I moved this task inside `Xamarin.Android.Build.Tasks.dll`, and we
appear to get some improvements "for free":

    76 ms  RedirectMonoAndroidSdkPaths                1 calls

I looked at some past logs, and there are some times where the
`RedirectMonoAndroidSdkPaths` target was taking over 200ms. I suspect
MSBuild might also have some caching functionality for inlined C#
code. There might be a cached assembly somewhere? Not sure.

What makes this a better fix is that this target runs for all
builds--even builds with no changes.

General changes:
- The `<UsingTask />` doesn't need a condition, since it will be
  lazily evaluated anyways.
- Used string interpolation where it looked nicer.
- Used `LogDebugMessage` and improved the log message.
@jonathanpeppers
Copy link
Member Author

Logs for this: RedirectMonoAndroidSdkPaths.zip

@jonathanpeppers
Copy link
Member Author

I think the build failure is unrelated, this target doesn't run at all on Mac?

<Target Name="RedirectMonoAndroidSdkPaths" Condition="'$(VsInstallRoot)' != ''">

The error is:

TestApks.targets(248,5): error : Could not find file "/Users/builder/jenkins/workspace/xamarin-android-pr-builder/xamarin-android/bin/TestDebug/TestResult-Xamarin.Android.Bcl_Tests.nunit.xml"

@jonpryor jonpryor merged commit a677c17 into dotnet:master Sep 5, 2018
jonpryor pushed a commit that referenced this pull request Sep 5, 2018
…2130)

In `Xamarin.Android.Sdk.props` we have some inline C# code for a
MSBuild task named `SetVsMonoAndroidRegistryKey`.  Which is
understandable, since the code needed is so simple.  But thinking
about it, MSBuild has to *compile* this code to run it.  Which seems
inherently slower than if we compiled the code during our build.

Currently its entire parent target, `RedirectMonoAndroidSdkPaths`,
takes:

	157 ms  RedirectMonoAndroidSdkPaths                1 calls

I moved this task inside `Xamarin.Android.Build.Tasks.dll`, and we
appear to get some improvements "for free":

	 76 ms  RedirectMonoAndroidSdkPaths                1 calls

I looked at some past logs, and there are some times where the
`RedirectMonoAndroidSdkPaths` target was taking over 200ms.  I
suspect MSBuild might also have some caching functionality for
inlined C# code. There might be a cached assembly somewhere?
Not sure.

What makes this a better fix is that this target runs for all
builds--even builds with no changes.

General changes:

  - The `<UsingTask/>` doesn't need a condition, since it will be
    lazily evaluated anyways.
  - Used string interpolation where it looked nicer.
  - Used `LogDebugMessage()` and improved the log message.
@github-actions github-actions bot locked and limited conversation to collaborators Feb 2, 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.

2 participants