Summary
Add a Subplan Sharing optimization pass that identifies and eliminates redundant sub-computations across rules within the same stratum.
Motivation
When multiple rules scan the same relation with identical filters or join the same pair of relations on the same keys, the DD plan currently generates duplicate operator chains. Subplan sharing detects these common sub-plans and merges them so the underlying DD execution evaluates each unique sub-computation only once.
Design
- New pass file:
wirelog/passes/subplan_sharing.c (following fusion.c, jpp.c, sip.c pattern)
- Operates on the stratified IR before DD plan generation
- Identifies structurally equivalent sub-trees (SCAN+FILTER, JOIN with same keys) across rules in a stratum
- Rewrites the IR to share a single sub-tree, with dependent rules referencing the shared node
- Integrated into the optimization pipeline in
driver.c after SIP
Acceptance Criteria
Context
Phase 1 optimization — item 8 in the roadmap. Follows JPP and SIP.
Summary
Add a Subplan Sharing optimization pass that identifies and eliminates redundant sub-computations across rules within the same stratum.
Motivation
When multiple rules scan the same relation with identical filters or join the same pair of relations on the same keys, the DD plan currently generates duplicate operator chains. Subplan sharing detects these common sub-plans and merges them so the underlying DD execution evaluates each unique sub-computation only once.
Design
wirelog/passes/subplan_sharing.c(followingfusion.c,jpp.c,sip.cpattern)driver.cafter SIPAcceptance Criteria
wl_subplan_sharing_apply()pass implemented and integratedmeson test,cargo test)clang-format-18)Context
Phase 1 optimization — item 8 in the roadmap. Follows JPP and SIP.