Bug 1463408 part 2 - Add profiler feature seqstyle for forcing sequential styling when profiling. r?mstange,emilio draft
authorXidorn Quan <me@upsuper.org>
Wed, 23 May 2018 19:35:03 +1000 (2018-05-23)
changeset 799151 dcade557435696733f7be4cd43539cd96e819e9e
parent 799150 ad9b870e4680cdf629f5be224ae8f99d2792cb89
push id110939
push userxquan@mozilla.com
push dateThu, 24 May 2018 01:22:29 +0000 (2018-05-24)
reviewersmstange, emilio
bugs1463408
milestone62.0a1
Bug 1463408 part 2 - Add profiler feature seqstyle for forcing sequential styling when profiling. r?mstange,emilio MozReview-Commit-ID: 6fm8j7z1EbJ
browser/components/extensions/schemas/geckoProfiler.json
devtools/client/performance-new/components/Settings.js
devtools/server/tests/browser/browser_perf-04.js
layout/style/ServoStyleSet.cpp
tools/profiler/public/GeckoProfiler.h
--- a/browser/components/extensions/schemas/geckoProfiler.json
+++ b/browser/components/extensions/schemas/geckoProfiler.json
@@ -26,16 +26,17 @@
           "java",
           "js",
           "leaf",
           "mainthreadio",
           "memory",
           "privacy",
           "responsiveness",
           "screenshots",
+          "seqstyle",
           "stackwalk",
           "tasktracer",
           "threads",
           "trackopts"
         ]
       }
     ],
     "functions": [
--- a/devtools/client/performance-new/components/Settings.js
+++ b/devtools/client/performance-new/components/Settings.js
@@ -124,16 +124,21 @@ const featureCheckboxes = [
       "(RSS) and unique set size (USS)."
   },
   {
     name: "Privacy",
     value: "privacy",
     title: "Remove some potentially user-identifiable information."
   },
   {
+    name: "Sequential Styling",
+    value: "seqstyle",
+    title: "Disable parallel traversal in styling."
+  },
+  {
     name: "JIT Optimizations",
     value: "trackopts",
     title: "Track JIT optimizations in the JS engine."
   },
   {
     name: "TaskTracer",
     value: "tasktracer",
     title: "Enable TaskTracer (Experimental, requires custom build.)"
--- a/devtools/server/tests/browser/browser_perf-04.js
+++ b/devtools/server/tests/browser/browser_perf-04.js
@@ -15,17 +15,17 @@ add_task(async function() {
   is(await front.isLockedForPrivateBrowsing(), false,
     "The browser is not in private browsing mode.");
   is(await front.isActive(), false,
     "The profiler is not active yet.");
 
   front.once("profiler-started", (entries, interval, features) => {
     is(entries, 1000, "Should apply entries by startProfiler");
     is(interval, 0.1, "Should apply interval by startProfiler");
-    is(features, 0x102, "Should apply features by startProfiler");
+    is(features, 0x202, "Should apply features by startProfiler");
   });
 
   // Start the profiler.
   await front.startProfiler({ entries: 1000, interval: 0.1,
                               features: ["js", "stackwalk"] });
 
   is(await front.isActive(), true, "The profiler is active.");
 
--- a/layout/style/ServoStyleSet.cpp
+++ b/layout/style/ServoStyleSet.cpp
@@ -32,16 +32,17 @@
 #include "nsIDocumentInlines.h"
 #include "nsMediaFeatures.h"
 #include "nsPrintfCString.h"
 #include "nsSMILAnimationController.h"
 #include "nsXBLPrototypeBinding.h"
 #include "gfxUserFontSet.h"
 #include "nsBindingManager.h"
 #include "nsWindowSizes.h"
+#include "GeckoProfiler.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 #ifdef DEBUG
 bool
 ServoStyleSet::IsCurrentThreadInServoTraversal()
 {
@@ -1508,17 +1509,25 @@ ServoStyleSet::MayTraverseFrom(const Ele
 
   return !Servo_Element_IsDisplayNone(parent->AsElement());
 }
 
 bool
 ServoStyleSet::ShouldTraverseInParallel() const
 {
   MOZ_ASSERT(mDocument->GetShell(), "Styling a document without a shell?");
-  return mDocument->GetShell()->IsActive();
+  if (!mDocument->GetShell()->IsActive()) {
+    return false;
+  }
+#ifdef MOZ_GECKO_PROFILER
+  if (profiler_feature_active(ProfilerFeature::SequentialStyle)) {
+    return false;
+  }
+#endif
+  return true;
 }
 
 void
 ServoStyleSet::PrependSheetOfType(SheetType aType, StyleSheet* aSheet)
 {
   aSheet->AddStyleSet(this);
   mSheets[aType].InsertElementAt(0, aSheet);
 }
--- a/tools/profiler/public/GeckoProfiler.h
+++ b/tools/profiler/public/GeckoProfiler.h
@@ -123,27 +123,30 @@ class TimeStamp;
   macro(5, "privacy", Privacy) \
   \
   /* Collect thread responsiveness information. */ \
   macro(6, "responsiveness", Responsiveness) \
   \
   /* Take a snapshot of the window on every composition. */ \
   macro(7, "screenshots", Screenshots) \
   \
+  /* Disable parallel traversal in styling. */ \
+  macro(8, "seqstyle", SequentialStyle) \
+  \
   /* Walk the C++ stack. Not available on all platforms. */ \
-  macro(8, "stackwalk", StackWalk) \
+  macro(9, "stackwalk", StackWalk) \
   \
   /* Start profiling with feature TaskTracer. */ \
-  macro(9, "tasktracer", TaskTracer) \
+  macro(10, "tasktracer", TaskTracer) \
   \
   /* Profile the registered secondary threads. */ \
-  macro(10, "threads", Threads) \
+  macro(11, "threads", Threads) \
   \
   /* Have the JavaScript engine track JIT optimizations. */ \
-  macro(11, "trackopts", TrackOptimizations)
+  macro(12, "trackopts", TrackOptimizations)
 
 struct ProfilerFeature
 {
   #define DECLARE(n_, str_, Name_) \
     static const uint32_t Name_ = (1u << n_); \
     static bool Has##Name_(uint32_t aFeatures) { return aFeatures & Name_; } \
     static void Set##Name_(uint32_t& aFeatures) { aFeatures |= Name_; } \
     static void Clear##Name_(uint32_t& aFeatures) { aFeatures &= ~Name_; }