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

Use lightweight replacement for Expression to improve performance of manually created expression #5

Closed
dadhi opened this issue Apr 13, 2017 · 1 comment
Assignees

Comments

@dadhi
Copy link
Owner

dadhi commented Apr 13, 2017

The final results

Benchmark of Creating and Compiling expression

() => new X(new A(), new B())

Comparing classic Expression

Expression.Lambda(Expression.New(_xCtor, Expression.New(_aCtor), Expression.New(_bCtor)))

vs lightweight ExpressionInfo:

ExpressionInfo.Lambda(ExpressionInfo.New(_xCtor, ExpressionInfo.New(_aCtor), ExpressionInfo.New(_bCtor)))

image

Supported lightweight ExpressionInfo's

  • ExpressionInfo.Lambda
  • ExpressionInfo.Parameter
  • ExpressionInfo.Constant
  • ExpressionInfo.Call
  • ExpressionInfo.Property
  • ExpressionInfo.Field

The rest is for the later.

Old info

Current results show that composing Expression Tree may take significant amount of time even compare to compilation of expression. It happens because Expression validates its child nodes and wrapped operations. But in case you do it on your own, that seems like a double work.

image

Introducing lightweight DryExpression may improve performance (and probably memory utilization) in such case. It may be also designed the way to include normal Expressions as children. So the implementation may start with sub-set of expressions, and DryExpressionCompiler may fallback to FastExpressionCompiler for the rest.

Current results for creating simple DryExpression.New vs Expression.New:

image

@dadhi dadhi changed the title Use lightweight DryExpression to improve performance of manually created expression Use lightweight replacement for Expression to improve performance of manually created expression Jun 22, 2017
@dadhi dadhi self-assigned this Jun 22, 2017
@dadhi
Copy link
Owner Author

dadhi commented Jun 23, 2017

Updated results:

image

For service with two dependencies, created with ExpressionInfo instead of Expression and then compiled is ~2x faster (at the moment). Hey, expected 25% improvements but not as much!

@dadhi dadhi closed this as completed in c2c87ab Jul 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant