Repository navigation
[SQL] Improvements related to CSE - #7864
Merged
Merged
Conversation
Signed-off-by: Mihai Budiu <mbudiu@feldera.com>
gz
approved these changes
Nov 5, 2026
Contributor
|
What I ran
I found no correctness problems. The value-numbering, closure-scoping, assignment-placement and static-replacement logic all hold up for the cases I traced. The gates pass: the PR adds unit tests, it has no user-visible or breaking change, and it adds no dependencies. missing (medium): cases the PR's tests do not cover. I wrote tests for all three and they pass:
@Test
public void testCSENestedBlocks() {
DBSPCompiler compiler = new DBSPCompiler(new CompilerOptions());
DBSPVariablePath t = b.refVar(b.tup(b.i32n(), b.i32n()));
DBSPLetStatement a = new DBSPLetStatement("a", b.field(t, 0));
DBSPLetStatement c = new DBSPLetStatement("c", b.field(t, 1));
DBSPExpression prod = b.binary(b.i32n(), DBSPOpcode.MUL,
b.add(a.getVarReference(), c.getVarReference()),
b.add(a.getVarReference(), c.getVarReference()));
DBSPExpression inner = new DBSPBlockExpression(Linq.list(c), b.tuple(prod,
b.call("f", b.add(a.getVarReference(), b.lit(1, true))),
b.call("g", b.add(a.getVarReference(), b.lit(1, true)))));
IDBSPInnerNode result = cse(compiler, new DBSPBlockExpression(Linq.list(a), inner).closure(t));
assertCseVariables(compiler, result, 2);
assertResolves(compiler, result);
}
@Test
public void testCSEMutableFieldBorrow() {
DBSPCompiler compiler = new DBSPCompiler(new CompilerOptions());
DBSPVariablePath acc = b.tup(b.i32n()).var();
DBSPClosureExpression closure = b.tuple(
b.call("f", acc.field(0)),
b.call("g", acc.field(0).borrow(true)),
b.call("f", acc.field(0))).closure(acc);
assertCseVariables(compiler, cse(compiler, closure), 0);
}Otherwise LGTM. |
- Insert each CSE variable after the last let statement that it depends on. - Copy a subtree that two closures share, so that each closure gets its own translation. - Include the result type in the representation of unary expressions and tuples. - Put delimiters around expression ids in value numbering representations. - Count each user that has no value number as a separate user. - Include the generic arguments in the representation of paths. - Give no value number to an expression that reads a mutable variable. Fixes #7596 Signed-off-by: Mihai Budiu <mbudiu@feldera.com>
Signed-off-by: Mihai Budiu <mbudiu@feldera.com>
Signed-off-by: Mihai Budiu <mbudiu@feldera.com>
Signed-off-by: Mihai Budiu <mbudiu@feldera.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Linked Issue
Fixes #7596
Describe Manual Test Plan
There are 5 commits; the main one is the one related to ValueNumbering (inner CSE), which fixes some potential bugs. The other commits are small code quality improvements and tests
Checklist