Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a --aot-lazy-assembly-load command line option to load assemblies… #67024

Merged
merged 2 commits into from
Mar 24, 2022

Conversation

vargaz
Copy link
Contributor

@vargaz vargaz commented Mar 23, 2022

… referenced by AOT images lazily.

Note that if this is enabled, and a referenced assembly is not found or its not
the exact version used to AOT the referencing assembly, the runtime will abort
because these kinds of errors can only be handled when loading the AOT image,
not later.

@vargaz
Copy link
Contributor Author

vargaz commented Mar 23, 2022

#66361

@vargaz
Copy link
Contributor Author

vargaz commented Mar 23, 2022

This option can either be set on the command line, or from C code before
the runtime is initialized:

extern gboolean mono_opt_aot_lazy_assembly_load;

mono_opt_aot_lazy_assembly_load = TRUE;

@radical
Copy link
Member

radical commented Mar 23, 2022

This option can either be set on the command line, or from C code before the runtime is initialized:

extern gboolean mono_opt_aot_lazy_assembly_load;

mono_opt_aot_lazy_assembly_load = TRUE;

Does this need to be documented anywhere?

nvm that!
Will this be usable, and useful for wasm too? cc @lewing

@lambdageek lambdageek added the tenet-performance Performance related issue label Mar 23, 2022
lambdageek
lambdageek previously approved these changes Mar 23, 2022
@lambdageek
Copy link
Member

/backport to release/6.0

@github-actions
Copy link
Contributor

Started backporting to release/6.0: https://github.com/dotnet/runtime/actions/runs/2028463178

@github-actions
Copy link
Contributor

@lambdageek backporting to release/6.0 failed, the patch most likely resulted in conflicts:

$ git am --3way --ignore-whitespace --keep-non-patch changes.patch

Applying: Add a --aot-lazy-assembly-load command line option to load assemblies referenced by AOT images lazily.
Using index info to reconstruct a base tree...
M	src/mono/mono/mini/aot-runtime.c
M	src/mono/mono/utils/options-def.h
Falling back to patching base and 3-way merge...
Auto-merging src/mono/mono/utils/options-def.h
CONFLICT (content): Merge conflict in src/mono/mono/utils/options-def.h
Auto-merging src/mono/mono/mini/aot-runtime.c
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Add a --aot-lazy-assembly-load command line option to load assemblies referenced by AOT images lazily.
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Error: The process '/usr/bin/git' failed with exit code 128

Please backport manually!

@lambdageek lambdageek dismissed their stale review March 23, 2022 13:07

Might need some more work

@lambdageek
Copy link
Member

lambdageek commented Mar 23, 2022

@vargaz these options are a little bit difficult for embedders to use - mono_options_parse_options isn't called from mono_jit_parse_options() or read from MONO_ENV_OPTIONS.

Here's how XA does it now: https://github.com/xamarin/xamarin-android/blob/169838082a55f8a280d4179ca3a12f852ef6002c/src/monodroid/jni/monodroid-glue.cc#L835

@steveisok is there some way to pass options to our Android template? It would be nice if we could modify one of the functional tests to use this https://github.com/dotnet/runtime/tree/main/src/tests/FunctionalTests/Android/Device_Emulator

@steveisok
Copy link
Member

@steveisok is there some way to pass options to our Android template? It would be nice if we could modify one of the functional tests to use this https://github.com/dotnet/runtime/tree/main/src/tests/FunctionalTests/Android/Device_Emulator

We'd have to tweak a few things, but it shouldn't be too difficult.

@vargaz
Copy link
Contributor Author

vargaz commented Mar 23, 2022

@vargaz these options are a little bit difficult for embedders to use - mono_options_parse_options isn't called from mono_jit_parse_options() or read from MONO_ENV_OPTIONS.

Will fix that. I think it is parsed when parsing MONO_ENV_OPTIONS.

@vargaz
Copy link
Contributor Author

vargaz commented Mar 23, 2022

Also, options.h could become part of the embedding api in the future if the api looks ok.

… referenced by AOT images lazily.

Note that this requires the assemblies used at AOT time to exactly match
the assemblies loaded at runtime, otherwise the runtime will abort
when it loads the mismatching reference.
@@ -58,6 +58,7 @@ DEFINE_BOOL_READONLY(readonly_flag, "readonly-flag", FALSE, "Example")
*/

DEFINE_BOOL(wasm_exceptions, "wasm-exceptions", FALSE, "Enable codegen for wasm exceptions")
DEFINE_BOOL(aot_lazy_assembly_load, "aot-lazy-assembly-load", FALSE, "Load assemblies referenced by AOT images lazily")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we make the default true for HOST_ANDROID, HOST_WASM, HOST_DARWIN && !HOST_OSX?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think platforms should set it themselves.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe we can set it in the runtime startup code.

@vargaz vargaz merged commit 0e1c91b into dotnet:main Mar 24, 2022
@vargaz vargaz deleted the aot-lazy-assembly-load branch March 24, 2022 00:45
@eerhardt
Copy link
Member

Have we tried using this on Maui Android and gotten any before/after startup perf numbers?

@lambdageek
Copy link
Member

Have we tried using this on Maui Android and gotten any before/after startup perf numbers?

@eerhardt we haven't tried

lambdageek pushed a commit to lambdageek/runtime that referenced this pull request Mar 24, 2022
dotnet#67024)

* Add a --aot-lazy-assembly-load command line option to load assemblies referenced by AOT images lazily.

Note that this requires the assemblies used at AOT time to exactly match
the assemblies loaded at runtime, otherwise the runtime will abort
when it loads the mismatching reference.

* Handle the options added by options.h in mono_jit_parse_options ().
radekdoulik pushed a commit to radekdoulik/runtime that referenced this pull request Mar 30, 2022
dotnet#67024)

* Add a --aot-lazy-assembly-load command line option to load assemblies referenced by AOT images lazily.

Note that this requires the assemblies used at AOT time to exactly match
the assemblies loaded at runtime, otherwise the runtime will abort
when it loads the mismatching reference.

* Handle the options added by options.h in mono_jit_parse_options ().
carlossanlop pushed a commit that referenced this pull request Apr 13, 2022
#67024) (#67103)

* Add a --aot-lazy-assembly-load command line option to load assemblies referenced by AOT images lazily.

Note that this requires the assemblies used at AOT time to exactly match
the assemblies loaded at runtime, otherwise the runtime will abort
when it loads the mismatching reference.

* Handle the options added by options.h in mono_jit_parse_options ().

Co-authored-by: Zoltan Varga <vargaz@gmail.com>
grendello added a commit to grendello/xamarin-android that referenced this pull request Apr 19, 2022
Fixes: dotnet#6935
Context: dotnet/runtime#67024

Add support for enabling lazy loading of AOTd assemblies and their
associated shared libraries, when targetting .NET6+.

The feature is enabled by default when AOT is enabled for `Release`
builds and can be disabled by setting the new
`$(AndroidAotEnableLazyLoad)` MSBuild property to `false`.
grendello added a commit to grendello/xamarin-android that referenced this pull request Apr 22, 2022
Fixes: dotnet#6935
Context: dotnet/runtime#67024

Add support for enabling lazy loading of AOTd assemblies and their
associated shared libraries, when targetting .NET6+.

The feature is enabled by default when AOT is enabled for `Release`
builds and can be disabled by setting the new
`$(AndroidAotEnableLazyLoad)` MSBuild property to `false`.
grendello added a commit to grendello/xamarin-android that referenced this pull request Apr 22, 2022
Fixes: dotnet#6935
Context: dotnet/runtime#67024

Add support for enabling lazy loading of AOTd assemblies and their
associated shared libraries, when targetting .NET6+.

The feature is enabled by default when AOT is enabled for `Release`
builds and can be disabled by setting the new
`$(AndroidAotEnableLazyLoad)` MSBuild property to `false`.
@ghost ghost locked as resolved and limited conversation to collaborators Apr 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants