[Xamarin.Android.Build.Tasks] <GetImportedLibraries/> perf improvements #2930
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.EnumerateFiles
three times...foreach
would 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
Inputs
andOutputs
would more appropriately be:This way, if
_ResolveLibraryProjectImports
runs 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.