Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes: #11885 Looking at the JITStats report in PerfView (for MSBuild.exe): | Name | JitTime (ms) | | --- | --: | | Microsoft.Maui.Controls.Build.Tasks.dll | 214.0 | | Mono.Cecil | 119.0 | It appears that `Microsoft.Maui.Controls.Build.Tasks.dll` spends a lot of time in the JIT. What is confusing, is this was an incremental build where everything should already be loaded. The JIT's work should be done already? I don't see the same behavior for Android MSBuild tasks or Windows App SDK tasks. The cause appears to be usage of `[LoadInSeparateAppDomain]` in .NET MAUI. However, we can't just *remove this* as there would be complications... `[LoadInSeparateAppDomain]` also conveniently resets all `static` state when `<XamlCTask/>` runs again. Meaning that future incremental builds would potentially use old (garbage) values. There are several places that cache Mono.Cecil objects for performance reasons. Really weird bugs would result if we didn't address this. To make things correct *and* remove `[LoadInSeparateAppDomain]`: * Move all `static` state to a `XamlCache` class as instance values. * Each `ILContext` has an instance of `XamlCache`. * Any child `ILContext`'s such as with `DataTemplate` are passed the parent's `XamlCache`. * Various `static` extension methods now require a `XamlCache` to be passed in. This allows unit tests to do this as well. * Other `*Visitor` or `*Converter` types have an instance of `ILContext`, so they can access `ILContext.Cache` as needed. Unfortunately, I had to make small changes to lots of lines for this. Testing these changes inside Visual Studio with a `dotnet new maui` project template: Before: XamlCTask = 743 ms XamlCTask = 706 ms XamlCTask = 692 ms After: XamlCTask = 128 ms XamlCTask = 134 ms XamlCTask = 117 ms This saves about ~587ms on incremental builds on all platforms, an 82% improvement. This will help even more on large solutions with multiple .NET MAUI projects, where `<XamlCTask/>` runs multiple times.
- Loading branch information
1 parent
44575de
commit 73a06de
Showing
54 changed files
with
651 additions
and
635 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.