runtime: iOS/Catalyst build performance regression from net8.0 to net9.0
Description
There’s quite a noticeable decrease in performance building iOS and Catalyst apps:
dotnet build -bl:../net8.0-ios.binlog
Restore complete (0.5s)
MauiTestApp net8.0-ios succeeded (12.6s) → bin/Debug/net8.0-ios/iossimulator-arm64/MauiTestApp.dll
Build succeeded in 13.3s
dotnet build -bl:../net9.0-ios.binlog
Restore complete (0.4s)
MauiTestApp net9.0-ios succeeded (17.4s) → bin/Debug/net9.0-ios/iossimulator-arm64/MauiTestApp.dll
Build succeeded in 18.1s
The performance regresson is also present for maccatalyst
Steps to Reproduce
The problem is reproducible with a MAUI template project, changing the TFM between net8.0-ios and net9.0-ios
Link to public reproduction project repository
No response
Version with bug
9.0.10 SR1
Is this a regression from previous behavior?
Yes, this used to work in .NET MAUI
Last version that worked well
8.0.100 SR10
Affected platforms
iOS, macOS
Affected platform versions
No response
Did you find any workaround?
Roll back to dotnet 8
Relevant log output
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 4
- Comments: 23 (12 by maintainers)
Confirmed. Not only is the build regression fixed, the build is now faster than ever. Nice one, thanks!
Heads up – we’ve gained a better understanding of the regression and are working on a fix: https://github.com/dotnet/runtime/issues/110833. I’ll let you know once we have a PR ready.
That got changed here:
https://github.com/xamarin/xamarin-macios/pull/20936
with a follow up fix here:
https://github.com/xamarin/xamarin-macios/pull/20945
and a final fix here:
https://github.com/xamarin/xamarin-macios/pull/20953
so I’m a bit unsure as to exactly when it’s safe/correct to enable/disable dedup at this point.
That said, I have a tentative PR up to disable dedup if interpreting every assembly: https://github.com/xamarin/xamarin-macios/pull/21661.
The fix https://github.com/dotnet/runtime/pull/113316 has been included in the 9.0.4 servicing release.
@rolfbjarne That’s awesome, thanks. Maybe the conditions can be improved/tailored, but if it’s useful to anyone, I find the following gives a pretty decent productivity bump as a workaround until the above patch gets released.
<_IsDedupEnabled Condition="'$(Configuration)' == 'Debug'">false</_IsDedupEnabled>Struggling with the same issue on quite big project. Can’t share binlog, however I will paste suspicious fragments from it:
.net8 MtouchLink=SdkOnly, Target _AOTCompile took 7:27:062
.net9 MtouchLink=SdkOnly, Target _AOTCompile took 49:06.155
.net9 MtouchLink=Full, Target _AOTCompile took 1:48:586
Build time bloated a lot. Unfortunately the app is not ready to be fully linked, SdkOnly is the preferable option for us. Interpreter is turned off.
Fwiw, I got similar times on my m2 w/ what @rolfbjarne provided.
I’ve looked a bit into this, and this is what I’ve found so far:
The AOT compilation is also slower, but that shows up better in the next finding:
/p:UseInterpreter=false), we AOT much more code, and since the AOT compiler is also much slower, it has a much bigger effect:Timings for only the AOT compilation:
The resulting app bundle is also a bit bigger, but nothing that would explain the almost 3x difference in AOT compilation:
So it seems this is a runtime issue, so moving there.
M2 …