Open jonathanpeppers opened 3 weeks ago
If we got this working, it would probably solve:
After some conversation, it may be more appropriate for Android to use $(AndroidAotMode)=hybrid
anyway. We don't really want people to have to opt into the interpreter, if the JIT can be available.
Some conversation here:
Of course, the drawback to using hybrid
is app size!
Summary:
+ 0 Other entries 0.00% (of 2,858,353)
+ 0 Dalvik executables 0.00% (of 15,406,204)
+ 43,171,232 Shared libraries 235.64% (of 18,320,632)
+ 10,569,349 Package size difference 63.65% (of 16,604,909)
Startup time was also either slightly worse (or the same, within margin of error), when using $(AndroidAotMode)=hybrid
. It could likely be due to the larger files being loaded at startup. This diminishes the usefulness of the feature.
I would rather prefer to have an opportunity to opt into the interpreter on Android - all depends on whether it's faster than JIT specifically on app startup. And if we assume Profiled AOT works (ok, currently it doesn't, but maybe you'll end up fixing this), the % of methods to interpret should be relatively small.
I would rather prefer to have an opportunity to opt into the interpreter on Android
@alexyakunin this feels a bit off-topic, but you can do this today in a Release
build with:
<PropertyGroup>
<RunAOTCompilation>false</RunAOTCompilation>
<UseInterpreter>true</UseInterpreter>
</PropertyGroup>
But I suspect you will see worse performance with this combination. Startup might be OK, but as soon as there is a complicated for
-loop, it will perform much slower even than JIT. Additionally, features like hardware intrinsics won't work.
There is no combination of "Normal" AOT mode with interpreter:
We are consumers of the runtime, so we can only use what they provide.
But I suspect you will see worse performance with this combination.
Yes, it is - we tried this option. As far as I remember, it's worse on Android vs even JIT w/o AOT.
We are consumers of the runtime, so we can only use what they provide.
@jonathanpeppers What about MONO_AOT_MODE_INTERP
and its variants? At glance, it looks like AOT w/o JIT.
It looks like MONO_AOT_MODE_INTERP
is AOT with Interpreter fallback. I discussed in a meeting today, we want to try it out, there are some changes required for it to work.
We'd need to update:
Build time:
Runtime:
I got an impression iOS uses these modes, + yeah, there is an incompatibility (well, only partial compatibility) between the modes available in Mono runtime & modes you can specify in Android .targets.
Android framework version
net9.0-android
Affected platform version
.NET 9 RC 2
Description
I was trying to enable "full AOT" and disable JIT on Android:
dotnet new maui
- remove the other platforms beside Androiddotnet build build -c Release -p:AndroidAotMode=full -p:AndroidEnableProfiledAot=false -p:RunAOTCompilation=true -r android-arm64 -bl -t:Run
This should "AOT everything" and also toggle
MONO_AOT_MODE_FULL
at runtime.This appears to pass the right flags to the
<MonoAOTCompiler/>
task:And at runtime:
https://github.com/dotnet/android/blob/aa668a5c746a7669a145e63efe59d0964093e604/src/native/monodroid/monodroid-glue.cc#L1479
But then the JIT is still used and we crash:
Perhaps it fails on the first generic method?
Steps to Reproduce
See above.
Did you find any workaround?
No.
Relevant log output
aot-mode-full.txt