Skip to content

WIP - Use Lambda Expressions for field/property accessor when UseReflectionOptimizer enabled #1942

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

Closed
wants to merge 3 commits into from

Conversation

maca88
Copy link
Contributor

@maca88 maca88 commented Dec 20, 2018

The performance tests shows up to 10 times faster than before for getting or setting a property/field.

@hazzik
Copy link
Member

hazzik commented Dec 20, 2018

I would rewrite this using dynamic lambda.

@maca88
Copy link
Contributor Author

maca88 commented Dec 20, 2018

Done, the performance is more or less the same.
I realized that I mistakenly pushed the branch to this repository, should I remove it and create a new PR?

@maca88 maca88 changed the title Use IL generated code for Field and BasicProperty accessor when UseReflectionOptimizer enabled Use Lambda Expressions for field/property accessor when UseReflectionOptimizer enabled Dec 20, 2018
@maca88 maca88 changed the title Use Lambda Expressions for field/property accessor when UseReflectionOptimizer enabled WIP - Use Lambda Expressions for field/property accessor when UseReflectionOptimizer enabled Dec 20, 2018
@hazzik
Copy link
Member

hazzik commented Dec 20, 2018

I realized that I mistakenly pushed the branch to this repository, should I remove it and create a new PR?

No, it's fine

@fredericDelaporte

This comment has been minimized.

@maca88

This comment has been minimized.

{
private readonly FieldInfo field;
private readonly System.Type clazz;
private readonly string name;
[NonSerialized]
private Lazy<Func<object, object>> _getDelegate;
Copy link
Member

@fredericDelaporte fredericDelaporte Dec 21, 2018

Choose a reason for hiding this comment

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

Using a lazy here or in property accessor looks like #1904 laziness, which was rejected: it may reduce start-up time but will cause warming-up more hard to achieve.

And also, the reflection optimizer documentation is crystal clear about that:

The use of the reflection optimizer inflicts a certain startup cost on the application but should lead to better performance in the long run.

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've made an alternative approach (#1944) that avoids this problem.

@fredericDelaporte
Copy link
Member

Replaced by #1944.

@ghost ghost deleted the AccessorOptimization branch January 1, 2019 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants