@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.

Speed up loading of diffs with a lot of unit test failures

Summary:
We've been having trouble with viewing diffs timing out when there's a lot of unit test failures. It was caused by formatting userdata for every single failure. The expensive part of this was actually creating the engine for every result, so moved the construction outside of the loop.

Diffs that timed out (2 min) loading before load in around 6 seconds now.

Test Plan: Loaded diffs that used to time out. Verified that details still looked right when Show Full Unit Test Results Is Clicked.

Reviewers: epriestley, keegancsmith, lifeihuang, #blessed_reviewers

Reviewed By: epriestley

CC: Korvin, epriestley, aran, andrewjcg

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

+23 -12
+20 -11
src/applications/differential/field/specification/DifferentialUnitFieldSpecification.php
··· 70 70 $udata[$key]['sort'] = idx($sort_map, idx($test, 'result')); 71 71 } 72 72 $udata = isort($udata, 'sort'); 73 - 74 - foreach ($udata as $test) { 73 + $engine = new PhabricatorMarkupEngine(); 74 + $engine->setViewer($this->getUser()); 75 + $markup_objects = array(); 76 + foreach ($udata as $key => $test) { 77 + $userdata = idx($test, 'userdata'); 78 + if ($userdata) { 79 + if ($userdata !== false) { 80 + $userdata = str_replace("\000", '', $userdata); 81 + } 82 + $markup_object = id(new PhabricatorMarkupOneOff()) 83 + ->setContent($userdata) 84 + ->setPreserveLinebreaks(true); 85 + $engine->addObject($markup_object, 'default'); 86 + $markup_objects[$key] = $markup_object; 87 + } 88 + } 89 + $engine->process(); 90 + foreach ($udata as $key => $test) { 75 91 $result = idx($test, 'result'); 76 92 77 93 $default_hide = false; ··· 110 126 'show' => $show, 111 127 ); 112 128 113 - $userdata = idx($test, 'userdata'); 114 - if ($userdata) { 115 - if ($userdata !== false) { 116 - $userdata = str_replace("\000", '', $userdata); 117 - } 118 - $engine = PhabricatorMarkupEngine::newDifferentialMarkupEngine(); 119 - $engine->setConfig('viewer', $this->getUser()); 120 - $userdata = $engine->markupText($userdata); 129 + if (isset($markup_objects[$key])) { 121 130 $rows[] = array( 122 131 'style' => 'details', 123 - 'value' => $userdata, 132 + 'value' => $engine->getOutput($markup_objects[$key], 'default'), 124 133 'show' => false, 125 134 ); 126 135 if (empty($hidden['details'])) {
+3 -1
src/infrastructure/markup/PhabricatorMarkupEngine.php
··· 242 242 } 243 243 244 244 foreach ($objects as $key => $info) { 245 - if (isset($blocks[$key])) { 245 + // False check in case MySQL doesn't support unicode characters 246 + // in the string (T1191), resulting in unserialize returning false. 247 + if (isset($blocks[$key]) && $blocks[$key]->getCacheData() !== false) { 246 248 // If we already have a preprocessing cache, we don't need to rebuild 247 249 // it. 248 250 continue;