Skip to content

perf(workflow-compiler): index output ports when wiring links - #9632

Draft
Matthew-DWM wants to merge 1 commit into
apache:mainfrom
Matthew-DWM:perf/compiler-producer-index
Draft

Matthew-DWM wants to merge 1 commit into
apache:mainfrom
Matthew-DWM:perf/compiler-producer-index

Conversation

@Matthew-DWM

Copy link
Copy Markdown

What changes were proposed in this PR?

WorkflowCompiler.expandLogicalPlan found the source of each logical link with physicalPlan.getPhysicalOpsOfLogicalOp(fromOp), which builds a JGraphT DAG of the whole plan so far and walks it in topological order. Every link paid for that.

The compiler now records which physical op produces each (logical op, output port) as it adds ops, and wires a link with one map lookup.

Before:  link from Aggregate -> DAG of every physical op so far -> topological walk -> globalAgg, port 0
After:   link from Aggregate -> producers((Aggregate, port 0))                       -> globalAgg, port 0

Internal ports are separate keys, so the first stage of Aggregate or Hash Join, which writes to internal port 0, is never picked.

Any related issues, documentation, discussions?

Closes #9631

How was this PR tested?

  • New WorkflowCompilerProducerLookupSpec (4 cases): links out of real Aggregate and Hash Join operators and their storage ports, an operator whose later internal link fails, a link from a missing port, and repeated links into one port. They pass on main too.
  • sbt WorkflowCompiler/test: 91 passed. Scalafmt and Scalafix checks pass.
  • An out-of-tree check compiled 121 workflows with main and with this PR in both modes. Plans, link order, schemas, errors and storage ports match for 119. The other two are synthetic shapes no shipped operator produces: two physical ops on the same output port (this PR picks the first added), and a reused physical op ID that forms a cycle, which main caught at the next link.

Median editing-time compile on local machine with JDK 17, 5 JVMs × 20 runs of main and this PR alternating after warmup:

Workflow main This PR Allocated per compile
16-operator chain 0.60 ms 0.31 ms 0.50 → 0.26 MB
64-operator chain 10.8 ms 3.9 ms 6.7 → 2.3 MB
36 Aggregates 9.8 ms 4.9 ms 5.5 → 2.7 MB
20 Hash Joins 7.6 ms 3.8 ms 4.5 → 2.0 MB
80 branches into a Union 22.9 ms 14.2 ms 11.5 → 6.5 MB

Strict mode moves the same way, and a one-link workflow is no slower.

Was this PR authored or co-authored using generative AI tooling?

Generated-by: OpenAI Codex (GPT-6.2 Sol) and Claude Code (Claude Opus 5.5)

@github-actions

Copy link
Copy Markdown
Contributor

Automated Reviewer Suggestions

Based on the git blame history of the changed files, we recommend the following reviewers:

  • Contributors with relevant context: @Xiao-zhen-Liu
    You can notify them by mentioning @Xiao-zhen-Liu in a comment.

@Matthew-DWM
Matthew-DWM marked this pull request as draft November 23, 2026 17:49

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Workflow compiler walks the whole physical plan to wire each link

1 participant