@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Use PhabricatorCachedClassMapQuery when querying object PHID types

Summary:
Ref T11954. When we query for Conduit tokens, we load the associated objects (users) by PHID.

Currently, querying objects by PHID requires us to load every PHIDType class, when we can know which specific classes we actually need (e.g., just `UserPHIDType`, if only user PHIDs are present in the query).

Use PhabricatorCachedClassMapQuery to reduce the number of classes we load on this pathway.

Test Plan:
- Used `ab -n100` to roughly measure a ~5% performance improvement?
- This measurement feels a little flimsy but the XHProf profile is cleaner, at least.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T11954

Differential Revision: https://secure.phabricator.com/D16997

+30 -9
+17 -7
src/applications/phid/query/PhabricatorObjectQuery.php
··· 29 29 $this->namedResults = array(); 30 30 } 31 31 32 - $types = PhabricatorPHIDType::getAllTypes(); 33 - if ($this->types) { 34 - $types = array_select_keys($types, $this->types); 35 - } 36 - 37 32 $names = array_unique($this->names); 38 33 $phids = $this->phids; 39 34 ··· 51 46 } 52 47 } 53 48 54 - $phids = array_unique($phids); 55 - 56 49 if ($names) { 50 + $types = PhabricatorPHIDType::getAllTypes(); 51 + if ($this->types) { 52 + $types = array_select_keys($types, $this->types); 53 + } 57 54 $name_results = $this->loadObjectsByName($types, $names); 58 55 } else { 59 56 $name_results = array(); 60 57 } 61 58 62 59 if ($phids) { 60 + $phids = array_unique($phids); 61 + 62 + $phid_types = array(); 63 + foreach ($phids as $phid) { 64 + $phid_type = phid_get_type($phid); 65 + $phid_types[$phid_type] = $phid_type; 66 + } 67 + 68 + $types = PhabricatorPHIDType::getTypes($phid_types); 69 + if ($this->types) { 70 + $types = array_select_keys($types, $this->types); 71 + } 72 + 63 73 $phid_results = $this->loadObjectsByPHID($types, $phids); 64 74 } else { 65 75 $phid_results = array();
+13 -2
src/applications/phid/type/PhabricatorPHIDType.php
··· 144 144 * @return dict<string, PhabricatorPHIDType> Map of type constants to types. 145 145 */ 146 146 final public static function getAllTypes() { 147 + return self::newClassMapQuery() 148 + ->execute(); 149 + } 150 + 151 + final public static function getTypes(array $types) { 152 + return id(new PhabricatorCachedClassMapQuery()) 153 + ->setClassMapQuery(self::newClassMapQuery()) 154 + ->setMapKeyMethod('getTypeConstant') 155 + ->loadClasses($types); 156 + } 157 + 158 + private static function newClassMapQuery() { 147 159 return id(new PhutilClassMapQuery()) 148 160 ->setAncestorClass(__CLASS__) 149 - ->setUniqueMethod('getTypeConstant') 150 - ->execute(); 161 + ->setUniqueMethod('getTypeConstant'); 151 162 } 152 163 153 164