Skip to content

perf: Improve xaml generator performance - #11074

Merged
jeromelaban merged 23 commits into
unoplatform:masterfrom
Youssef1313:gen-perf
Feb 22, 2023
Merged

jeromelaban merged 23 commits into
unoplatform:masterfrom
Youssef1313:gen-perf

Conversation

@Youssef1313

Copy link
Copy Markdown
Member

Previously, every run of the generator was collecting a dictionary of all symbols in compilation references. This is very expensive, and the generator is run on every change in the IDE. This is both slow and very memory consuming which can in turn cause high GC pause times.

PR Type

What kind of change does this PR introduce?

What is the current behavior?

What is the new behavior?

PR Checklist

Please check if your PR fulfills the following requirements:

Other information

Internal Issue (If applicable):

@github-actions github-actions Bot added the area/code-generation Categorizes an issue or PR as relevant to code generation label Jan 27, 2023
@Youssef1313
Youssef1313 marked this pull request as draft January 27, 2023 08:56
@Youssef1313
Youssef1313 force-pushed the gen-perf branch 7 times, most recently from 779bcca to 2ff36fa Compare January 27, 2023 16:45
@github-actions github-actions Bot added the area/automation Categorizes an issue or PR as relevant to project automation label Jan 27, 2023
@Youssef1313
Youssef1313 force-pushed the gen-perf branch 2 times, most recently from 9a6fe33 to cef959a Compare January 27, 2023 18:27
@unoplatform unoplatform deleted a comment from azure-pipelines Bot Jan 27, 2023
@Youssef1313
Youssef1313 force-pushed the gen-perf branch 5 times, most recently from e72662c to da3ac20 Compare January 28, 2023 16:10
@Youssef1313
Youssef1313 marked this pull request as ready for review January 28, 2023 19:19
@Youssef1313

Copy link
Copy Markdown
Member Author

@jeromelaban This is ready for review.

@Youssef1313 Youssef1313 mentioned this pull request Jan 29, 2023
10 of 12 tasks
@jeromelaban

Copy link
Copy Markdown
Member

This is unfortunately a large breaking change. There are some legacy codebases which rely on the use of fuzzy matching.

This may be a change that we can include in the next major breaking change pass.

That being said, the change about the Binding attribute may be included sooner, as it is not breaking.

@Youssef1313

Copy link
Copy Markdown
Member Author

I tried to reduce the impact of the breaking change by adding additional namespaces that are searched by default. We can also introduce an MSBuild property UnoXamlDefaultNamespaces to make it easier for developers to overcome the breaking change. So, if someone largely broke, they can add `CommaSeparatedNamespaces.

Alternatively, we can introduce a UnoEnableXamlFuzzyMatching property and document that it affects performance badly and that it will be removed in the next major release. This property will restore the fuzzy matching.

@Youssef1313

Copy link
Copy Markdown
Member Author

Also worth noting that code relying on this wouldn't compile on Windows.

@Youssef1313

Copy link
Copy Markdown
Member Author

Worth noting that the GC pause time I found was too large, and these allocations are the major contributor.

image

@jeromelaban

Copy link
Copy Markdown
Member

I don't mind if we introduce this breaking change in the next major, it's a good one. Introducing the msbuild property is a good idea, we'll make it enabled by default for 4.x, and mention that in the docs that devs will need to test it when moving to the later version.

@Youssef1313
Youssef1313 marked this pull request as ready for review February 8, 2023 14:54
@Youssef1313
Youssef1313 marked this pull request as draft February 8, 2023 20:45
@Youssef1313
Youssef1313 marked this pull request as ready for review February 8, 2023 20:45
@Youssef1313

Copy link
Copy Markdown
Member Author

Two different errors in CI. One that I cannot reproduce locally, and the other is because of incomplete IncludeXamlNamespaces/ExcludeXamlNamespaces in the outer build (not sure if that is the correct terminology, but I'm referring to the build that has all TFMs set but no specific TFM to be build, which at later point is dispatched to inner builds). The task runs on the build before it is dispatched so we don't (can't) have all xaml namespaces set. I'll update to rely on Ignorable as you suggested before @jeromelaban

Then will see if the error that I cannot reproduce locally will happen.

@Youssef1313 Youssef1313 mentioned this pull request Feb 18, 2023
6 tasks
@Youssef1313

Copy link
Copy Markdown
Member Author

Run Android UI Tests Android_9.0_Snapshots (NavigationView_MUXControlsTestApp_NavigationViewInfoBadgeTestPage) keeps failing even after restart. I'll see if re-running everything will work.

@Youssef1313

Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 2 pipeline(s).

@Youssef1313

Copy link
Copy Markdown
Member Author

@jeromelaban Finally, this is green now 🎉

Comment thread src/Directory.Build.props Resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/automation Categorizes an issue or PR as relevant to project automation area/code-generation Categorizes an issue or PR as relevant to code generation area/solution-templates Categorizes an issue or PR as relevant to the solution template kind/documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants