From 0c34e6b35b61c6572ec29611cdeea90a075f3717 Mon Sep 17 00:00:00 2001 From: Kaxil Naik Date: Wed, 1 Apr 2020 22:40:51 +0100 Subject: [PATCH] [AIRFLOW-6871] optimize tree view for large DAGs (#7492) This change reduces page size by more than 10X and reduces page load time by 3-5X. As a result, the tree view can now load large DAGs that were causing 5XX error without the patch. List of optimizations applied to the view handler: * only seralize used task instance attributes to json instead of the whole ORM object * encode task instance attributes as array instead of dict * encode datetime in unix timestamp instead of iso formmat string * push task instance attribute construction into client side JS * remove redundant task instance attributes * simplify reduce_nodes() logic, remove unnecessary if statements * seralize JSON as string to be used with JSON.parse on the client side to speed up browser JS parse time * remove spaces in seralized JSON string to reduce payload size Co-Authored-By: QP Hou (cherry-picked from c1c2d6a1a13350672de52b01a9456103a8dc9b2e) --- airflow/www_rbac/templates/airflow/tree.html | 100 ++++++++++++--- airflow/www_rbac/views.py | 126 ++++++++++++------- 2 files changed, 167 insertions(+), 59 deletions(-) diff --git a/airflow/www_rbac/templates/airflow/tree.html b/airflow/www_rbac/templates/airflow/tree.html index 9bf29c8643af32..7b6288fd72213a 100644 --- a/airflow/www_rbac/templates/airflow/tree.html +++ b/airflow/www_rbac/templates/airflow/tree.html @@ -84,8 +84,59 @@