Optimize FlatExpression node layout for constants, parameters, and parent links#534
Optimize FlatExpression node layout for constants, parameters, and parent links#534
Conversation
Agent-Logs-Url: https://github.com/dadhi/FastExpressionCompiler/sessions/7d16be33-857d-4217-8cbc-c6e95d110f84 Co-authored-by: dadhi <39516+dadhi@users.noreply.github.com>
dadhi
left a comment
There was a problem hiding this comment.
The ubuntu build is failed:
/home/runner/work/FastExpressionCompiler/FastExpressionCompiler/src/FastExpressionCompiler.LightExpression/FlatExpression.cs(1793,6): error CS0246: The type or namespace name 'DoesNotReturnAttribute' could not be found (are you missing a using directive or an assembly reference?) [/home/runner/work/FastExpressionCompiler/FastExpressionCompiler/src/FastExpressionCompiler.LightExpression/FastExpressionCompiler.LightExpression.csproj::TargetFramework=net472]
Also just to verify. We are using the same condition for FE as for SE and LE in FEC to decide what to store in ClosureConstants. We did not change that. The only change is for non closure constants that previosly can be stored inplace in Constant node for up to 8 bytes, but now - just up to 4 bytes. So bigger than 4 bytes non-closure values dtored in Obj (possibly boxed). Please check that.
Agent-Logs-Url: https://github.com/dadhi/FastExpressionCompiler/sessions/e4fd589e-da46-45a0-877b-94c254d85cd8 Co-authored-by: dadhi <39516+dadhi@users.noreply.github.com>
Fixed in def9eb9. I removed the |
dadhi
left a comment
There was a problem hiding this comment.
Vi errors:
Error: /home/runner/work/FastExpressionCompiler/FastExpressionCompiler/src/FastExpressionCompiler.LightExpression/FlatExpression.cs(1315,40): error CS0117: 'BitConverter' does not contain a definition for 'SingleToInt32Bits' [/home/runner/work/FastExpressionCompiler/FastExpressionCompiler/src/FastExpressionCompiler.LightExpression/FastExpressionCompiler.LightExpression.csproj::TargetFramework=net472]
Agent-Logs-Url: https://github.com/dadhi/FastExpressionCompiler/sessions/72f15b2a-4d12-499c-a213-bcad43d6e4be Co-authored-by: dadhi <39516+dadhi@users.noreply.github.com>
Fixed in 5ce2ffc. I replaced the |
| tag = pointsToParent | ||
| ? (byte)(tag | nextPointsToParentMask) | ||
| : (byte)(tag & ~nextPointsToParentMask); | ||
| _data = (_data & KeepWithoutTagAndNextMask) |
There was a problem hiding this comment.
Let split to 4 bytes _data and 4 bytes _nodeTypeAndKind
There was a problem hiding this comment.
Done in 1484adf. ExprNode now uses a 4-byte _data field plus a 4-byte _nodeTypeAndKind field, while keeping the 24-byte explicit layout intact.
Agent-Logs-Url: https://github.com/dadhi/FastExpressionCompiler/sessions/4b99052f-cb83-4a38-8342-f53e859ddbc9 Co-authored-by: dadhi <39516+dadhi@users.noreply.github.com>
FlatExpression needs a more direct node model to support upcoming canonicalization and chaining work: compact constant storage, explicit parameter declaration/usage identity, and reliable parent reachability from child chains. This update reshapes the flat node metadata so those semantics are encoded directly instead of inferred indirectly.
Constant node layout
Objinstead of routing them throughClosureConstants.Parameter declaration vs usage
ChildIdxand declaration position inChildCount.Child chain parent linkage
Reader / builder updates
GetSurePresentRef/direct refs in hot paths.Focused coverage
Example of the new parameter model: