Skip to content

Improve startup time by caching compiled queries on disk #16496

@roji

Description

@roji

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:

  • How much startup time is really taken by query compilation - this may simply not be worth it
  • This depends on Reflection.Emit, whose status in .NET Standard isn't clear (see https://github.com/dotnet/corefx/issues/29365). It seems like this could work by checking at runtime whether emit is supported or not, and bypass this in AOT environments (even though our support of AOT environments isn't ideal in any case).
  • We'd have to decide when the query cache is persisted, how it's evicted (Improve query cache eviction #12905), how the user determines where it's stored, etc. etc.

This is conceptually similar to #1906, which is for caching the model.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions