Bug 1315041 - Revive recording of build phases to perfherder; r?catlee draft
authorGregory Szorc <gps@mozilla.com>
Fri, 04 Nov 2016 15:31:03 -0700
changeset 434126 9bb32d8f818d9981d7984634d963885d2cdd1d79
parent 434074 2a1b034ed3fb496b52ae8f4b55e3a18f44a81c29
child 434127 52b07934180bdd173219ba55ed31807493bd6e2d
child 434128 586472f6f477c2aee21e21300515abb65100282e
push id34739
push userbmo:gps@mozilla.com
push dateFri, 04 Nov 2016 22:33:02 +0000
reviewerscatlee
bugs1315041
milestone52.0a1
Bug 1315041 - Revive recording of build phases to perfherder; r?catlee aa1e7115e8d7 removed code related to influx. Unfortunately, part of a deleted class loaded build_resources.json and populated an attribute holding the results. This attribute was consulted by buildbase.BuildScript to send build metrics to perfherder. Oh, the joy of mixins. This commit essentially restores the build_resources.json loading code as part of BuildScript. MozReview-Commit-ID: IuFJd9Y6wFO
testing/mozharness/mozharness/mozilla/building/buildbase.py
--- a/testing/mozharness/mozharness/mozilla/building/buildbase.py
+++ b/testing/mozharness/mozharness/mozilla/building/buildbase.py
@@ -1842,16 +1842,45 @@ or run without that action (ie: --no-{ac
         if return_code:
             self.return_code = self.worst_level(
                 return_code,  self.return_code,
                 AUTOMATION_EXIT_CODES[::-1]
             )
             self.error("'make -k check' did not run successfully. Please check "
                        "log for errors.")
 
+    def _load_build_resources(self):
+        p = self.config.get('build_resources_path') % self.query_abs_dirs()
+        if not os.path.exists(p):
+            self.info('%s does not exist; not loading build resources' % p)
+            return None
+
+        with open(p, 'rb') as fh:
+            resources = json.load(fh)
+
+        if 'duration' not in resources:
+            self.info('resource usage lacks duration; ignoring')
+            return None
+
+        data = {
+            'name': 'build times',
+            'value': resources['duration'],
+            'subtests': [],
+        }
+
+        for phase in resources['phases']:
+            if 'duration' not in phase:
+                continue
+            data['subtests'].append({
+                'name': phase['name'],
+                'value': phase['duration'],
+            })
+
+        return data
+
     def generate_build_stats(self):
         """grab build stats following a compile.
 
         This action handles all statistics from a build: 'count_ctors'
         and then posts to graph server the results.
         We only post to graph server for non nightly build
         """
         if self.config.get('forced_artifact_build'):
@@ -1938,24 +1967,24 @@ or run without that action (ie: --no-{ac
         }
         if installer_size or size_measurements:
             perfherder_data["suites"].append({
                 "name": "installer size",
                 "value": installer_size,
                 "alertThreshold": 0.25,
                 "subtests": size_measurements
             })
-        if (hasattr(self, "build_metrics_summary") and
-            self.build_metrics_summary):
-            perfherder_data["suites"].append(self.build_metrics_summary)
+
+        build_metrics = self._load_build_resources()
+        if build_metrics:
+            perfherder_data['suites'].append(build_metrics)
 
         if perfherder_data["suites"]:
             self.info('PERFHERDER_DATA: %s' % json.dumps(perfherder_data))
 
-
     def sendchange(self):
         if os.environ.get('TASK_ID'):
             self.info("We are not running this in buildbot; skipping")
             return
 
         if self.config.get('enable_talos_sendchange'):
             self._do_sendchange('talos')
         else: