Closed newNcy closed 4 months ago
@simonrozsival as you've been looking into a similar area recently.
@simonrozsival Hi, any information you can share?
@newNcy Yes, the Mono AOT compiler can do exactly that. The MtouchInterpreter
property is not exclusive to MAUI, it can be used with any iOS .NET app.
@newNcy Yes, the Mono AOT compiler can do exactly that. The
MtouchInterpreter
property is not exclusive to MAUI, it can be used with any iOS .NET app.
Thanks ! Here are the things i have tried I made some changes to the project under runtime/src/mono/sample/ios
<MonoForceInterpreter> true</MonoForceInterpreter>
property<_InternalForceInterpret Condition="'$(MonoForceInterpreter)' == 'true' and '%(FileName)%(Extension)' ! = 'System.Private.CoreLib.dll'">true</_InternalForceInterpret>
Added Program.dll here.
When I run make run, the speed of the program is exactly the same as without Program.dll.Am I missing something or how do I use Mtouchinterpereter in this sample?
Ah, ok, you are using mono from the runtime directly. I thought you were using the iOS SDK, just without MAUI. The MtouchInterpreter
property is defined in the xamarin/xamarin-macios repo and so you can't use it just with the runtime.
@kotlarmilos do you know how to configure the AOT compiler in the iOS sample to AOT some assemblies and interpret the rest?
Actully im not sure what sdk i should use, my scenario is to run c#(mono) runtime in cpp, and exec the assemblies which contains som downloaded from network and cant be updated without update the ios app
@kotlarmilos need some help here
The runtime pipeline supports two modes: Full and JustInterp. In Full mode, it AOT compiles all assemblies. In JustInterp mode, only the wrappers and trampolines in System.Private.CoreLib.dll are AOT compiled. This enables interpreter to execute managed methods and P/Invokes for unmanaged callbacks.
Your code in Program.dll likely doesn't contain wrappers and trampolines, which could explain the performance issue. Do you have a specific use-case that require partial AOT compilation?
The runtime pipeline supports two modes: Full and JustInterp. In Full mode, it AOT compiles all assemblies. In JustInterp mode, only the wrappers and trampolines in System.Private.CoreLib.dll are AOT compiled. This enables interpreter to execute managed methods and P/Invokes for unmanaged callbacks.
Your code in Program.dll likely doesn't contain wrappers and trampolines, which could explain the performance issue. Do you have a specific use-case that require partial AOT compilation?
yup, we plan to use c# as gameplay dev language, and support hotfix on ios, some dll like core library we can accept not to hotfix, and the rest part we need to hotfix, but seems like full aot counld not hotfix cause it requires static-linking
Partial AOT compilation is available in Maui framework. The runtime infrastructure is designed primarily for testing purposes and is not intended for the deployment of customer-facing apps. Do you have some limitations with Maui framework?
@kotlarmilos if I understand it correctly they are embedding mono in their game so they can't even use MAUI. Should this be achievable by some combination of flags passed to the AOT compiler?
In this case, we can update our infrastructure to support partial AOT compilation. The MonoAOTCompiler task is already parametrized with Mode
property, and the FullInterp
mode could be added.
In this case, we can update our infrastructure to support partial AOT compilation. The MonoAOTCompiler task is already parametrized with
Mode
property, and theFullInterp
mode could be added.
yes we are embedding mono so we cant use MAUI and I have tried the FulInterp mode and it works . thx! So will this be done in AppleBuild.targets or i need to do it my self?
Do you use runtime infrastructure (MonoAOTCompiler and AppleBuild.targets) for publishing?
Do you use runtime infrastructure (MonoAOTCompiler and AppleBuild.targets) for publishing?
Maybe not, if we can do it with daily build. use it for prototype testing now
In this case, we can update our infrastructure to support partial AOT compilation. The MonoAOTCompiler task is already parametrized with
Mode
property, and theFullInterp
mode could be added.
can i use this in mono wasi-wasm? how to pass params to mono-aot-compiler
@lewing not sure I have the necessary knowledge to answer the wasi-wasm part of this question, maybe you'll be able to answer.
I checked the runtime.c to compile wasi-wasm, found out that only have LLVMONLY/LLVMONLY_INTERP aot mode , but llvm aot can't excluse assembly, is it possible to change to FullInterp + MONO_AOT_MODE_INTERP ? @lewing
how to pass params to mono-aot-compiler
To run FullInterp
mode, the AOT compiler expects --aot=full,interp
flags At runtime, the --full-aot-interp
mono env variable is used.
The AppleAppBuilder
is already parametrized and the AppleBuild.targets
can be changed to enable this mode. The new mode can be added in:
https://github.com/dotnet/runtime/blob/b42c51612c3c0cadf0b0a52fa0ac8f5f1532e6be/src/mono/msbuild/apple/build/AppleBuild.targets#L147-L150
Then, _AssembliesToBundleInternal
can be updated to include specific assemblies in:
https://github.com/dotnet/runtime/blob/b42c51612c3c0cadf0b0a52fa0ac8f5f1532e6be/src/mono/msbuild/apple/build/AppleBuild.targets#L187-L202
how to pass params to mono-aot-compiler
To run
FullInterp
mode, the AOT compiler expects--aot=full,interp
flags At runtime, the--full-aot-interp
mono env variable is used.The
AppleAppBuilder
is already parametrized and theAppleBuild.targets
can be changed to enable this mode. The new mode can be added in:Then,
_AssembliesToBundleInternal
can be updated to include specific assemblies in:
thx! Does this work with native aot? A.dll native AOT static linking with executable and the rest DLL will be interpreted
Does this work with native aot? A.dll native AOT static linking with executable and the rest DLL will be interpreted
The Native AOT does full program analysis and doesn't have partial AOT mode. Please note that it doesn't expose the same API as Mono runtime which may be a limitation in embedded scenarios.
This issue hasn't been active for a while. I'm closing it now. Please reopen it if you feel more input is needed.
In the mono ios example, I noticed that with thetag can configure how mono runtime runs and how assembly compiles, is it possible to specify some dll for aot compile and the rest for interpreted? And i found that in MAUI we can use MtouchInterpreter to do that