Commit 728e4ea
committed
[Xamarin.Android.Build.Tasks] delay ToJniName calls in ManifestDocument (#7653)
Reviewing `dotnet trace` output for a `dotnet new maui` app:
dotnet trace collect --format speedscope -- .\bin\Release\dotnet\dotnet.exe build -bl --no-restore foo.csproj
8.6% of the time in `<GenerateJavaStubs/>` is spent in:
93.81ms xamarin.android.build.tasks!Xamarin.Android.Tasks.ManifestDocument.Merge(...)
Drilling down further, a lot of time is spent in:
26.91ms java.interop.tools.javacallablewrappers!Java.Interop.Tools.TypeNameMappings.JavaNativeTypeManager.ToJniName(...)
4.03ms java.interop.tools.javacallablewrappers!Java.Interop.Tools.TypeNameMappings.JavaNativeTypeManager.ToCompatJniName(...)
It looks like we call this code for *every* Java.Lang.Object subclass:
var name = JavaNativeTypeManager.ToJniName (t, cache).Replace ('/', '.');
var compatName = JavaNativeTypeManager.ToCompatJniName (t, cache).Replace ('/', '.');
if (((string) app.Attribute (attName)) == compatName) {
app.SetAttributeValue (attName, name);
}
It looks like this code was originally here to solve a problem with
`Android.App.Application` classes that are missing an `[Application]`
attribute:
xamarin/monodroid@2a668b7
To improve this:
1. First check if we are a `Android.App.Application`, apply the above
fixup and `continue`.
2. Find out if we are other types of interesting subclasses, where a
`generator` is needed. `continue` otherwise.
3. Lastly, compute `name` & `compatName`. We are no longer doing this
work for every type.
After these changes, I instead get:
72.84ms xamarin.android.build.tasks!Xamarin.Android.Tasks.ManifestDocument.Merge(...)
This saves about ~21ms on incremental builds of `dotnet new maui`
projects.1 parent 0a58977 commit 728e4ea
File tree
1 file changed
+12
-4
lines changed- src/Xamarin.Android.Build.Tasks/Utilities
1 file changed
+12
-4
lines changedLines changed: 12 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
336 | 336 | | |
337 | 337 | | |
338 | 338 | | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
343 | 345 | | |
344 | 346 | | |
345 | 347 | | |
346 | 348 | | |
347 | 349 | | |
348 | 350 | | |
349 | 351 | | |
| 352 | + | |
350 | 353 | | |
351 | 354 | | |
352 | 355 | | |
| |||
481 | 484 | | |
482 | 485 | | |
483 | 486 | | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
484 | 492 | | |
485 | 493 | | |
486 | 494 | | |
| |||
0 commit comments