bug 1237619: Add system and command metadata to resouce_usage.json r?gps draft
authorDan Minor <dminor@mozilla.com>
Wed, 13 Jan 2016 06:42:51 -0500
changeset 321373 f6833ac20a24f92ca16da2ec14c63ba8ac039f4e
parent 321372 04ddf6347773a042ffb888182c562e67dc143255
child 321374 e4a8e3056a69a59568dd4271a96cc22163796898
push id9364
push userdminor@mozilla.com
push dateWed, 13 Jan 2016 13:08:09 +0000
reviewersgps
bugs1237619
milestone46.0a1
bug 1237619: Add system and command metadata to resouce_usage.json r?gps This adds metadata about the local system to resource_usage.json that will be useful for analysis when we start collecting these results. Some of it is redundant with data collected for individual tiers, but having it available at a top level should make analysis easier.
python/mozbuild/mozbuild/controller/building.py
python/mozbuild/mozbuild/resources/html-build-viewer/index.html
--- a/python/mozbuild/mozbuild/controller/building.py
+++ b/python/mozbuild/mozbuild/controller/building.py
@@ -3,16 +3,17 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from __future__ import absolute_import, unicode_literals
 
 import getpass
 import json
 import logging
 import os
+import platform
 import subprocess
 import sys
 import time
 import which
 
 from collections import (
     namedtuple,
     OrderedDict,
@@ -366,17 +367,18 @@ class BuildMonitor(MozbuildObject):
         if excessive is not None and (sin or sout):
             sin /= 1048576
             sout /= 1048576
             self.log(logging.WARNING, 'swap_activity',
                 {'sin': sin, 'sout': sout},
                 'Swap in/out (MB): {sin}/{sout}')
 
         o = dict(
-            version=1,
+            version=2,
+            argv=sys.argv,
             start=self.start_time,
             end=self.end_time,
             duration=self.end_time - self.start_time,
             resources=[],
             cpu_percent=cpu_percent,
             cpu_times=cpu_times,
             io=io,
         )
@@ -398,16 +400,41 @@ class BuildMonitor(MozbuildObject):
                 swap=list(usage.swap),
             )
 
             self.tiers.add_resources_to_dict(entry, start=usage.start,
                     end=usage.end)
 
             o['resources'].append(entry)
 
+        # TODO: it would be nice to collect data on the storage device as well
+        o['system'] = dict(
+            architecture=list(platform.architecture()),
+            logical_cpu_count=psutil.cpu_count(),
+            machine=platform.machine(),
+            physical_cpu_count=psutil.cpu_count(logical=False),
+            python_version=platform.python_version(),
+            release=platform.release(),
+            system=platform.system(),
+            swap_total=psutil.swap_memory()[0],
+            version=platform.version(),
+            vmem_total=psutil.virtual_memory()[0],
+        )
+
+        if platform.system() == 'Linux':
+            dist = list(platform.linux_distribution())
+            o['system']['linux_distribution'] = dist
+        elif platform.system() == 'Windows':
+            win32_ver=list((platform.win32_ver())),
+            o['system']['win32_ver'] = win32_ver
+        elif platform.system() == 'Darwin':
+            # mac version is a special Cupertino snowflake
+            r, v, m = platform.mac_ver()
+            o['system']['mac_ver'] = [r, list(v), m]
+
         return o
 
     def _log_resource_usage(self, prefix, m_type, duration, cpu_percent,
         cpu_times, io, extra_params={}):
 
         params = dict(
             duration=duration,
             cpu_percent=cpu_percent,
--- a/python/mozbuild/mozbuild/resources/html-build-viewer/index.html
+++ b/python/mozbuild/mozbuild/resources/html-build-viewer/index.html
@@ -51,18 +51,18 @@ svg {
   <body>
     <script>
 var currentResources;
 
 /**
  * Interface for a build resources JSON file.
  */
 function BuildResources(data) {
-  if (data.version != 1) {
-    throw new Error("Only version 1 of the JSON format is supported.");
+  if (data.version != 1 && data.version != 2) {
+    throw new Error("Unsupported version of the JSON format: " + data.version);
   }
 
   this.resources = [];
 
   var cpu_fields = data.cpu_times_fields;
   var io_fields = data.io_fields;
   var virt_fields = data.virt_fields;
   var swap_fields = data.swap_fields;