-
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
[WIP] Handle first class spans #35279
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
255 changes: 248 additions & 7 deletions
255
src/EFCore.Relational/Query/RelationalSqlTranslatingExpressionVisitor.cs
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ChrisJollyAU thanks for working on this, and sorry that I didn't have time to look earlier.
As per dotnet/runtime#109757 (comment) - which I hope you agree is a good approach to handle this - I think we'd be normalizing away method calls like MemoryExtensions.Contains - replacing them with corresponding non-Span calls - very early in the pipeline, in ExpressionTreeFuncletizer. If we go down this road, no later part of the query pipeline will ever see these MemoryExtensions methods.
Does that make sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did see that. It is one way to do it and was the alternative I considered. Not sure what the performance cost is though of rewriting the query away from span (implicit) back to normal versus handling it direct.
Note that I actually have it that there is only interpretation being done with very minimal changes to the funcletizer. Nothing is getting the full compilation. It just gets directly picked in in the translator mostly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, take for example this
Currently this doesn't even compile (Expression tree cannot contain value of ref struct or restricted type) but should that support get added (that other thread has mentioned a couple of issues in order to get it working), rewriting it away would not be able to work. This handling it direct in the translator side would handle it (without much change if any I think)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I had in mind would be to do the rewriting as part of the funcletization pass, rather than adding an additional pass just for that; if we do it that way, the perf impact should be completely negligible, I think.
But more important: when the funcletizer identifies a tree fragment that can be client-evaluated, it does that and embeds the result either as a constant or as a parameter. If such an evaluatable tree fragment happens to contains a Contains, won't that now start throwing, since client evaluation involves going through the LINQ interpreter? Am I missing something here?
if so, then the funcletizer must do the substitution early (i.e. remove any Span-based method overloads), because it has to happen before the LINQ interpreter is possibly used.
Right, but that seems pretty orthogonal to the discussion (and not necessarily extremely important). I indeed don't think the C# compiler will allow ref structs inside LINQ expression trees any time soon; that's also not a change from 9 to 10 - it has never been allowed, and as far as I know nobody has ever complained about it (there's no real reason to use a Span variable rather than an array when querying like this).