Skip to content

Optimize grid node merging with ID index#61656

Merged
pierrejeambrun merged 1 commit intoapache:mainfrom
steveahnahn:grid-merge-index
Feb 11, 2026
Merged

Optimize grid node merging with ID index#61656
pierrejeambrun merged 1 commit intoapache:mainfrom
steveahnahn:grid-merge-index

Conversation

@steveahnahn
Copy link
Copy Markdown
Contributor

Summary

Optimize grid node merge by replacing repeated list scans with a single ID -> node index, improving merge performance when combining node trees.

The previous _merge_node_dicts used a set for ID membership (O(1)), but still performed a full list scan to retrieve the node object on every match. That turned the merge into O(n·m) for large grids and repeated work for each incoming node.
This change makes lookups O(1) and scales better with newly appended nodes being updated the dict so subsequent lookups see it.

Tests

test_merge_node_dicts_merges_children_and_appends_new_nodes
test_merge_node_dicts_preserves_existing_non_group_node_shape
test_merge_node_dicts_large_merge_keeps_unique_nodes
These cover correct child merges, avoiding accidental mutation of leaf nodes, and ensuring large merges don’t duplicate entries.

Copy link
Copy Markdown
Member

@pierrejeambrun pierrejeambrun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Copy Markdown
Member

@pierrejeambrun pierrejeambrun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@pierrejeambrun pierrejeambrun added this to the Airflow 3.1.8 milestone Feb 11, 2026
@pierrejeambrun pierrejeambrun merged commit 9da4a15 into apache:main Feb 11, 2026
129 checks passed
github-actions bot pushed a commit that referenced this pull request Feb 11, 2026
(cherry picked from commit 9da4a15)

Co-authored-by: Steve Ahn <steveahnahn@g.ucla.edu>
@github-actions
Copy link
Copy Markdown

Backport successfully created: v3-1-test

Status Branch Result
v3-1-test PR Link

jason810496 pushed a commit that referenced this pull request Feb 12, 2026
(cherry picked from commit 9da4a15)

Co-authored-by: Steve Ahn <steveahnahn@g.ucla.edu>
pierrejeambrun pushed a commit that referenced this pull request Feb 12, 2026
(cherry picked from commit 9da4a15)

Co-authored-by: Steve Ahn <steveahnahn@g.ucla.edu>
Ratasa143 pushed a commit to Ratasa143/airflow that referenced this pull request Feb 15, 2026
choo121600 pushed a commit to choo121600/airflow that referenced this pull request Feb 22, 2026
Subham-KRLX pushed a commit to Subham-KRLX/airflow that referenced this pull request Mar 4, 2026
vatsrahul1001 pushed a commit that referenced this pull request Mar 4, 2026
(cherry picked from commit 9da4a15)

Co-authored-by: Steve Ahn <steveahnahn@g.ucla.edu>
dominikhei pushed a commit to dominikhei/airflow that referenced this pull request Mar 11, 2026
Ankurdeewan pushed a commit to Ankurdeewan/airflow that referenced this pull request Mar 15, 2026
radhwene pushed a commit to radhwene/airflow that referenced this pull request Mar 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:API Airflow's REST/HTTP API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants