Bug 1586939 - Re-enable MOZ_BASE_PROFILER_STARTUP_DURATION and _INTERVAL - r=gregtatum
☠☠ backed out by 7541d616ff87 ☠ ☠
authorGerald Squelart <gsquelart@mozilla.com>
Wed, 15 Jan 2020 01:57:13 +0000
changeset 510430 b5aac83f7f4fbb8b3f6eb6eeaeafda286515fe67
parent 510429 e69960479b2ad9c896146229645a62da5bf3586f
child 510431 9222433458072c6e042ea0e1d3d1c0d604b69a0f
push id37021
push userrmaries@mozilla.com
push dateThu, 16 Jan 2020 09:46:51 +0000
treeherdermozilla-central@7541d616ff87 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgregtatum
bugs1586939
milestone74.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 1586939 - Re-enable MOZ_BASE_PROFILER_STARTUP_DURATION and _INTERVAL - r=gregtatum This env-vars were not processed because of some needed special processing, and they were not critical. But now we want them to be correctly read, to match the Gecko Profiler features. Differential Revision: https://phabricator.services.mozilla.com/D54448
mozglue/baseprofiler/core/platform.cpp
--- a/mozglue/baseprofiler/core/platform.cpp
+++ b/mozglue/baseprofiler/core/platform.cpp
@@ -55,16 +55,17 @@
 #  include "mozilla/TimeStamp.h"
 #  include "mozilla/Tuple.h"
 #  include "mozilla/UniquePtr.h"
 #  include "mozilla/Vector.h"
 #  include "prdtoa.h"
 #  include "prtime.h"
 
 #  include <algorithm>
+#  include <cmath>
 #  include <errno.h>
 #  include <fstream>
 #  include <ostream>
 #  include <sstream>
 
 // Win32 builds always have frame pointers, so FramePointerStackWalk() always
 // works.
 #  if defined(GP_PLAT_x86_windows)
@@ -2415,45 +2416,41 @@ void profiler_init(void* aStackTop) {
         LOG("- MOZ_BASE_PROFILER_STARTUP_ENTRIES not a valid integer: %s",
             startupCapacity);
         PrintUsageThenExit(1);
       }
     }
 
     const char* startupDuration = getenv("MOZ_BASE_PROFILER_STARTUP_DURATION");
     if (startupDuration && startupDuration[0] != '\0') {
-      // TODO implement if needed
-      MOZ_CRASH("MOZ_BASE_PROFILER_STARTUP_DURATION unsupported");
-      // errno = 0;
-      // double durationVal = PR_strtod(startupDuration, nullptr);
-      // if (errno == 0 && durationVal >= 0.0) {
-      //   if (durationVal > 0.0) {
-      //     duration = Some(durationVal);
-      //   }
-      //   LOG("- MOZ_BASE_PROFILER_STARTUP_DURATION = %f", durationVal);
-      // } else {
-      //   LOG("- MOZ_BASE_PROFILER_STARTUP_DURATION not a valid float: %s",
-      //       startupDuration);
-      //   PrintUsageThenExit(1);
-      // }
+      errno = 0;
+      double durationVal = strtod(startupDuration, nullptr);
+      if (errno == 0 && durationVal >= 0.0 && durationVal < HUGE_VAL) {
+        if (durationVal > 0.0) {
+          duration = Some(durationVal);
+        }
+        LOG("- MOZ_BASE_PROFILER_STARTUP_DURATION = %f", durationVal);
+      } else {
+        LOG("- MOZ_BASE_PROFILER_STARTUP_DURATION not a valid float: %s",
+            startupDuration);
+        PrintUsageThenExit(1);
+      }
     }
 
     const char* startupInterval = getenv("MOZ_BASE_PROFILER_STARTUP_INTERVAL");
     if (startupInterval && startupInterval[0] != '\0') {
-      // TODO implement if needed
-      MOZ_CRASH("MOZ_BASE_PROFILER_STARTUP_INTERVAL unsupported");
-      // errno = 0;
-      // interval = PR_strtod(startupInterval, nullptr);
-      // if (errno == 0 && interval > 0.0 && interval <= 1000.0) {
-      //   LOG("- MOZ_BASE_PROFILER_STARTUP_INTERVAL = %f", interval);
-      // } else {
-      //   LOG("- MOZ_BASE_PROFILER_STARTUP_INTERVAL not a valid float: %s",
-      //       startupInterval);
-      //   PrintUsageThenExit(1);
-      // }
+      errno = 0;
+      interval = strtod(startupInterval, nullptr);
+      if (errno == 0 && interval > 0.0 && interval <= 1000.0) {
+        LOG("- MOZ_BASE_PROFILER_STARTUP_INTERVAL = %f", interval);
+      } else {
+        LOG("- MOZ_BASE_PROFILER_STARTUP_INTERVAL not a valid float: %s",
+            startupInterval);
+        PrintUsageThenExit(1);
+      }
     }
 
     features |= StartupExtraDefaultFeatures() & AvailableFeatures();
 
     const char* startupFeaturesBitfield =
         getenv("MOZ_BASE_PROFILER_STARTUP_FEATURES_BITFIELD");
     if (startupFeaturesBitfield && startupFeaturesBitfield[0] != '\0') {
       errno = 0;