Skip to content

Add new Mono embedding API to consume binary runtimeconfig format#49740

Merged
fanyang-mono merged 19 commits into
dotnet:mainfrom
fanyang-mono:embedded_api
Mar 22, 2021
Merged

Add new Mono embedding API to consume binary runtimeconfig format#49740
fanyang-mono merged 19 commits into
dotnet:mainfrom
fanyang-mono:embedded_api

Conversation

@fanyang-mono

Copy link
Copy Markdown
Member

Fixes #49236

@ghost

ghost commented Mar 17, 2021

Copy link
Copy Markdown

Tagging subscribers to this area: @CoffeeFlux
See info in area-owners.md if you want to be subscribed.

Issue Details

Fixes #49236

Author: fanyang-mono
Assignees: -
Labels:

area-AssemblyLoader-mono

Milestone: -

@lambdageek lambdageek left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

  1. Use the mono-mmap functions to open the file - it can fall back to making a copy of the data, but it doesn't have to.
  2. Use the mono_metadata_decode_blob function to get the lengths.
  3. I don't think you should parse the file right away. Just save away the MonovmRuntimeConfigArguments and the cleanup function, and parse right in mono_runtime_install_appctx_properties when we have both sets of arguments and we can create a single set of arrays to pass to managed.

Comment thread src/mono/mono/mini/monovm.c Outdated
Comment thread src/mono/mono/mini/monovm.c Outdated
Comment thread src/mono/mono/mini/monovm.c Outdated
Comment thread src/mono/mono/mini/monovm.c Outdated
Comment thread src/mono/mono/mini/monovm.c Outdated
Comment thread src/mono/mono/mini/monovm.c Outdated
Comment thread src/mono/mono/mini/monovm.c Outdated
@fanyang-mono fanyang-mono requested a review from thaystg as a code owner March 18, 2021 18:41

@lambdageek lambdageek left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Great steps in the right direction.

I'm suspicious about g_new0 not doing the right thing - I suspect it's because you're accessing the monovm_initialize keys and values after that function has already returned. Unfortunately there's no avoiding making a copy of those since the caller of monovm_initiaze might free them.

Comment thread src/mono/mono/metadata/appdomain.c Outdated
Comment thread src/mono/mono/metadata/appdomain.c Outdated
Comment thread src/mono/mono/metadata/appdomain.c Outdated
Comment thread src/mono/mono/mini/monovm.c Outdated
Comment thread src/mono/mono/mini/monovm.c Outdated
Comment thread src/mono/mono/mini/monovm.c Outdated

@lambdageek lambdageek left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Keeps getting better. But let's keep going.

I sketched out how I think _install should look. monovm_runtimeconfig_initialize can be literally a 1 liner that just stores arg, cleanup_fn and user_data to mono_runtime_register_runtimeconfig_json_properties without doing anything to them.

Comment thread src/mono/mono/metadata/appdomain.c Outdated
Comment thread src/mono/mono/metadata/appdomain.c Outdated
Comment thread src/mono/mono/mini/monovm.c Outdated
Comment thread src/mono/mono/mini/monovm.c Outdated
Comment thread src/mono/mono/mini/monovm.c Outdated

@lambdageek lambdageek left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In general LGTM. Thanks @fanyang-mono !
I'll go through one more time in a couple of hours in detail, for any minor nits.

@lambdageek lambdageek left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ok, went through in detail. Couple of minor whitespace nits, but otherwise LGTM

Comment thread src/mono/mono/metadata/appdomain.c Outdated
Comment thread src/mono/mono/metadata/appdomain.c Outdated
Comment thread src/mono/mono/metadata/appdomain.c Outdated
Comment thread src/mono/mono/metadata/appdomain.c Outdated
Comment thread src/mono/mono/metadata/appdomain.c Outdated
Comment thread src/mono/mono/metadata/appdomain.c Outdated
Comment thread src/mono/mono/metadata/appdomain.c Outdated
Comment thread src/mono/mono/metadata/appdomain.c Outdated

@lewing lewing left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good, a couple of thoughts about simplifying things.

Comment thread src/mono/mono/metadata/appdomain.c

@CoffeeFlux CoffeeFlux left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Mix of nits and comments about unneeded strlen and strcpy calls. This is called during startup, so we really need to include as few of them as possible. Getting close though! 😄

Comment thread src/mono/mono/metadata/appdomain.c Outdated
Comment thread src/mono/mono/metadata/appdomain.c Outdated
Comment thread src/mono/mono/metadata/appdomain.c Outdated
Comment thread src/mono/mono/metadata/appdomain.c Outdated
Comment thread src/mono/mono/metadata/appdomain.c Outdated
Comment thread src/mono/mono/metadata/appdomain.c Outdated
Comment thread src/mono/mono/metadata/appdomain.c Outdated
Comment thread src/mono/mono/metadata/appdomain.c Outdated
Comment thread src/mono/mono/metadata/appdomain.c Outdated
Comment thread src/mono/mono/metadata/appdomain.c Outdated
fanyang-mono and others added 7 commits March 22, 2021 08:05
Co-authored-by: Aleksey Kliger (λgeek) <akliger@gmail.com>
Co-authored-by: Aleksey Kliger (λgeek) <akliger@gmail.com>
Co-authored-by: Aleksey Kliger (λgeek) <akliger@gmail.com>
Co-authored-by: Ryan Lucia <ryan@luciaonline.net>
Co-authored-by: Ryan Lucia <ryan@luciaonline.net>
Co-authored-by: Ryan Lucia <ryan@luciaonline.net>
Co-authored-by: Ryan Lucia <ryan@luciaonline.net>
fanyang-mono and others added 4 commits March 22, 2021 08:11
Co-authored-by: Ryan Lucia <ryan@luciaonline.net>
Co-authored-by: Ryan Lucia <ryan@luciaonline.net>
Co-authored-by: Ryan Lucia <ryan@luciaonline.net>
Comment thread src/mono/mono/metadata/appdomain.c Outdated

@CoffeeFlux CoffeeFlux left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just one nit, but otherwise should be good to go!.

Comment thread src/mono/mono/metadata/appdomain.c
Comment thread src/mono/mono/mini/mono-private-unstable.h Outdated
Co-authored-by: Ryan Lucia <ryan@luciaonline.net>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add new Mono embedding API to consume binary runtimeconfig format

5 participants