viiccwen opened a new pull request, #69849:
URL: https://github.com/apache/airflow/pull/69849

    <!-- SPDX-License-Identifier: Apache-2.0
         https://www.apache.org/licenses/LICENSE-2.0 -->
   
   <!--
   Thank you for contributing!
   
   Please provide above a brief description of the changes made in this pull 
request.
   Write a good git commit message following this guide: 
http://chris.beams.io/posts/git-commit/
   
   Please make sure that your code changes are covered with tests.
   And in case of new features or big changes remember to adjust the 
documentation.
   
   For user-facing UI changes, please attach before/after screenshots (or a 
short
   screen recording) so reviewers can assess the visual impact.
   
   Feel free to ping (in general) for the review if you do not see reaction for 
a few days
   (72 Hours is the minimum reaction time you can expect from volunteers) - we 
sometimes miss notifications.
   
   In case of an existing issue, reference it using one of the following:
   
   * closes: #ISSUE
   * related: #ISSUE
   -->
   
   ## Description
   
   closes #69848 
   
   Asset-triggered Dag run creation currently materializes every matching 
`AssetEvent` ORM object, including its JSON metadata, before writing the Dag 
run association rows. Large event windows can therefore cause scheduler memory 
spikes far beyond the raw payload size.
   
   This change writes the association rows with a server-side `INSERT ... 
SELECT` while preserving the existing event predicates, transaction boundary, 
exact event membership, and relationship behavior.
   
   The partitioned-asset path uses the same set-based association helper. No 
schema or configuration change is needed.
   
   ## Benchmark
   
   The benchmark invokes the real scheduler path on SQLite, PostgreSQL, and 
MySQL with a 512-byte JSON
   payload per event. Setup is outside the measured interval.
   
   | Database | Events | Duration before → after | Speedup | Python peak before 
→ after | Peak reduction | RSS increase before → after |
   |---|---:|---:|---:|---:|---:|---:|
   | SQLite | 1,000 | 0.537 → 0.255s | 2.11× | 6.23 → 1.91 MB | 69.3% | 0.17 → 
0.17 MB |
   | SQLite | 10,000 | 1.785 → 0.024s | 74.38× | 54.24 → 0.11 MB | 99.8% | 
79.98 → 0.00 MB |
   | SQLite | 50,000 | 12.545 → 0.071s | **176.69×** | 274.21 → 0.13 MB | 
**99.95%** | 465.98 → 0.00 MB |
   | PostgreSQL | 1,000 | 0.339 → 0.237s | 1.43× | 7.39 → 1.84 MB | 75.1% | 
1.88 → 0.00 MB |
   | PostgreSQL | 10,000 | 2.510 → 0.096s | **26.15×** | 62.34 → 0.12 MB | 
99.8% | 108.78 → 0.00 MB |
   | PostgreSQL | 50,000 | 10.046 → 0.688s | 14.60× | 289.72 → 0.14 MB | 
**99.95%** | 483.77 → 0.00 MB |
   | MySQL | 1,000 | 2.622 → 0.956s | 2.74× | 6.76 → 1.89 MB | 72.0% | 0.75 → 
0.00 MB |
   | MySQL | 10,000 | 4.478 → 0.185s | **24.21×** | 54.54 → 0.11 MB | 99.8% | 
98.21 → 0.00 MB |
   | MySQL | 50,000 | 21.502 → 1.977s | 10.88× | 272.63 → 0.13 MB | **99.95%** 
| 475.28 → 0.00 MB |
   
   The 1,000-event result includes first-call and tracing warm-up overhead.
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   <!--
   If generative AI tooling has been used in the process of authoring this PR, 
please
   change below checkbox to `[X]` followed by the name of the tool, uncomment 
the "Generated-by".
   -->
   
   - [x] Yes - Codex (GPT 5.6 Sol)
   
   <!--
   Generated-by: [Tool Name] following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
   -->
   
   ---
   
   * Read the **[Pull Request 
Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)**
 for more information. Note: commit author/co-author name and email in commits 
become permanently public when merged.
   * For fundamental code changes, an Airflow Improvement Proposal 
([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals))
 is needed.
   * When adding dependency, check compliance with the [ASF 3rd Party License 
Policy](https://www.apache.org/legal/resolved.html#category-x).
   * For significant user-facing changes create newsfragment: 
`{pr_number}.significant.rst`, in 
[airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/newsfragments).
 You can add this file in a follow-up commit after the PR is created so you 
know the PR number.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to