From 3d00e0448d2b47a89134a83f6c6509d278cbf2cb Mon Sep 17 00:00:00 2001 From: vrana Date: Fri, 12 Oct 2012 15:01:19 -0700 Subject: [PATCH] Resolve diff property updates in parallel Summary: I was thinking about creating a method `differential.setdiffproperties` updating all properties at once or adding 'properties' to `differential.creatediff` (better) but it will require bumping Conduit version. This looks simpler and with similar effect. We could postpone resolving properties more but I don't want to risk not resolving them after an error. Test Plan: This diff for that it works. Benchmark: 0.55 s before, 0.25 s after (with three properties, the difference will be bigger with more). Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D3689 --- src/workflow/ArcanistDiffWorkflow.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/workflow/ArcanistDiffWorkflow.php b/src/workflow/ArcanistDiffWorkflow.php index 03b5ac37..6ead7f50 100644 --- a/src/workflow/ArcanistDiffWorkflow.php +++ b/src/workflow/ArcanistDiffWorkflow.php @@ -38,6 +38,7 @@ final class ArcanistDiffWorkflow extends ArcanistBaseWorkflow { private $revisionID; private $postponedLinters; private $haveUncommittedChanges = false; + private $diffPropertyFutures = array(); public function getCommandSynopses() { return phutil_console_format(<<updateLintDiffProperty(); $this->updateUnitDiffProperty(); $this->updateLocalDiffProperty(); + $this->resolveDiffPropertyUpdates(); $output_json = $this->getArgument('json'); @@ -499,10 +501,9 @@ EOTEXT $revision = $this->dispatchWillCreateRevisionEvent($revision); - $future = $conduit->callMethod( + $result = $conduit->callMethodSynchronous( 'differential.createrevision', $revision); - $result = $future->resolve(); $revised_message = $conduit->callMethodSynchronous( 'differential.getcommitmessage', @@ -2292,7 +2293,7 @@ EOTEXT * @task diffprop */ private function updateDiffProperty($name, $data) { - $this->getConduit()->callMethodSynchronous( + $this->diffPropertyFutures[] = $this->getConduit()->callMethod( 'differential.setdiffproperty', array( 'diff_id' => $this->getDiffID(), @@ -2301,6 +2302,18 @@ EOTEXT )); } + /** + * Wait for finishing all diff property updates. + * + * @return void + * + * @task diffprop + */ + private function resolveDiffPropertyUpdates() { + Futures($this->diffPropertyFutures)->resolveAll(); + $this->diffPropertyFutures = array(); + } + private function dispatchWillCreateRevisionEvent(array $fields) { $event = $this->dispatchEvent( ArcanistEventType::TYPE_REVISION_WILLCREATEREVISION,