Replies: 3 comments 3 replies
-
Hi @jods4 I know about the interpretation option. This library does not cover the use of it.
So, calculate for yourself how many calls you need to win the perf. There is also a hybrid approach I am using for https://github.com/dadhi/DryIoc. There is also a bonus if you know the expressions - it may be faster to program your own Interpretator to avoid the reflection calls for known parts of your expression. This is done in DryIoc. |
Beta Was this translation helpful? Give feedback.
-
I have the same consideration if to use the interpreted version or to use the FastExpressionCompiler in my project when trying to get the values of the arguments of an MethodCallExpression. Since the argument expressions are not cached and would compile always again the interpreted version is my favourite and is sufficient in my case. In my project I must come along still with .NET Framework 4.8. What I am wondering: In .NET 8 the intepreted version is about 10-15 times faster. But in .NET Framework 4.8 the intepreted version is even a little slower than the compiled version. Do you have an idea why this is the case? Maybe you also have an idea how to cache the argument expressions myself with the FastExpressionCompiler... Thanks! |
Beta Was this translation helpful? Give feedback.
-
Huh. Ok. I have a similar thing in mind for adding espression equality #431 Regarding the Hash, I did not think about that because internally I may use Reference for the hashing. Which won't work in your scenario. So, this is great to know. I may add hashing now to pair it with equality. Also it may open up other opportunities. E.g. there are content addressed ASTs in the world (see https://www.unison-lang.org/ or https://eyg.run/) which enable new ways to pass code across the service boundaries, avoid recompilation, etc. Actually, I am amazed how having the almost complete package of the compilation tooling makes possible to do new things #433, #435 |
Beta Was this translation helpful? Give feedback.
-
Since .net 4.7.1 there's an overload
LambdaExpression.Compile(bool preferInterpretation)
(which I believe has no equivalent in FEC?).When you pass
preferInterpretation: true
, the lambda is quickly converted into a stack-based interpreter.It's a trade off between compilation-time (supposedly much faster) and runtime-performance (obviously slower).
The motivation is that you sometimes have an API that takes an
Expression
that you need to evaluate just once, or maybe a few times. In this case, the overall performance of compile + call would be better with the interpreter rather than doing a full compilation.I think it'd be valuable to add this variant to the benchmarks, to see how it compares with FEC and might be (or not) a viable alternative for expressions evaluated only once (or few times).
Benchmarking is a tad tricky, as ideally for a one-time Expression you'd like to factor in the JIT time to native code of the compiled delegate (no warmup or repeated executions).
Beta Was this translation helpful? Give feedback.
All reactions