Repository navigation
[Xamarin.Android.Build.Tasks] <GetImportedLibraries/> perf improvements - #2930
Merged
Merged
Conversation
I noticed a target running on an incremental build with only a XAML
code change:
116 ms _BuildLibraryImportsCache 1 calls
This was using VS 2019 GA, just a blank Xamarin.Forms app.
Reviewing `<GetImportedLibraries/>` it had some general perf
improvements that could be done:
* It called `Directory.EnumerateFiles` three times...
* It used a bunch of LINQ where a `foreach` would do.
Additionally, I saw some improvements I could do at the MSBuild target
level:
<Target Name="_BuildLibraryImportsCache"
Inputs="$(MSBuildProjectFullPath);@(_ReferencePath);@(_ReferenceDependencyPaths);$(_AndroidBuildPropertiesCache);$(_AndroidLibraryProjectImportsCache)"
Outputs="$(_AndroidLibraryImportsCache).stamp">
This target operates on the output of `_ResolveLibraryProjectImports`,
but it was re-running if *any* assembly changed?
I think the `Inputs` and `Outputs` would more appropriately be:
Inputs="$(_AndroidLibraryProjectImportsCache)"
Outputs="$(_AndroidStampDirectory)_BuildLibraryImportsCache.stamp"
This way, if `_ResolveLibraryProjectImports` runs and does work, it
writes to `$(_AndroidLibraryProjectImportsCache)`. We then only need
to run this task when that file changes.
I also updated this target so it follows our new convention for
placing stamp files in `$(_AndroidStampDirectory)`.
~~ Results ~~
An example of an initial build of the Xamarin.Forms project in this
repo:
Before:
299 ms GetImportedLibraries 1 calls
After:
172 ms GetImportedLibraries 1 calls
And then an incremental build, that is a XAML change:
Before:
109 ms _BuildLibraryImportsCache 1 calls
After:
n/a
The task is skipped now:
_BuildLibraryImportsCache:
Skipping target "_BuildLibraryImportsCache" because all output files are up-to-date with respect to the input files.
Overall, I would say there is a ~120ms improvement on initial build.
Incremental builds with XAML changes have a ~100ms improvement.
Member
Author
|
Build logs: getimportedlibraries.zip |
dellis1972
reviewed
Apr 5, 2019
Contributor
|
3 of the errors look like those weird ssl issues. One is this not sure it is related though, |
dellis1972
approved these changes
Apr 8, 2019
Member
Author
|
I restarted the macOS build -- if we just had network failures would be OK, but the multi-dex tests failing to start were concerning. |
Member
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.

I noticed a target running on an incremental build with only a XAML
code change:
This was using VS 2019 GA, just a blank Xamarin.Forms app.
Reviewing
<GetImportedLibraries/>it had some general perfimprovements that could be done:
Directory.EnumerateFilesthree times...foreachwould do.Additionally, I saw some improvements I could do at the MSBuild target
level:
This target operates on the output of
_ResolveLibraryProjectImports,but it was re-running if any assembly changed?
I think the
InputsandOutputswould more appropriately be:This way, if
_ResolveLibraryProjectImportsruns and does work, itwrites to
$(_AndroidLibraryProjectImportsCache). We then only needto run this task when that file changes.
I also updated this target so it follows our new convention for
placing stamp files in
$(_AndroidStampDirectory).Results
An example of an initial build of the Xamarin.Forms project in this
repo:
And then an incremental build, that is a XAML change:
The task is skipped now:
Overall, I would say there is a ~120ms improvement on initial build.
Incremental builds with XAML changes have a ~100ms improvement.