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 ModuleDefinition.ImmediateRead #713

Merged
merged 1 commit into from
Feb 12, 2021

Conversation

mrvoorhe
Copy link
Contributor

We are going to use this to do a multi stage load in parallel. We will be able to greatly reduce our load times using this new API. The way it's going to work is

Stage 1 - In parallel, load the assemblies with ReadingMode.Deferred.
Stage 2 - Populate our AssemblyResolver with a cache of all read assemblies.
Stage 3 - In parallel, call ImmediateRead.

What I really want is an API to load everything in stage 3. I found that ImmediateRead does not load method bodies. I don't know if/how you want want something like this exposed via the public API. For now I'm iterating the data model and forcing things to load that ImmediateRead did not cover.

@@ -166,6 +166,7 @@ protected override void ReadModule ()

public void ReadModule (ModuleDefinition module, bool resolve_attributes)
{
module.ReadingMode = ReadingMode.Immediate;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jbevain You didn't include this in the changes you sent to me. I added this for 2 reasons.

  1. It seemed like the easiest way to write a test that meant something.

  2. I saw some other behaviors such as writing and symbol reading checked the reading mode. It seemed like it would be better if the reading mode was updated. However, I'm not certain this is correct. Does this seem sensible to you?

Copy link
Owner

Choose a reason for hiding this comment

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

I say just move this to ImmediateRead ()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@mrvoorhe
Copy link
Contributor Author

mrvoorhe commented Feb 4, 2021

@jbevain Can you take a look?

@mrvoorhe
Copy link
Contributor Author

I updated the PR to more sensibly handle a module with no image. Now ImmediateRead will do nothing if there was no image. Previously it would throw.

@mrvoorhe
Copy link
Contributor Author

@jbevain Does this seem like a change you'd be willing to take?

{
using (var module = GetResourceModule ("hello.exe", ReadingMode.Deferred)) {
Assert.AreEqual (ReadingMode.Deferred, module.ReadingMode);
module.ImmediateRead();
Copy link
Owner

Choose a reason for hiding this comment

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

Missing a space before the opening (

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@jbevain
Copy link
Owner

jbevain commented Feb 11, 2021

Thanks Mike, please just address the two tidbits and that's good to go!

We are going to use this to do a multi stage load in parallel.  We will be able to greatly reduce our load times using this new API.  The way it's going to work is

Stage 1 - In parallel, load the assemblies with ReadingMode.Deferred.
Stage 2 - Populate our AssemblyResolver with a cache of all read assemblies.
Stage 3 - In parallel, call ImmediateRead.

What I really want is an API to load everything in stage 3.  I found that ImmediateRead does not load method bodies.  I don't know if/how you want want something like this exposed via the public API.  For now I'm iterating the data model and forcing things to load that ImmediateRead did not cover.
@jbevain jbevain merged commit 3c4ea3f into jbevain:master Feb 12, 2021
@jbevain
Copy link
Owner

jbevain commented Feb 12, 2021

Thanks Mike!

mrvoorhe added a commit to Unity-Technologies/cecil that referenced this pull request Apr 14, 2021
We are going to use this to do a multi stage load in parallel.  We will be able to greatly reduce our load times using this new API.  The way it's going to work is

Stage 1 - In parallel, load the assemblies with ReadingMode.Deferred.
Stage 2 - Populate our AssemblyResolver with a cache of all read assemblies.
Stage 3 - In parallel, call ImmediateRead.

What I really want is an API to load everything in stage 3.  I found that ImmediateRead does not load method bodies.  I don't know if/how you want want something like this exposed via the public API.  For now I'm iterating the data model and forcing things to load that ImmediateRead did not cover.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants