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

Incremental steps to netnative support #3478

Closed
wants to merge 1 commit into from
Closed

Conversation

natemcmaster
Copy link
Contributor

Changes necessary to make the very basic UWP app work in Release mode (after .NET Native mangles it).

Will still require a patch to Relinq (re-motion/Relinq#6)

Makes significant progress on #623

@ajcvickers
Copy link
Contributor

How does this effect perf? Does it make the benchmarks we have significantly slower?

@ajcvickers
Copy link
Contributor

Also, have we considered cross-compiling so we only do this for UWP apps? Since perf is a priority it seems counter-productive to on the one hand be trying to improve perf, while with the other hand removing code that was specifically added to help with perf.

@natemcmaster
Copy link
Contributor Author

I suspect perf will be worse. I can actually test the numbers to see how much.

We are not currently set up to cross compile to UWP. @bricelam would know better how we could set that up.

Alternatively, we could catch the runtime exception thrown only on .NET Native and then invoke this slower path which preserves the original path for all other cases.

@ajcvickers
Copy link
Contributor

I think we should discuss after seeing how much it affects our current benchmarks.

InternalImplyValuesAndTypes<TEntity> EntityValueProp;

InternalImpliesTypes<TEntity> EntityProp;
InternalImpliesTypes<char> CharProp;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a way we can do this in providers since primitive type support is tied to providers?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perhaps a better method is to expose a utility class publicly and let providers pass in their primitive types.

Copy link
Contributor

Choose a reason for hiding this comment

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

I like that. Also, I kept mulling on it after our in person discussion and here are some of my thoughts:

  • The goal is to make .NET Native support as transparent as possible to application developers (as opposed to provider writers)
  • I would like to see providers do whatever they need to do so that their valid primitive types are supported in .NET native in code that is near/related to their type mapper
  • If we do this for some well known set of types in the core it actually increases the chances that providers are just going to miss that they need to do it for all the types they support in their type mapper until they have some customer trying to use a particular type that is not part of the subset on .NET Native.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@divega I added some of the related actionable items of these in #623 (comment).

@natemcmaster
Copy link
Contributor Author

To my surprise, this actually improves perf:

        [Benchmark(Iterations =10)]
        public void ConstructGetterSource(IMetricCollector collector)
        {
            var entityType = new EntityType(typeof(Poco), new Model());
            var prop = entityType.AddProperty("Id", typeof(int));
            for (var i = 0; i < 100000; i++)
            {
                var getter = new ClrPropertyGetterSource();
                var setter = new ClrPropertySetterSource();
                collector.StartCollection();
                getter.GetAccessor(prop);
                setter.GetAccessor(prop);
                collector.StopCollection();
            }
        }
Code TimeElapsedAverage TimeElapsed95
Original 2266 2383
With changes in this PR 1840 1889

@ajcvickers
Copy link
Contributor

@natemcmaster That looks good--what is the impact on our existing benchmarks?

@natemcmaster
Copy link
Contributor Author

@ajcvickers The changes to existing perf benchmarks was hardly significant. I had to run 100,000 iterations to get numbers I could believe were significantly different.

@rowanmiller
Copy link
Contributor

Just checking that you got those numbers on a release build and not a debug one (since that is the perf we care about)

@natemcmaster
Copy link
Contributor Author

Good point. Those were Debug. I'll re-run on release mode.

@ajcvickers
Copy link
Contributor

@natemcmaster I misunderstood the code when I looked at it last night. I see now that it doesn't change the cached delegate path, and hence I'm not surprised that the overall benchmark numbers are okay.

I can say :shipit: for those code changes. The "implies" stuff and how it is supposed to work is a mystery to me, so somebody who knows about that should look.

@natemcmaster
Copy link
Contributor Author

@ajcvickers Good to know.

Everyone else, there is gonna be a whole lot more awful "implies" stuff, so brace yourselves. This stuff exists only to trick ILC (the .NET Native compilation step) to keep metadata about generic methods and types we use at run time.

@ajcvickers
Copy link
Contributor

@natemcmaster :shipit:

@natemcmaster
Copy link
Contributor Author

Merged with c35ce4d

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.

5 participants