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

[xamlc] return early in NodeILExtensions for ValidateOnly #24493

Merged
merged 1 commit into from
Sep 10, 2024

Conversation

jonathanpeppers
Copy link
Member

Context: 7efca8e
Context: xamarin/Xamarin.Forms#7407

For Debug builds, .NET MAUI runs XamlC in a "ValidateOnly" mode, which avoids writing .dll files at the end. This way, we get faster builds, but still emit the same errors and warnings that would be emitted in Release mode.

Right now, the ValidateOnly flag is only checked at the end of the process to skip writing files. I looked for some places taking time, such as:

36.30ms (1.1%) microsoft.maui.controls.build.tasks!Microsoft.Maui.Controls.Build.Tasks.NodeILExtensions+<PushServiceProvider>d__12.MoveNext()
20.20ms (0.6%) microsoft.maui.controls.build.tasks!Microsoft.Maui.Controls.Build.Tasks.NodeILExtensions+<PushParentObjectsArray>d__9.MoveNext()
 1.21ms (0.0%) microsoft.maui.controls.build.tasks!Microsoft.Maui.Controls.Build.Tasks.NodeILExtensions.PushXmlLineInfo(class Microsoft.Maui.Controls.Xaml.INode,class Microsoft.Maui.Controls.Build.Tasks.ILContext)

And added checks to just return early in these methods.

With this change in-place, an incremental build of a dotnet new maui project template:

Before:
1704 ms  XamlCTask                                  4 calls
After:
1402 ms  XamlCTask                                  4 calls

This probably saves a little less than 100ms per call, but in this example it is running once per platform. This improvement probably will help even more for larger projects with many XAML files.

Context: dotnet@7efca8e
Context: xamarin/Xamarin.Forms#7407

For Debug builds, .NET MAUI runs XamlC in a "ValidateOnly" mode, which
avoids writing `.dll` files at the end. This way, we get faster
builds, but still emit the same errors and warnings that would be
emitted in `Release` mode.

Right now, the `ValidateOnly` flag is only checked at the end of the
process to skip writing files. I looked for some places taking time,
such as:

    36.30ms (1.1%) microsoft.maui.controls.build.tasks!Microsoft.Maui.Controls.Build.Tasks.NodeILExtensions+<PushServiceProvider>d__12.MoveNext()
    20.20ms (0.6%) microsoft.maui.controls.build.tasks!Microsoft.Maui.Controls.Build.Tasks.NodeILExtensions+<PushParentObjectsArray>d__9.MoveNext()
     1.21ms (0.0%) microsoft.maui.controls.build.tasks!Microsoft.Maui.Controls.Build.Tasks.NodeILExtensions.PushXmlLineInfo(class Microsoft.Maui.Controls.Xaml.INode,class Microsoft.Maui.Controls.Build.Tasks.ILContext)

And added checks to just return early in these methods.

With this change in-place, an incremental build of a `dotnet new maui`
project template:

    Before:
    1704 ms  XamlCTask                                  4 calls
    After:
    1402 ms  XamlCTask                                  4 calls

This probably saves a little less than 100ms per call, but in this
example it is running once per platform. This improvement probably
will help even more for larger projects with many XAML files.
@jonathanpeppers jonathanpeppers added the area-xaml XAML, CSS, Triggers, Behaviors label Aug 28, 2024
@jonathanpeppers jonathanpeppers marked this pull request as ready for review August 28, 2024 21:48
@jonathanpeppers jonathanpeppers requested a review from a team as a code owner August 28, 2024 21:48
@rmarinho rmarinho merged commit f7574dd into dotnet:main Sep 10, 2024
95 of 97 checks passed
@jonathanpeppers jonathanpeppers deleted the XamlCValidateOnly branch September 10, 2024 13:44
@samhouts samhouts added the fixed-in-net9.0-nightly This may be available in a nightly release! label Oct 1, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Nov 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-xaml XAML, CSS, Triggers, Behaviors fixed-in-net9.0-nightly This may be available in a nightly release!
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants