Bug 1544686 - [raptor] Make Gecko profiler threads customizable in the harness. r=rwood
authorHenrik Skupin <mail@hskupin.info>
Tue, 23 Apr 2019 15:37:30 +0000
changeset 471806 201fb70499ef00904a0a728f5934b1ea66bddd7b
parent 471805 9ff6837b1526aaae3eca6546245ace6710c20a40
child 471807 50b7f764f4afc39d21c1b96c8c11505daaf6e4a4
push id112953
push usershindli@mozilla.com
push dateTue, 30 Apr 2019 04:15:04 +0000
treeherdermozilla-inbound@b3612d6d6448 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrwood
bugs1544686
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1544686 - [raptor] Make Gecko profiler threads customizable in the harness. r=rwood Differential Revision: https://phabricator.services.mozilla.com/D28046
testing/raptor/raptor/manifest.py
testing/raptor/webext/raptor/runner.js
--- a/testing/raptor/raptor/manifest.py
+++ b/testing/raptor/raptor/manifest.py
@@ -162,27 +162,33 @@ def write_test_settings_json(args, test_
             subtest_lower_is_better)
 
     if test_details.get("alert_threshold", None) is not None:
         test_settings['raptor-options']['alert_threshold'] = float(test_details['alert_threshold'])
 
     if test_details.get("screen_capture", None) is not None:
         test_settings['raptor-options']['screen_capture'] = test_details.get("screen_capture")
 
-    # if gecko profiling is enabled, write profiling settings for webext
+    # if Gecko profiling is enabled, write profiling settings for webext
     if test_details.get("gecko_profile", False):
-        test_settings['raptor-options']['gecko_profile'] = True
-        # when profiling, if webRender is enabled we need to set that, so
-        # the runner can add the web render threads to gecko profiling
-        test_settings['raptor-options']['gecko_profile_interval'] = \
-            float(test_details.get("gecko_profile_interval", 0))
-        test_settings['raptor-options']['gecko_profile_entries'] = \
-            float(test_details.get("gecko_profile_entries", 0))
-        if str(os.getenv('MOZ_WEBRENDER')) == '1':
-            test_settings['raptor-options']['webrender_enabled'] = True
+        threads = 'GeckoMain,Compositor'
+
+        # With WebRender enabled profile some extra threads
+        if os.getenv('MOZ_WEBRENDER') == '1':
+            threads = '{},Renderer,WR'.format(threads)
+
+        if test_details.get('gecko_profile_threads'):
+            threads = '{0},{1}'.format(threads, test_details.get('gecko_profile_threads'))
+
+        test_settings['raptor-options'].update({
+            'gecko_profile': True,
+            'gecko_profile_entries': int(test_details.get('gecko_profile_entries')),
+            'gecko_profile_interval': int(test_details.get('gecko_profile_interval')),
+            'gecko_profile_threads': threads,
+        })
 
     if test_details.get("newtab_per_cycle", None) is not None:
         test_settings['raptor-options']['newtab_per_cycle'] = \
             bool(test_details['newtab_per_cycle'])
 
     settings_file = os.path.join(tests_dir, test_details['name'] + '.json')
     try:
         with open(settings_file, 'w') as out_file:
--- a/testing/raptor/webext/raptor/runner.js
+++ b/testing/raptor/webext/raptor/runner.js
@@ -56,17 +56,17 @@ var isFCPPending = false;
 var isDCFPending = false;
 var isTTFIPending = false;
 var isLoadTimePending = false;
 var isBenchmarkPending = false;
 var pageTimeout = 10000; // default pageload timeout
 var geckoProfiling = false;
 var geckoInterval = 1;
 var geckoEntries = 1000000;
-var webRenderEnabled = false;
+var geckoThreads = [];
 var debugMode = 0;
 var screenCapture = false;
 
 var results = {"name": "",
                "page": "",
                "type": "",
                "browser_cycle": 0,
                "expected_browser_cycles": 0,
@@ -111,30 +111,23 @@ function getTestSettings() {
         results.expected_browser_cycles = settings.expected_browser_cycles;
         results.cold = settings.cold;
         results.unit = settings.unit;
         results.subtest_unit = settings.subtest_unit;
         results.lower_is_better = settings.lower_is_better === true;
         results.subtest_lower_is_better = settings.subtest_lower_is_better === true;
         results.alert_threshold = settings.alert_threshold;
 
-        if (settings.gecko_profile !== undefined) {
-          if (settings.gecko_profile === true) {
-            geckoProfiling = true;
-            results.extra_options = ["gecko_profile"];
-            if (settings.gecko_profile_interval !== undefined) {
-              geckoInterval = settings.gecko_profile_interval;
-            }
-            if (settings.gecko_profile_entries !== undefined) {
-              geckoEntries = settings.gecko_profile_entries;
-            }
-            if (settings.webrender_enabled !== undefined) {
-              webRenderEnabled = settings.webrender_enabled;
-            }
-          }
+        if (settings.gecko_profile === true) {
+          results.extra_options = ["gecko_profile"];
+
+          geckoProfiling = true;
+          geckoEntries = settings.gecko_profile_entries;
+          geckoInterval = settings.gecko_profile_interval;
+          geckoThreads = settings.gecko_profile_threads;
         }
 
         if (settings.screen_capture !== undefined) {
           screenCapture = settings.screen_capture;
         }
 
         if (settings.newtab_per_cycle !== undefined) {
           reuseTab = settings.newtab_per_cycle;
@@ -313,30 +306,23 @@ function onCaptured(screenshotUri) {
   postToControlServer("screenshot", [screenshotUri, testName, pageCycle]);
 }
 
 function onError(error) {
   console.log("Screenshot captured failed!");
   console.log(`Error: ${error}`);
 }
 
-
 async function startGeckoProfiling() {
-  var _threads;
-  if (webRenderEnabled) {
-    _threads = ["GeckoMain", "Compositor", "WR", "Renderer"];
-  } else {
-    _threads = ["GeckoMain", "Compositor"];
-  }
-  postToControlServer("status", "starting gecko profiling");
+  postToControlServer("status", `starting Gecko profiling for threads: ${geckoThreads}`);
   await browser.geckoProfiler.start({
     bufferSize: geckoEntries,
     interval: geckoInterval,
     features: ["js", "leaf", "stackwalk", "threads", "responsiveness"],
-    threads: _threads,
+    threads: geckoThreads.split(","),
   });
 }
 
 async function stopGeckoProfiling() {
   postToControlServer("status", "stopping gecko profiling");
   await browser.geckoProfiler.stop();
 }