I know that there\'s support for AOT in Xamarin for Android. After the software became free, all of its features became free as well. I read around the documentation and I enabl
AOT'ing your assemblies/code is not going to change the startup of the app's initialization (native app bootstrap + Xamarin/Mono initialization BUT not including any of your code execution time).
Now, if you are doing X amount of work that is CPU bound within your code, say within the OnCreate
(which you really should not be doing), you would (should) see a decrease in total time. I say should due to the fact that AOT'ing does not guarantee that you will see a faster execution time of a particular portion of code, it does eliminates the jitter, but there are lots of other factors involved. I've been using Mono (AOT w/ & w/o LLVM) for many years and you really need to instrument and test on your code.
Although the JIT mode is very fast, and the default optimizations in Mono have been tuned to provide a good balance between optimizations and JIT speed, AOT compilation provides a few extra benefits:
- Reduced startup time.
Note: This is particularly useful for large programs that might need to execute a lot of code before they are operational...
- Potential better performance.
Note: ....This means that certain programs might run slower as the generated code is more general than the specific code that the JIT can produce.
Ref: http://www.mono-project.com/docs/advanced/aot/
In terms of optimization of AOT code, enable LLVM along with AOT in your release builds for performance/instrumentation testing. Note: Testing is key, having a complete app test suite and internal instrumentation for collecting runtime performance is key to getting those 5 stars reviews on the app stores ;-)
EnableLLVM
A boolean property that determines whether or not LLVM will be used when Ahead-of-Time compiling assemblines into native code. Support for this property was added in Xamarin.Android 5.1.
This property is False by default.
This property is ignored unless the $(AotAssemblies) MSBuild property is True.
AotAssemblies
A boolean property that determines whether or not assemblies will be Ahead-of-Time compiled into native code and included in the .apk. Support for this property was added in Xamarin.Android 5.1.
This property is False by default.
Coincidence or not, when I added <AotAssemblies>True</AotAssemblies>
to <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
section of the android .csproj my startup times were reduced from 10 seconds to 4 seconds! Then I removed the AotAssemblies and tried again and I have 10 seconds again, so the AotAssemblies does something :)