Bug 1425308 - Automatically view local talos gecko profile in perf-html.io; r?jmaher draft
authorRob Wood <rwood@mozilla.com>
Mon, 28 May 2018 11:51:02 -0400
changeset 800600 47f87e64a4c2bb7263eabcaebb207882debfd426
parent 800535 1d53c55e96dfbcd965b8a722539ea049bb45fffe
push id111419
push userrwood@mozilla.com
push dateMon, 28 May 2018 15:51:31 +0000
Bug 1425308 - Automatically view local talos gecko profile in perf-html.io; r?jmaher When running talos locally with --geckoProfile set, the latest gecko-profile archive will automatically be loaded in perf-html.io using the view-gecko-profile tool. To disable this automatic perf-html.io launching, set TALOS_DISABLE_PERFHTMLIO_LAUNCH=1. MozReview-Commit-ID: 8tpLnsPAXD9
--- a/testing/talos/talos/cmdline.py
+++ b/testing/talos/talos/cmdline.py
@@ -86,17 +86,20 @@ def create_parser(mach_interface=False):
                  "run and output the results in $MOZ_UPLOAD_DIR.")
     add_arg('--spsProfileInterval', dest='gecko_profile_interval', type=float,
             help="(Deprecated - Use --geckoProfileInterval instead.) How "
                  "frequently to take samples (ms)")
     add_arg('--spsProfileEntries', dest="gecko_profile_entries", type=int,
             help="(Deprecated - Use --geckoProfileEntries instead.) How "
                  "many samples to take with the profiler")
     add_arg('--geckoProfile', action="store_true", dest="gecko_profile",
-            help="Profile the run and output the results in $MOZ_UPLOAD_DIR.")
+            help="Profile the run and output the results in $MOZ_UPLOAD_DIR. "
+                 "After talos is finished, perf-html.io will be launched in Firefox so you "
+                 "can analyze the local profiles. To disable auto-launching of perf-html.io "
+                 "set the TALOS_DISABLE_PERFHTMLIO_LAUNCH=1 env var.")
     add_arg('--geckoProfileInterval', dest='gecko_profile_interval', type=float,
             help="How frequently to take samples (ms)")
     add_arg('--geckoProfileEntries', dest="gecko_profile_entries", type=int,
             help="How many samples to take with the profiler")
     add_arg('--extension', dest='extensions', action='append',
             help="Extension to install while running")
     add_arg('--fast', action='store_true',
--- a/testing/talos/talos/gecko_profile.py
+++ b/testing/talos/talos/gecko_profile.py
@@ -199,16 +199,20 @@ class GeckoProfile(object):
                     arc.write(profile_path, path_in_zip)
                 except Exception:
                         "Failed to copy profile {0} as {1} to"
                         " archive {2}".format(profile_path,
+            # write latest gecko profie archive name to env var so
+            # later we can use the view-gecko-profile tool and view it
+            os.environ['TALOS_LATEST_GECKO_PROFILE_ARCHIVE'] = self.profile_arcname
+            LOG.info("set TALOS_LATEST_GECKO_PROFILE_ARCHIVE to %s" % self.profile_arcname)
     def clean(self):
         Clean up temp folders created with the instance creation.
         if self.cleanup:
             for symbol_path in self.symbol_paths.values():
--- a/testing/talos/talos/run_tests.py
+++ b/testing/talos/talos/run_tests.py
@@ -323,16 +323,30 @@ def run_tests(config, browser_config):
     # output results
     if results_urls and not browser_config['no_upload_results']:
         if browser_config['develop'] or config['gecko_profile']:
             print("Thanks for running Talos locally. Results are in %s"
                   % (results_urls['output_urls']))
+    # if gecko profiling was turned on, use the view-gecko-profile tool
+    # to automatically load the latest gecko profile in perf-html.io
+    if config['gecko_profile']:
+        # unless TALOS_DISABLE_PERFHTMLIO_LAUNCH is set
+        if os.environ.get('TALOS_DISABLE_PERFHTMLIO_LAUNCH', '0') == '1':
+            LOG.info("Not launching perf-html.io because TALOS_DISABLE_PERFHTMLIO_LAUNCH=1")
+        else:
+            profile_zip = os.environ.get('TALOS_LATEST_GECKO_PROFILE_ARCHIVE', 0)
+            if profile_zip is not None:
+                LOG.info('Auto-loading this profile in perfhtml.io: %s' % profile_zip)
+                # DO IT
+            else:
+                LOG.info("No local gecko profiles were found so not launching perf-html.io")
     # we will stop running tests on a failed test, or we will return 0 for
     # green
     return 0
 def make_comparison_result(base_and_reference_results):
     ''' Receive a test result object meant to be used as a base vs reference test. The result
     object will have one test with two subtests; instead of traditional subtests we want to