-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Improve startup time by caching compiled queries on disk #16496
Comments
LambdaExpression.CompileToMethod is only available in .net framework :( |
@mburbea that's true. However, since System.Reflection.Emit is supported (although that's also a bit of a mess), it may be possible to recreate the same thing in .NET Core (see https://stackoverflow.com/questions/41520319/alternatives-of-compiletomethod-in-net-standard). Definitely nothing certain here. |
I am going to assume we are talking about both implicitly compiled and explicitly compiled queries, but I believe most of what I am going to describe applies regardless: At a high level, query compilation takes a source expression tree and arguments (e.g. closure variables, compiled query arguments, DbContext state that affects the query, etc.) and produces a few distinct outputs:
Persisting the query cache has then has several distinct aspects, some of which can be addressed independently:
|
It's an interesting idea... The Roslyn-based compile/design-time approach seems like it can be called AOT, as opposed to the purely runtime approach. Here are some preliminary thoughts:
PS One unrelated crazy thought I had on cache lookups, is to use caller information as cache key - the file name and line number could maybe have been used as a much more efficient lookup key. This could theoretically be implemented via |
Some customer feedback:
Hope this helps. |
@GSPP thanks for your input, FWIW I agree that steady state perf should be prioritized over startup, at least at the moment. |
Replacing with #25009 |
In order to improve startup time, we could cache compiled delegates on disk. Technically this doesn't seem very complicated to do, with LambdaExpression.CompileToMethod(). This would make EF Core have some "AOT" characteristics in addition to the current "JIT" behavior.
Some questions that would need to be answered:
This is conceptually similar to #1906, which is for caching the model.
The text was updated successfully, but these errors were encountered: