Skip to content

Improve performance of task dequeuing - #61376

Merged
potiuk merged 3 commits into
apache:mainfrom
steveahnahn:fix/deque-popleft
Feb 15, 2026
Merged

potiuk merged 3 commits into
apache:mainfrom
steveahnahn:fix/deque-popleft

Conversation

@steveahnahn

Copy link
Copy Markdown
Contributor

Summary

Replace list.pop(0) with deque.popleft() in three hot‑path task traversal/queueing loops to avoid O(n^2) behavior.
list.pop(0) is O(n) due to element shifting; repeated in loops it becomes O(n^2). deque.popleft() is O(1) and preserves ordering.

Changes

  • airflow-core/src/airflow/executors/base_executor.py: use deque in trigger_tasks()
  • airflow-core/src/airflow/serialization/definitions/taskgroup.py: use deque in iter_tasks()
  • task-sdk/src/airflow/sdk/definitions/taskgroup.py: use deque in iter_tasks()

@shivaam

shivaam commented Feb 3, 2026

Copy link
Copy Markdown
Contributor

Provider unit tests failed.

@potiuk potiuk changed the title pop(0) to deque.popleft() Improve performance of task dequeuing Feb 15, 2026

@potiuk potiuk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice!

@potiuk
potiuk merged commit fd4fd67 into apache:main Feb 15, 2026
102 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

Backport failed to create: v3-1-test. View the failure log Run details

Status Branch Result
❌ v3-1-test Commit Link

You can attempt to backport this manually by running:

cherry_picker fd4fd67 v3-1-test

This should apply the commit to the v3-1-test branch and leave the commit in conflict state marking
the files that need manual conflict resolution.

After you have resolved the conflicts, you can continue the backport process by running:

cherry_picker --continue

If you don't have cherry-picker installed, see the installation guide.

choo121600 pushed a commit to choo121600/airflow that referenced this pull request Feb 22, 2026
* pop(0) to popleft()

* revert with reverse list
Subham-KRLX pushed a commit to Subham-KRLX/airflow that referenced this pull request Mar 4, 2026
* pop(0) to popleft()

* revert with reverse list
dominikhei pushed a commit to dominikhei/airflow that referenced this pull request Mar 11, 2026
* pop(0) to popleft()

* revert with reverse list
Ankurdeewan pushed a commit to Ankurdeewan/airflow that referenced this pull request Mar 15, 2026
* pop(0) to popleft()

* revert with reverse list
radhwene pushed a commit to radhwene/airflow that referenced this pull request Mar 21, 2026
* pop(0) to popleft()

* revert with reverse list
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.

6 participants