john-rodriguez-mgni opened a new pull request, #61483:
URL: https://github.com/apache/airflow/pull/61483
## Summary
This PR addresses a significant performance issue in the `/ui/dags` endpoint
where page load times scaled poorly with the number of DAGs (12-16 seconds for
just 25 DAGs in our testing).
Two optimizations are implemented:
### 1. Cache URLSafeSerializer for file_token generation
Previously, a new `URLSafeSerializer` was instantiated and
`conf.get_mandatory_value()` was called for **every DAG** in the response. Now
uses `@lru_cache` to create the serializer once and reuse it.
### 2. Eliminate redundant Pydantic validation in response construction
The original pattern used:
```python
DAGWithLatestDagRunsResponse.model_validate({
**DAGResponse.model_validate(dag).model_dump(),
...
})
```
This caused triple serialization overhead per DAG (validate → dump →
validate). The fix validates once with `DAGResponse.model_validate()`, then
uses `model_construct()` to build `DAGWithLatestDagRunsResponse` without
redundant validation.
## Results
Together, these changes reduced page load time from **12-16 seconds to
~130ms** in our dev environment.
## Test Plan
- [ ] Existing unit tests pass
- [ ] Manual testing of /ui/dags endpoint with varying numbers of DAGs
- [ ] Verify file_token generation still works correctly
Made with [Cursor](https://cursor.com)
--
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]