From 6933ee5fb86dc4afd0c5e93e98f13f382e32a15e Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 16 Jun 2015 19:32:58 -0700 Subject: [PATCH] Don't spend ridiculous amounts of time rebuilding orderable columns Summary: Ref T8575. Because orderable columns need to build custom fields, they are relatively expensive to build. Use the request cache. (The request cache is technically more correct than `static`, because configuration may change between requests and we may eventually reuse interpreters.) Test Plan: Saw home page time drop 39% (from 462ms to 283ms). Reviewers: btrahan, avivey Reviewed By: avivey Subscribers: avivey, epriestley Maniphest Tasks: T8575 Differential Revision: https://secure.phabricator.com/D13322 --- .../policy/PhabricatorCursorPagedPolicyAwareQuery.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php b/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php index 4d0f96bde5..772be350a9 100644 --- a/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php +++ b/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php @@ -872,6 +872,15 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery * @task order */ public function getOrderableColumns() { + $cache = PhabricatorCaches::getRequestCache(); + $class = get_class($this); + $cache_key = 'query.orderablecolumns.'.$class; + + $columns = $cache->getKey($cache_key); + if ($columns !== null) { + return $columns; + } + $columns = array( 'id' => array( 'table' => $this->getPrimaryTableAlias(), @@ -909,6 +918,8 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery } } + $cache->setKey($cache_key, $columns); + return $columns; }