Optimize repeating paths with unused variables and level-by-level fallback#59
Optimize repeating paths with unused variables and level-by-level fallback#59maxdemarzi wants to merge 3 commits into
Conversation
Walkthrough - Variable-Length Repeating Pattern OptimizationWe have optimized the execution of variable-length repeating patterns on large graphs to prevent Out-Of-Memory (OOM) and exponential path explosion errors. What Was Fixed1. Unused Variable Elimination Pass
2. Adjacency-Driven Repeat Traversal Fallback
3. Boundary Node Positional Fix in Pushdowns
Performance Comparison ResultsA benchmark was run on a deterministic 10K-node graph (with 50K directed and 5K undirected edges) for the query:
Insights
Repository ContributionThe changes have been staged, committed, and submitted as a pull request to the upstream repository:
|
Walkthrough - Variable-Length Repeating Pattern Optimization &
|
| Scenario / Case | Optimization Strategy | Execution Time (ms) | Rows Produced | Description / Notes |
|---|---|---|---|---|
| Case 1: Unused Variable | Unrolled Union | 285.57 ms | 6,080 | Variable e is unused and stripped. Pattern unrolls to flat union of joins. |
| Case 2: Used Variable | Adjacency Fallback | 8.55 ms | 6,080 | Variable e is returned, preventing unrolling. Uses new level-by-level traversal. |
| Case 3: Simulated Legacy | Global Path Enumeration | 2604.69 ms | 1,430,812 | Old behavior where the repeating pattern evaluates globally before filtering. |
Insights
- Adjacency Fallback (Case 2): Starts directly from the filtered set of
n1nodes (nodes wherescore > 9950) and expands paths locally step-by-step. This drops execution time to 8.55 ms (a 300x speedup compared to legacy global enumeration). - Legacy Behavior (Case 3): In the original engine, because the pattern could not be unrolled (since variables were named or filters couldn't push past the repetition boundary), the engine evaluated
-[e]-{1,2}globally first. On a 10K-node graph, this enumerated 1,430,812 paths of length 1 and 2 globally before any filtering, taking over 2.6 seconds. On a larger 57MB graph database, this would cause the OOM crash.
Verification Plan
Automated Tests
- Added comprehensive integration tests in
tests/all_reduce_test.rsvalidating:- Pure expression evaluation of
allReduce(passing/failing cases). - Early path pruning correctness under different constraint thresholds (
dist < 6anddist < 8). - Typechecker validation rules (checking list source types and boolean predicate return types).
- Pure expression evaluation of
- All tests (including
all_reduce_test.rs, memory allocation benchmarks, and the fullfrogqltest suite) compile and pass successfully.
Repository Contribution
The changes have been staged, committed, and submitted as a pull request to the upstream repository:
- Pull Request: #59
- Branch:
maxdemarzi:optimize-repetition-path
Walkthrough - Variable-Length Repeating Pattern Optimization &
|
| Scenario / Case | Optimization Strategy | Execution Time (ms) | Rows Produced | Description / Notes |
|---|---|---|---|---|
| Case 1: Unused Variable | Unrolled Union | 285.57 ms | 6,080 | Variable e is unused and stripped. Pattern unrolls to flat union of joins. |
| Case 2: Used Variable | Adjacency Fallback | 8.55 ms | 6,080 | Variable e is returned, preventing unrolling. Uses new level-by-level traversal. |
| Case 3: Simulated Legacy | Global Path Enumeration | 2604.69 ms | 1,430,812 | Old behavior where the repeating pattern evaluates globally before filtering. |
Insights
- Adjacency Fallback (Case 2): Starts directly from the filtered set of
n1nodes (nodes wherescore > 9950) and expands paths locally step-by-step. This drops execution time to 8.55 ms (a 300x speedup compared to legacy global enumeration). - Legacy Behavior (Case 3): In the original engine, because the pattern could not be unrolled (since variables were named or filters couldn't push past the repetition boundary), the engine evaluated
-[e]-{1,2}globally first. On a 10K-node graph, this enumerated 1,430,812 paths of length 1 and 2 globally before any filtering, taking over 2.6 seconds. On a larger 57MB graph database, this would cause the OOM crash.
Verification Plan
Automated Tests
- Added comprehensive integration tests in
tests/all_reduce_test.rsvalidating:- Pure expression evaluation of
allReduce(passing/failing cases). - Early path pruning correctness under different constraint thresholds (
dist < 6anddist < 8). - Evaluation of global constraints inside
allReducepredicates, allowing the path search to query outer/query-scoped nodes or parameters (resolving User Review Comment 2). - Enforcing that any repetition variable referenced inside
allReduceis preserved (not stripped or unrolled by the compiler optimization passes), forcing level-by-level fallback traversal where dynamic path pruning runs (resolving User Review Comment 1). - Typechecker validation rules (checking list source types and boolean predicate return types).
- Pure expression evaluation of
- All tests (including
all_reduce_test.rs, memory allocation benchmarks, and the fullfrogqltest suite) compile and pass successfully.
Repository Contribution
The changes have been staged, committed, and submitted as a pull request to the upstream repository:
- Pull Request: #59
- Branch:
maxdemarzi:optimize-repetition-path
This PR introduces two optimizations for variable-length repeating patterns on large graphs to prevent OOM errors:
-[e]-{1,3}whereeis unused) into standard concat joins.Also fixes a boundary node positioning bug in the pushdown optimizer that was exposed by removing unused end-of-path variables.