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

Rewrite the funcletizer to support precompiled queries #33106

Merged
merged 6 commits into from
Feb 22, 2024

Conversation

roji
Copy link
Member

@roji roji commented Feb 15, 2024

Here's the rewrite of ParameterExtractingExpressionVisitor, to support precompiled queries.

  • The new ExpressionTreeFuncletizer now has a new "path calculation" mode, where it returns a tree representing the paths to all parameterized nodes in the input tree. This will be used when generating precompiled query interceptors in order to generate code that extracts the parameterizable nodes and evaluates them at runtime.
  • To support this, the new funcletizer has a visitation method for each node type (that's required for generating the correct path through each node). This is different from the previous approach, where the same semi-generic code attempted to handle the work for all node types (but in practice there were many exceptions and special code paths for specific node types).
  • In addition, the new funcletizer does its work in a single visitation pass; the old approach was to visit once to identify evaluatable nodes, and then to visit again and evaluate the top-level nodes. This is better for perf.

Closes #32999
Closes #32698
Closes #33012

@roji roji requested a review from a team February 15, 2024 15:59
@roji
Copy link
Member Author

roji commented Feb 15, 2024

FYI I'm happy to go over the code with whoever wants to review, or possibly to do a brown bag if people are interested.

@roji
Copy link
Member Author

roji commented Feb 15, 2024

Note: the new mode (path calculation for precompiled queries) is obviously not well-tested; I will very likely be revisiting the funceltizer as part of later NativeAOT work. So there are likely some bugs in those specific bugs of the code - that's expected.

@maumar
Copy link
Contributor

maumar commented Feb 21, 2024

awesome stuff!

@roji roji mentioned this pull request Feb 22, 2024
@roji roji merged commit a2b8f2c into dotnet:main Feb 22, 2024
7 checks passed
@roji roji deleted the NewFuncletizer branch February 22, 2024 23:10
@roji
Copy link
Member Author

roji commented Feb 22, 2024

Thanks for the reviewing and the suggestions @maumar!

private bool _calculatingPath;

/// <summary>
/// Indicates whether we should parameterize. Is false in in compiled query mode, as well as when we're handling query filters
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra 'in'

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do in next commit

roji added a commit to roji/efcore that referenced this pull request Mar 5, 2024
roji added a commit to roji/efcore that referenced this pull request Mar 5, 2024
roji added a commit that referenced this pull request Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants