hazzik / DelegateDecompiler

A library which is able to decompile a delegate or a method body to its lambda representation
MIT License
526 stars 62 forks source link

Performance #244

Open Daythril opened 1 month ago

Daythril commented 1 month ago

1st-of-all, thanks for this tool. I use NHibernate and wanted a way to make my computed properties usable in LINQ expressions that convert to SQL. I had it working with code similar to NeinLinq where you create a static Expression and annotate the method you want to convert to SQL so that NH knows to substitute that Expression tree for it, but DelegateDecompiler is much easier to use. I think it also covers more situations, but I haven't yet established that.

Now, I find that the first time DD expands the LINQ for a Computed property there's quite a bit of overhead -- on the order of a full second on my 12th Gen Intel(R) Core(TM) i7-1280P 1.80 GHz with 32 GB of RAM.

There's no overhead on subsequent use of the same query (perhaps even of the same method combined with other elements in the LINQ, but I don't remember), so I'm assuming you're caching the subtrees.

Can you please point me to some documentation that explains how these things work, and perhaps offers advice for how to optimize?

Thanks in advance.

NetMastr5 commented 1 month ago

@Daythril , this sounds like it might be the performance issue I reported when migrating from 0.31.0 to 0.32.0, which is still open. You can try downgrading to 0.31.0 to see if your performance issue goes away.