Uh oh!
There was an error while loading. Please reload this page.
improve grid/ti_summaries and grid/runs - #64034
Conversation
5d0add7 to
4691a38Compare4691a38 to
de430afCompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
80559cf to
fad072bComparefad072b to
dbaeda8CompareThere was a problem hiding this comment.
Pull request overview
Improves performance and memory usage of the Grid UI FastAPI endpoints (/grid/runs and /grid/ti_summaries) for DAGs with deep TaskGroup nesting and high mapped task-instance cardinality, while keeping the API contract unchanged.
Changes:
- Refactors
/grid/runsto avoid eager-loading all task instances / history rows just to computedag_versions, using a slimmer post-fetch preloading step instead. - Refactors
/grid/ti_summariesaggregation to use a compact summary object (GridNodeAgg) and avoid building/propagating per-TIdetailslists during TaskGroup rollups. - Adds a unit test covering the “multiple DAG versions per run” response shape for
/grid/runs.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| airflow-core/tests/unit/api_fastapi/core_api/routes/ui/test_grid.py | Adds regression test for multiple dag_versions per run in /grid/runs. |
| airflow-core/src/airflow/api_fastapi/core_api/services/ui/grid.py | Introduces GridNodeAgg and updates aggregate building to avoid propagating TI details. |
| airflow-core/src/airflow/api_fastapi/core_api/routes/ui/grid.py | Updates Grid routes to use slim dag-version prefetching for runs and streaming/compact TI summary aggregation. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
pierrejeambrun
left a comment
There was a problem hiding this comment.
Nice, looking good, thanks.
pierrejeambrun
commented
Apr 2, 2026
Unrelated CI failure, merging. |
Uh oh!
There was an error while loading. Please reload this page.
bbovenzi
commented
Apr 2, 2026
#protm another big improvement to the grid view! |
@bbovenzi do we need this in 3.2.2? or ok to be moved to 3.3.0 as its an improvement |
* improve grid/ti_summaries and grid/runs (#64034) * improve grid/ti_summaries and grid/runs * remove serdag * Fix tests * Undo migration file change --------- Co-authored-by: Henry Chen <henryhenry0512@gmail.com> Co-authored-by: Rahul Vats <43964496+vatsrahul1001@users.noreply.github.com>
* improve grid/ti_summaries and grid/runs (#64034) * improve grid/ti_summaries and grid/runs * remove serdag * Fix tests * Undo migration file change --------- Co-authored-by: Henry Chen <henryhenry0512@gmail.com> Co-authored-by: Rahul Vats <43964496+vatsrahul1001@users.noreply.github.com>
* improve grid/ti_summaries and grid/runs (#64034) * improve grid/ti_summaries and grid/runs * remove serdag * Fix tests * Undo migration file change --------- Co-authored-by: Henry Chen <henryhenry0512@gmail.com> Co-authored-by: Rahul Vats <43964496+vatsrahul1001@users.noreply.github.com>
* improve grid/ti_summaries and grid/runs (#64034) * improve grid/ti_summaries and grid/runs * remove serdag * Fix tests * Undo migration file change --------- Co-authored-by: Henry Chen <henryhenry0512@gmail.com> Co-authored-by: Rahul Vats <43964496+vatsrahul1001@users.noreply.github.com>
Why
The previous implementation scaled poorly for DAGs that combine:
TaskGroupnestingIn particular,
grid/ti_summarieswas keepingdetailsduring aggregation even though those details are not part of the response model. This meant we were paying extra CPU and memory cost for intermediate data that was never returned to the client.I don't think we should keep
detailsin the summary path, because the response does not include them. Keeping them only increases temporary allocations and repeated copying when task-group summaries are rolled up.What
This improves the Grid API performance for DAGs with large mapped task instance cardinality.
There are two main changes:
grid/runsno longer loads alltask_instances/task_instances_historiesfor everyDagRunon the page just to computedag_versions.Instead, it fetches the paginated runs first and then performs a slimmer lookup for the distinct DAG versions needed for the response.
grid/ti_summariesno longer builds and propagates full per-task-instancedetailslists while aggregating task groups.It now keeps only the summary data needed for the response, such as child state counts and min/max dates.
Why
The previous implementation scaled poorly for DAGs that combine:
TaskGroupnestingIn particular,
grid/ti_summarieswas keepingdetailsduring aggregation even though those details are not part of the response model. This meant we were paying extra CPU and memory cost for intermediate data that was never returned to the client.I don't think we should keep
detailsin the summary path, because the response does not include them. Keeping them only increases temporary allocations and repeated copying when task-group summaries are rolled up.Result
This keeps the API contract unchanged, but reduces unnecessary ORM loading and Python-side aggregation work.
On a local benchmark with 5 DAG runs and about 4002 task instances per run:
grid/runsmedian latency improved from ~2955 ms to ~43 msgrid/runstracemalloc peak dropped from ~104.6 MiB to ~1.7 MiBgrid/ti_summariestracemalloc peak dropped from ~5.4 MiB to ~1.7 MiBcloses: #63975
Was generative AI tooling used to co-author this PR?
{pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.