]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Resolve diff property updates in parallel
authorvrana <jakubv@fb.com>
Fri, 12 Oct 2012 22:01:19 +0000 (15:01 -0700)
committervrana <jakubv@fb.com>
Fri, 12 Oct 2012 22:18:56 +0000 (15:18 -0700)
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

index 03b5ac374dd1bb7fff229cb17967e96d8c72d99a..6ead7f50e4a49db380dcca4096fc400a6798a375 100644 (file)
@@ -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(<<<EOTEXT
@@ -459,6 +460,7 @@ EOTEXT
     $this->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,