[ 
https://issues.apache.org/jira/browse/AIRFLOW-5930?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16993866#comment-16993866
 ] 

ASF GitHub Bot commented on AIRFLOW-5930:
-----------------------------------------

ashb commented on pull request #6792: [AIRFLOW-5930] Use cached-SQL query 
building for hot-path queries
URL: https://github.com/apache/airflow/pull/6792
 
 
   Make sure you have checked _all_ steps below.
   
   ### Jira
   
   - [x] https://issues.apache.org/jira/browse/AIRFLOW-5930
   
   ### Description
   
   - [ ] Building the SQL string for this query takes up about 25% of the time 
that the DAG parsing process spends, so replacing this one query should help 
speed up the rate at which the scheduler can queue tasks.
   
     See https://docs.sqlalchemy.org/en/13/orm/extensions/baked.html for more 
info. The docs explain a lot of how/why this works, so rather than rebuilding 
them from string 10s of times (once per task per active dag run) we cache the 
build SQL string!
   
     I will collect up-to-date performance numbers against master, but this 
makes the "dag parsing" process of the scheduler (which creates and updates dag 
runs, and creates Task Instances) about 2x quicker:
   
     Concurrent DagRuns | Tasks | Before | After | Speedup
     -- | -- | -- | -- | --
     2 | 12 | 0.146s (±0.0163s) | 0.074s (±0.0037s) | x1.97
     10 | 12 | 1.11s (±0.0171s) | 0.266s (±0.0229s) | x4.17
     40 | 12 | 4.28s (±0.101s) | 0.852s (±0.0113s) | x5.02
     40 | 40 | 6.72s (±0.067s) | 2.659s (±0.0283s) | x2.53
   
   
   
   ### Tests
   
   - [x] No new tests, no change in behaviour.
   
   ### Commits
   
   - [ ] My commits all reference Jira issues in their subject lines, and I 
have squashed multiple commits if they address the same issue. In addition, my 
commits follow the guidelines from "[How to write a good git commit 
message](http://chris.beams.io/posts/git-commit/)":
     1. Subject is separated from body by a blank line
     1. Subject is limited to 50 characters (not including Jira issue reference)
     1. Subject does not end with a period
     1. Subject uses the imperative mood ("add", not "adding")
     1. Body wraps at 72 characters
     1. Body explains "what" and "why", not "how"
   
   ### Documentation
   
   - [ ] In case of new functionality, my PR adds documentation that describes 
how to use it.
     - All the public functions and the classes in the PR contain docstrings 
that explain what it does
     - If you implement backwards incompatible changes, please leave a note in 
the [Updating.md](https://github.com/apache/airflow/blob/master/UPDATING.md) so 
we can assign it to a appropriate release
   
 
----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> Reduce time spent building SQL strings
> --------------------------------------
>
>                 Key: AIRFLOW-5930
>                 URL: https://issues.apache.org/jira/browse/AIRFLOW-5930
>             Project: Apache Airflow
>          Issue Type: Improvement
>          Components: scheduler
>    Affects Versions: 2.0.0
>            Reporter: Ash Berlin-Taylor
>            Assignee: Ash Berlin-Taylor
>            Priority: Major
>
> My profling of the scheduler work turned up a lot of cases where the 
> scheduler_job/dag parser process was spending a lot of time building (not 
> executing!) the SQL string.
> This can be improved with 
> https://docs.sqlalchemy.org/en/13/orm/extensions/baked.html



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to