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

   ## What this does
   
   `write_dag()` computes `cls.hash(dag.data)` to compare against the stored
   hash. When the DAG has changed, it then calls `cls(dag)` which recomputes
   the same hash internally. This PR passes the already-known hash via
   `_precomputed_hash` to skip the redundant computation.
   
   When `reused_deadline_data` mutates `dag.data` after the initial hash
   comparison, the precomputed hash is stale, so it is recomputed once more
   right after the mutation before being passed in.
   
   ## Why
   
   Addresses the feedback from #70715 — the reviewer correctly pointed out
   that the original approach (merging hash and storage JSON generation)
   regressed the common unchanged-DAG path and altered stored bytes. This
   approach is minimal: it only eliminates the redundant `hash()` call on
   the changed-DAG path without touching the unchanged-DAG path or altering
   storage format.
   
   ## What does NOT change
   
   - The hash value produced is **identical** to before
   - The stored JSON is **identical**
   - `hash()` remains a public classmethod with the same signature
   - The unchanged-DAG (common) path is untouched — no performance regression
   - All existing `test_serialized_dag` tests pass unmodified
   
   ## Testing
   
   5 new tests in `TestPrecomputedHash`:
   - `_precomputed_hash` skips internal `hash()` call
   - Storage bytes identical with and without precomputed hash
   - Without precomputed hash, `hash()` called normally (backward compat)
   - `write_dag` passes precomputed hash on changed-DAG path
   - Deadline UUID mutation does not pass stale hash
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [x]  Yes — Claude Code (Anthropic)


-- 
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