-
Notifications
You must be signed in to change notification settings - Fork 564
[Xamarin.Android.Build.Tasks] <FilterAssemblies/> in-memory cache #4975
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
Merged
jonathanpeppers
merged 1 commit into
dotnet:master
from
jonathanpeppers:filterassemblies-inmemory
Aug 5, 2020
Merged
[Xamarin.Android.Build.Tasks] <FilterAssemblies/> in-memory cache #4975
jonathanpeppers
merged 1 commit into
dotnet:master
from
jonathanpeppers:filterassemblies-inmemory
Aug 5, 2020
Conversation
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
dellis1972
approved these changes
Aug 4, 2020
In a customer's build log, a large solution build with no changes had:
1956 ms FilterAssemblies 18 calls
The `<FilterAssemblies/>` MSBuild task runs on every build for class
libraries and application projects. It looks at assemblies to classify
them as a "MonoAndroid" assembly.
Since we are already using System.Reflection.Metadata to open each
assembly, we can use each assembly's MVID and `RegisterTaskObject` to
skip future calls to the same assembly. This will be helpful in
incremental builds in the IDE, as well as, large solutions that
encounter the same assemblies throughout a build.
Using the in-memory cache, we don't need to check any file timestamps.
Unique MVIDs will yield the same result for the `<FilterAssemblies/>`
task -- regardless if the assembly was built with `$(Deterministic)`
or not.
~~ Results ~~
I did not have access to the original customer project, so I tested
this change using xamarin/Xamarin.Forms@d9926450 instead. There
are 8 Xamarin.Android projects during the build.
Before:
165 ms FilterAssemblies 16 calls
After:
156 ms FilterAssemblies 16 calls
After (with MSBuild node running):
99 ms FilterAssemblies 16 calls
Even on the first build, many assemblies are pulled from the cache. It
printed ~326 instances of this log message:
Task "FilterAssemblies"
...
Cached: C:\src\Xamarin.Forms\Xamarin.Forms.Platform.Android.FormsViewGroup\bin\Release\FormsViewGroup.dll
This saves ~10ms from an initial build of Xamarin.Forms' source and
~66ms from incremental builds. This will have a bigger impact on
larger solutions.
~~ Other changes ~~
I removed an unused `DesignTimeBuild` property from
`<FilterAssemblies/>`.
I removed the log message:
// In the rare case, [assembly: TargetFramework("MonoAndroid,Version=v9.0")] may not match
Log.LogDebugMessage ($"{nameof (TargetFrameworkIdentifier)} did not match: {assemblyItem.ItemSpec}");
It is actually not a "rare" case, it was printed 330 times from the
customer's log. This log message didn't add much value, so I removed
it to reduce string allocations.
2e021be to
51c7eb5
Compare
Member
Author
dellis1972
approved these changes
Aug 5, 2020
jonpryor
pushed a commit
that referenced
this pull request
Aug 10, 2020
) In a customer's build log, a large solution build with no changes had: 1956 ms FilterAssemblies 18 calls The `<FilterAssemblies/>` MSBuild task runs on every build for class libraries and application projects. It looks at assemblies to classify them as a "MonoAndroid" assembly. Since we are already using System.Reflection.Metadata to open each assembly, we can use each assembly's MVID and `RegisterTaskObject` to skip future calls to the same assembly. This will be helpful in incremental builds in the IDE, as well as, large solutions that encounter the same assemblies throughout a build. Using the in-memory cache, we don't need to check any file timestamps. Unique MVIDs will yield the same result for the `<FilterAssemblies/>` task -- regardless if the assembly was built with `$(Deterministic)` or not. ~~ Results ~~ I did not have access to the original customer project, so I tested this change using xamarin/Xamarin.Forms@d9926450 instead. There are 8 Xamarin.Android projects during the build. Before: 165 ms FilterAssemblies 16 calls After: 156 ms FilterAssemblies 16 calls After (with MSBuild node running): 99 ms FilterAssemblies 16 calls Even on the first build, many assemblies are pulled from the cache. It printed ~326 instances of this log message: Task "FilterAssemblies" ... Cached: C:\src\Xamarin.Forms\Xamarin.Forms.Platform.Android.FormsViewGroup\bin\Release\FormsViewGroup.dll This saves ~10ms from an initial build of Xamarin.Forms' source and ~66ms from incremental builds. This will have a bigger impact on larger solutions. ~~ Other changes ~~ I removed an unused `DesignTimeBuild` property from `<FilterAssemblies/>`. I removed the log message: // In the rare case, [assembly: TargetFramework("MonoAndroid,Version=v9.0")] may not match Log.LogDebugMessage ($"{nameof (TargetFrameworkIdentifier)} did not match: {assemblyItem.ItemSpec}"); It is actually not a "rare" case, it was printed 330 times from the customer's log. This log message didn't add much value, so I removed it to reduce string allocations.
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.

In a customer's build log, a large solution build with no changes had:
The
<FilterAssemblies/>MSBuild task runs on every build for classlibraries and application projects. It looks at assemblies to classify
them as a "MonoAndroid" assembly.
Since we are already using System.Reflection.Metadata to open each
assembly, we can use each assembly's MVID and
RegisterTaskObjecttoskip future calls to the same assembly. This will be helpful in
incremental builds in the IDE, as well as, large solutions that
encounter the same assemblies throughout a build.
Using the in-memory cache, we don't need to check any file timestamps.
Unique MVIDs will yield the same result for the
<FilterAssemblies/>task -- regardless if the assembly was built with
$(Deterministic)or not.
Results
I did not have access to the original customer project, so I tested
this change using xamarin/Xamarin.Forms@d9926450 instead. There
are 8 Xamarin.Android projects during the build.
Even on the first build, many assemblies are pulled from the cache. It
printed ~326 instances of this log message:
This saves ~10ms from an initial build of Xamarin.Forms' source and
~66ms from incremental builds. This will have a bigger impact on
larger solutions.
Other changes
I removed an unused
DesignTimeBuildproperty from<FilterAssemblies/>.I removed the log message:
It is actually not a "rare" case, it was printed 330 times from the
customer's log. This log message didn't add much value, so I removed
it to reduce string allocations.