Bug 1540114 - Select all defaults in MOZ_PROFILER_STARTUP_FEATURES with keyword "default" - r=mstange
authorGerald Squelart <gsquelart@mozilla.com>
Tue, 30 Apr 2019 01:41:19 +0000
changeset 530679 33b606ed4e09fc17d2d0d548dd7d627fc2a8ede7
parent 530678 efbefb8b495104c7574eae481a6a5d7fc31e9f7e
child 530680 1a6729434b06259c87ab0d891875a6a45a92c43f
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange
bugs1540114
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 1540114 - Select all defaults in MOZ_PROFILER_STARTUP_FEATURES with keyword "default" - r=mstange MOZ_PROFILER_FEATURES is mostly used to add features in addition to the defaults. This will now be easier, e.g.: `MOZ_PROFILER_STARTUP_FEATURES=default,screenshots` Differential Revision: https://phabricator.services.mozilla.com/D25532
tools/profiler/core/platform.cpp
tools/profiler/core/platform.h
--- a/tools/profiler/core/platform.cpp
+++ b/tools/profiler/core/platform.cpp
@@ -2251,16 +2251,17 @@ static void PrintUsageThenExit(int aExit
   printf("    %c %5u: \"%s\" (%s)\n", FeatureCategory(ProfilerFeature::Name_), \
          ProfilerFeature::Name_, str_, desc_);
 
   PROFILER_FOR_EACH_FEATURE(PRINT_FEATURE)
 
 #undef PRINT_FEATURE
 
   printf(
+      "    -                \"default\" (All above D+S defaults)\n"
       "\n"
       "  MOZ_PROFILER_STARTUP_FILTERS=<Filters>\n"
       "  If MOZ_PROFILER_STARTUP is set, specifies the thread filters, as a\n"
       "  comma-separated list of strings. A given thread will be sampled if\n"
       "  any of the filters is a case-insensitive substring of the thread\n"
       "  name. If unset, a default is used.\n"
       "\n"
       "  MOZ_PROFILER_SHUTDOWN\n"
@@ -2623,36 +2624,43 @@ GeckoProfilerReporter::CollectReports(ns
       "Memory used by LUL, a stack unwinder used by the Gecko Profiler.");
 #endif
 
   return NS_OK;
 }
 
 NS_IMPL_ISUPPORTS(GeckoProfilerReporter, nsIMemoryReporter)
 
-static uint32_t ParseFeature(const char* aFeature) {
+static uint32_t ParseFeature(const char* aFeature, bool aIsStartup) {
+  if (strcmp(aFeature, "default") == 0) {
+    return (aIsStartup ? (DefaultFeatures() | StartupExtraDefaultFeatures())
+                       : DefaultFeatures()) &
+           AvailableFeatures();
+  }
+
 #define PARSE_FEATURE_BIT(n_, str_, Name_, desc_) \
   if (strcmp(aFeature, str_) == 0) {              \
     return ProfilerFeature::Name_;                \
   }
 
   PROFILER_FOR_EACH_FEATURE(PARSE_FEATURE_BIT)
 
 #undef PARSE_FEATURE_BIT
 
   printf("\nUnrecognized feature \"%s\".\n\n", aFeature);
   PrintUsageThenExit(1);
   return 0;
 }
 
 uint32_t ParseFeaturesFromStringArray(const char** aFeatures,
-                                      uint32_t aFeatureCount) {
+                                      uint32_t aFeatureCount,
+                                      bool aIsStartup /* = false */) {
   uint32_t features = 0;
   for (size_t i = 0; i < aFeatureCount; i++) {
-    features |= ParseFeature(aFeatures[i]);
+    features |= ParseFeature(aFeatures[i], aIsStartup);
   }
   return features;
 }
 
 // Find the RegisteredThread for the current thread. This should only be called
 // in places where TLSRegisteredThread can't be used.
 static RegisteredThread* FindCurrentThreadRegisteredThread(PSLockRef aLock) {
   int id = Thread::GetCurrentId();
@@ -2922,17 +2930,18 @@ void profiler_init(void* aStackTop) {
       const char* startupFeatures = getenv("MOZ_PROFILER_STARTUP_FEATURES");
       if (startupFeatures && startupFeatures[0] != '\0') {
         // Interpret startupFeatures as a list of feature strings, separated by
         // commas.
         UniquePtr<char[]> featureStringStorage;
         Vector<const char*> featureStringArray =
             SplitAtCommas(startupFeatures, featureStringStorage);
         features = ParseFeaturesFromStringArray(featureStringArray.begin(),
-                                                featureStringArray.length());
+                                                featureStringArray.length(),
+                                                /* aIsStartup */ true);
         LOG("- MOZ_PROFILER_STARTUP_FEATURES = %d", features);
       }
     }
 
     const char* startupFilters = getenv("MOZ_PROFILER_STARTUP_FILTERS");
     if (startupFilters && startupFilters[0] != '\0') {
       filters = SplitAtCommas(startupFilters, filterStorage);
       LOG("- MOZ_PROFILER_STARTUP_FILTERS = %s", startupFilters);
--- a/tools/profiler/core/platform.h
+++ b/tools/profiler/core/platform.h
@@ -106,17 +106,18 @@ UniquePlatformData AllocPlatformData(int
 
 namespace mozilla {
 class JSONWriter;
 }
 void AppendSharedLibraries(mozilla::JSONWriter& aWriter);
 
 // Convert the array of strings to a bitfield.
 uint32_t ParseFeaturesFromStringArray(const char** aFeatures,
-                                      uint32_t aFeatureCount);
+                                      uint32_t aFeatureCount,
+                                      bool aIsStartup = false);
 
 void profiler_get_profile_json_into_lazily_allocated_buffer(
     const std::function<char*(size_t)>& aAllocator, double aSinceTime,
     bool aIsShuttingDown);
 
 // Flags to conveniently track various JS features.
 enum class JSSamplingFlags {
   StackSampling = 0x1,