Bug 1340928 (part 16) - Clean up profiler env var handling. r=mstange.
authorNicholas Nethercote <nnethercote@mozilla.com>
Thu, 23 Feb 2017 14:26:46 +1100
changeset 344664 4d41302b84810f47240ebf30b9856a9408542302
parent 344663 8d35b6c817c2e53e954755cdd1584c2911a33209
child 344665 77b0ddb1fd71b626f023f70c5c64b85bdc310617
push id31414
push usercbook@mozilla.com
push dateFri, 24 Feb 2017 10:47:41 +0000
treeherdermozilla-central@be661bae6cb9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange
bugs1340928
milestone54.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 1340928 (part 16) - Clean up profiler env var handling. r=mstange. This patch does the following. - Uses "entries" consistently for the name of the value that is obtained from MOZ_PROFILER_ENTRIES and is the first argument to profiler_start(). (I.e. not "entry" or "entrySize".) - Removes variables (e.g. PROFILER_HELP) holding env var names and uses the names (e.g. "MOZ_PROFILER_HELP") directly. Some of the names are already used directly and I think the slight repetition isn't harmful. It's unlikely that we'd want to change these names the way we might need to change a numeric value, and they're perfectly descriptive. - Changes the "MOZ_PROFILING_FEATURES" string in the weird Android-only startup code to be "MOZ_PROFILER_FEATURES", for consistency. - Renames gUnwindInterval and gProfileEntries as gEnvVarInterval and gEnvVarEntries to make it clearer that they come from environment variables, but otherwise are parallel to gInterval and gEntries. - Puts entries before intervals in most places, to match the profiler_start() argument order. - Changes profiler_usage() so that (a) it always prints, no matter the verbosity, (b) it exits at its end, and (c) doesn't double-print "Profiler: " at the start of each line.
tools/profiler/core/SyncProfile.cpp
tools/profiler/core/platform-linux-android.cpp
tools/profiler/core/platform.cpp
tools/profiler/gecko/nsProfiler.cpp
tools/profiler/public/GeckoProfiler.h
widget/android/ANRReporter.cpp
--- a/tools/profiler/core/SyncProfile.cpp
+++ b/tools/profiler/core/SyncProfile.cpp
@@ -7,17 +7,17 @@
 #include "SyncProfile.h"
 
 SyncProfile::SyncProfile(int aThreadId, PseudoStack* aStack)
   : ThreadInfo("SyncProfile", aThreadId, /* isMainThread = */ false, aStack,
                /* stackTop = */ nullptr)
   , mOwnerState(REFERENCED)
 {
   MOZ_COUNT_CTOR(SyncProfile);
-  SetProfile(new ProfileBuffer(GET_BACKTRACE_DEFAULT_ENTRY));
+  SetProfile(new ProfileBuffer(GET_BACKTRACE_DEFAULT_ENTRIES));
 }
 
 SyncProfile::~SyncProfile()
 {
   MOZ_COUNT_DTOR(SyncProfile);
 }
 
 bool
--- a/tools/profiler/core/platform-linux-android.cpp
+++ b/tools/profiler/core/platform-linux-android.cpp
@@ -453,37 +453,39 @@ static uint32_t readCSVArray(char* csvLi
     buffer[count] = newBuf;
     strncpy(newBuf, item, length);
     count++;
   }
 
   return count;
 }
 
-// Currently support only the env variables
-// reported in read_profiler_env
-static void ReadProfilerVars(const char* fileName, const char** features,
-                            uint32_t* featureCount, const char** threadNames, uint32_t* threadCount) {
+// Support some of the env variables reported in ReadProfilerEnvVars, plus some
+// extra stuff.
+static void
+ReadProfilerVars(const char* fileName,
+                 const char** features, uint32_t* featureCount,
+                 const char** threadNames, uint32_t* threadCount) {
   FILE* file = fopen(fileName, "r");
   const int bufferSize = 1024;
   char line[bufferSize];
   char* feature;
   char* value;
   char* savePtr;
 
   if (file) {
     while (fgets(line, bufferSize, file) != NULL) {
       feature = strtok_r(line, "=", &savePtr);
       value = strtok_r(NULL, "", &savePtr);
 
-      if (strncmp(feature, PROFILER_INTERVAL, bufferSize) == 0) {
+      if (strncmp(feature, "MOZ_PROFILER_INTERVAL", bufferSize) == 0) {
         set_profiler_interval(value);
-      } else if (strncmp(feature, PROFILER_ENTRIES, bufferSize) == 0) {
+      } else if (strncmp(feature, "MOZ_PROFILER_ENTRIES", bufferSize) == 0) {
         set_profiler_entries(value);
-      } else if (strncmp(feature, PROFILER_FEATURES, bufferSize) == 0) {
+      } else if (strncmp(feature, "MOZ_PROFILER_FEATURES", bufferSize) == 0) {
         *featureCount = readCSVArray(value, features);
       } else if (strncmp(feature, "threads", bufferSize) == 0) {
         *threadCount = readCSVArray(value, threadNames);
       }
     }
 
     fclose(file);
   }
@@ -500,19 +502,18 @@ static void DoStartTask() {
   const char* threadNames[10];
   const char* features[10];
   const char* profilerConfigFile = "/data/local/tmp/profiler.options";
 
   ReadProfilerVars(profilerConfigFile, features, &featureCount, threadNames, &threadCount);
   MOZ_ASSERT(featureCount < 10);
   MOZ_ASSERT(threadCount < 10);
 
-  profiler_start(PROFILE_DEFAULT_ENTRY, 1,
-      features, featureCount,
-      threadNames, threadCount);
+  profiler_start(PROFILE_DEFAULT_ENTRIES, /* interval */ 1,
+                 features, featureCount, threadNames, threadCount);
 
   freeArray(threadNames, threadCount);
   freeArray(features, featureCount);
 }
 
 static void StartSignalHandler(int signal, siginfo_t* info, void* context) {
   class StartTask : public Runnable {
   public:
--- a/tools/profiler/core/platform.cpp
+++ b/tools/profiler/core/platform.cpp
@@ -114,18 +114,18 @@ static StaticRefPtr<ProfileBuffer> gBuff
 // gThreadNameFilters is accessed from multiple threads. All accesses to it
 // must be guarded by gThreadNameFiltersMutex.
 static Vector<std::string> gThreadNameFilters;
 static mozilla::StaticMutex gThreadNameFiltersMutex;
 
 // All accesses to gFeatures are on the main thread, so no locking is needed.
 static Vector<std::string> gFeatures;
 
-// All accesses to gEntrySize are on the main thread, so no locking is needed.
-static int gEntrySize = 0;
+// All accesses to gEntries are on the main thread, so no locking is needed.
+static int gEntries = 0;
 
 // All accesses to gInterval are on the main thread, so no locking is needed.
 static double gInterval = 0;
 
 // XXX: These two variables are used extensively both on and off the main
 // thread. It's possible that code that checks them then unsafely assumes their
 // values don't subsequently change.
 static Atomic<bool> gIsActive(false);
@@ -168,18 +168,18 @@ static Atomic<bool> gProfileThreads(fals
 static Atomic<bool> gUseStackWalk(false);
 
 /* we don't need to worry about overflow because we only treat the
  * case of them being the same as special. i.e. we only run into
  * a problem if 2^32 events happen between samples that we need
  * to know are associated with different events */
 
 // Values harvested from env vars, that control the profiler.
-static int gUnwindInterval;   /* in milliseconds */
-static int gProfileEntries;   /* how many entries do we store? */
+static int gEnvVarEntries;    /* how many entries do we store? */
+static int gEnvVarInterval;   /* in milliseconds */
 
 static mozilla::StaticAutoPtr<mozilla::ProfilerIOInterposeObserver>
                                                             gInterposeObserver;
 
 // The name that identifies the gecko thread for calls to
 // profiler_register_thread.
 static const char* gGeckoThreadName = "GeckoMain";
 
@@ -1228,69 +1228,59 @@ void ProfilerMarker::StreamJSON(Spliceab
       }
       aWriter.EndObject();
     }
   }
   aWriter.EndArray();
 }
 
 // Verbosity control for the profiler.  The aim is to check env var
-// MOZ_PROFILER_VERBOSE only once.  However, we may need to temporarily
-// override that so as to print the profiler's help message.  That's
-// what profiler_set_verbosity is for.
+// MOZ_PROFILER_VERBOSE only once.
 
 enum class Verbosity : int8_t { UNCHECKED, NOTVERBOSE, VERBOSE };
 
 // Raced on, potentially
 static Verbosity gVerbosity = Verbosity::UNCHECKED;
 
 bool
 profiler_verbose()
 {
   if (gVerbosity == Verbosity::UNCHECKED) {
     gVerbosity = getenv("MOZ_PROFILER_VERBOSE")
-                       ? Verbosity::VERBOSE
-                       : Verbosity::NOTVERBOSE;
+               ? Verbosity::VERBOSE
+               : Verbosity::NOTVERBOSE;
   }
 
   return gVerbosity == Verbosity::VERBOSE;
 }
 
-static void
-profiler_set_verbosity(Verbosity aPv)
-{
-  MOZ_ASSERT(aPv == Verbosity::UNCHECKED ||
-             aPv == Verbosity::VERBOSE);
-  gVerbosity = aPv;
-}
-
 static bool
 set_profiler_interval(const char* aInterval)
 {
   if (aInterval) {
     errno = 0;
     long int n = strtol(aInterval, nullptr, 10);
     if (errno == 0 && 1 <= n && n <= 1000) {
-      gUnwindInterval = n;
+      gEnvVarInterval = n;
       return true;
     }
     return false;
   }
 
   return true;
 }
 
 static bool
 set_profiler_entries(const char* aEntries)
 {
   if (aEntries) {
     errno = 0;
     long int n = strtol(aEntries, nullptr, 10);
     if (errno == 0 && n > 0) {
-      gProfileEntries = n;
+      gEnvVarEntries = n;
       return true;
     }
     return false;
   }
 
   return true;
 }
 
@@ -1299,94 +1289,73 @@ is_native_unwinding_avail()
 {
 # if defined(HAVE_NATIVE_UNWIND)
   return true;
 #else
   return false;
 #endif
 }
 
-// Environment variables to control the profiler
-static const char* PROFILER_HELP     = "MOZ_PROFILER_HELP";
-static const char* PROFILER_INTERVAL = "MOZ_PROFILER_INTERVAL";
-static const char* PROFILER_ENTRIES  = "MOZ_PROFILER_ENTRIES";
-#if defined(GP_OS_android)
-static const char* PROFILER_FEATURES = "MOZ_PROFILING_FEATURES";
-#endif
-
 static void
-profiler_usage()
+profiler_usage(int aExitCode)
 {
-  LOG( "Profiler: ");
-  LOG( "Profiler: Environment variable usage:");
-  LOG( "Profiler: ");
-  LOG( "Profiler:   MOZ_PROFILER_HELP");
-  LOG( "Profiler:   If set to any value, prints this message.");
-  LOG( "Profiler: ");
-  LOG( "Profiler:   MOZ_PROFILER_INTERVAL=<number>   (milliseconds, 1 to 1000)");
-  LOG( "Profiler:   If unset, platform default is used.");
-  LOG( "Profiler: ");
-  LOG( "Profiler:   MOZ_PROFILER_ENTRIES=<number>    (count, minimum of 1)");
-  LOG( "Profiler:   If unset, platform default is used.");
-  LOG( "Profiler: ");
-  LOG( "Profiler:   MOZ_PROFILER_VERBOSE");
-  LOG( "Profiler:   If set to any value, increases verbosity (recommended).");
-  LOG( "Profiler: ");
-  LOG( "Profiler:   MOZ_PROFILER_LUL_TEST");
-  LOG( "Profiler:   If set to any value, runs LUL unit tests at startup of");
-  LOG( "Profiler:   the unwinder thread, and prints a short summary of results.");
-  LOG( "Profiler: ");
-  LOGF("Profiler:   This platform %s native unwinding.",
+  // Force-enable verbosity so that LOG prints something.
+  gVerbosity = Verbosity::VERBOSE;
+
+  LOG ("");
+  LOG ("Environment variable usage:");
+  LOG ("");
+  LOG ("  MOZ_PROFILER_HELP");
+  LOG ("  If set to any value, prints this message.");
+  LOG ("");
+  LOG ("  MOZ_PROFILER_ENTRIES=<1..>      (count)");
+  LOG ("  If unset, platform default is used.");
+  LOG ("");
+  LOG ("  MOZ_PROFILER_INTERVAL=<1..1000> (milliseconds)");
+  LOG ("  If unset, platform default is used.");
+  LOG ("");
+  LOG ("  MOZ_PROFILER_VERBOSE");
+  LOG ("  If set to any value, increases verbosity (recommended).");
+  LOG ("");
+  LOG ("  MOZ_PROFILER_LUL_TEST");
+  LOG ("  If set to any value, runs LUL unit tests at startup of");
+  LOG ("  the unwinder thread, and prints a short summary of ");
+  LOG ("  results.");
+  LOG ("");
+  LOGF("  This platform %s native unwinding.",
        is_native_unwinding_avail() ? "supports" : "does not support");
-  LOG( "Profiler: ");
-
-  /* Re-set defaults */
-  gUnwindInterval   = 0;  /* We'll have to look elsewhere */
-  gProfileEntries   = 0;
-
-  LOG( "Profiler:");
-  LOGF("Profiler: Sampling interval = %d ms (zero means \"platform default\")",
-       (int)gUnwindInterval);
-  LOGF("Profiler: Entry store size  = %d (zero means \"platform default\")",
-       (int)gProfileEntries);
-  LOG( "Profiler:");
+  LOG ("");
+
+  exit(aExitCode);
 }
 
 // Read env vars at startup, so as to set:
-//   gUnwindInterval, gProfileEntries
+//   gEnvVarEntries, gEnvVarInterval
 static void
-read_profiler_env_vars()
+ReadProfilerEnvVars()
 {
-  /* Set defaults */
-  gUnwindInterval = 0;  /* We'll have to look elsewhere */
-  gProfileEntries = 0;
-
-  const char* interval = getenv(PROFILER_INTERVAL);
-  const char* entries = getenv(PROFILER_ENTRIES);
-
-  if (getenv(PROFILER_HELP)) {
-    // Enable verbose output
-    profiler_set_verbosity(Verbosity::VERBOSE);
-    profiler_usage();
-    // Now force the next enquiry of profiler_verbose to re-query
-    // env var MOZ_PROFILER_VERBOSE.
-    profiler_set_verbosity(Verbosity::UNCHECKED);
+  const char* help     = getenv("MOZ_PROFILER_HELP");
+  const char* entries  = getenv("MOZ_PROFILER_ENTRIES");
+  const char* interval = getenv("MOZ_PROFILER_INTERVAL");
+
+  if (help) {
+    profiler_usage(0); // terminates execution
   }
 
-  if (!set_profiler_interval(interval) ||
-      !set_profiler_entries(entries)) {
-      profiler_usage();
-  } else {
-    LOG( "Profiler:");
-    LOGF("Profiler: Sampling interval = %d ms (zero means \"platform default\")",
-        (int)gUnwindInterval);
-    LOGF("Profiler: Entry store size  = %d (zero means \"platform default\")",
-        (int)gProfileEntries);
-    LOG( "Profiler:");
+  if (!set_profiler_entries(entries) ||
+      !set_profiler_interval(interval)) {
+    profiler_usage(1); // terminates execution
   }
+
+  LOG ("");
+  LOGF("entries  = %d (zero means \"platform default\")",
+       gEnvVarEntries);
+  LOGF("interval = %d ms (zero means \"platform default\")",
+       gEnvVarInterval);
+  LOG ("");
 }
 
 static bool
 is_main_thread_name(const char* aName)
 {
   return aName && (strcmp(aName, gGeckoThreadName) == 0);
 }
 
@@ -1595,17 +1564,17 @@ profiler_init(void* stackTop)
 
   PseudoStack* stack = new PseudoStack();
   tlsPseudoStack.set(stack);
 
   bool isMainThread = true;
   RegisterCurrentThread(gGeckoThreadName, stack, isMainThread, stackTop);
 
   // Read settings from environment variables.
-  read_profiler_env_vars();
+  ReadProfilerEnvVars();
 
   // Platform-specific initialization.
   PlatformInit();
 
   set_stderr_callback(profiler_log);
 
 #if defined(PROFILE_JAVA)
   if (mozilla::jni::IsFennec()) {
@@ -1627,17 +1596,17 @@ profiler_init(void* stackTop)
 #endif
 #if defined(PROFILE_JAVA)
                            , "java"
 #endif
                            };
 
   const char* threadFilters[] = { "GeckoMain", "Compositor" };
 
-  profiler_start(PROFILE_DEFAULT_ENTRY, PROFILE_DEFAULT_INTERVAL,
+  profiler_start(PROFILE_DEFAULT_ENTRIES, PROFILE_DEFAULT_INTERVAL,
                  features, MOZ_ARRAY_LENGTH(features),
                  threadFilters, MOZ_ARRAY_LENGTH(threadFilters));
   LOG("END   profiler_init");
 }
 
 void
 profiler_shutdown()
 {
@@ -1747,29 +1716,28 @@ profiler_save_profile_to_file_async(doub
       return;
     }
 
     gGatherer->Start(aSinceTime, filename);
   }));
 }
 
 void
-profiler_get_start_params(int* aEntrySize,
-                          double* aInterval,
+profiler_get_start_params(int* aEntries, double* aInterval,
                           mozilla::Vector<const char*>* aFilters,
                           mozilla::Vector<const char*>* aFeatures)
 {
   MOZ_RELEASE_ASSERT(NS_IsMainThread());
 
-  if (NS_WARN_IF(!aEntrySize) || NS_WARN_IF(!aInterval) ||
+  if (NS_WARN_IF(!aEntries) || NS_WARN_IF(!aInterval) ||
       NS_WARN_IF(!aFilters) || NS_WARN_IF(!aFeatures)) {
     return;
   }
 
-  *aEntrySize = gEntrySize;
+  *aEntries = gEntries;
   *aInterval = gInterval;
 
   {
     StaticMutexAutoLock lock(gThreadNameFiltersMutex);
 
     MOZ_ALWAYS_TRUE(aFilters->resize(gThreadNameFilters.length()));
     for (uint32_t i = 0; i < gThreadNameFilters.length(); ++i) {
       (*aFilters)[i] = gThreadNameFilters[i].c_str();
@@ -1881,34 +1849,34 @@ profiler_get_features()
 #endif
     nullptr
   };
 
   return features;
 }
 
 void
-profiler_get_buffer_info_helper(uint32_t *aCurrentPosition,
-                                uint32_t *aTotalSize,
-                                uint32_t *aGeneration)
+profiler_get_buffer_info_helper(uint32_t* aCurrentPosition,
+                                uint32_t* aEntries,
+                                uint32_t* aGeneration)
 {
   // This function is called by profiler_get_buffer_info(), which has already
   // zeroed the outparams.
 
   MOZ_RELEASE_ASSERT(NS_IsMainThread());
 
   if (!stack_key_initialized)
     return;
 
   if (!gBuffer) {
     return;
   }
 
   *aCurrentPosition = gBuffer->mWritePos;
-  *aTotalSize = gEntrySize;
+  *aEntries = gEntries;
   *aGeneration = gBuffer->mGeneration;
 }
 
 static bool
 hasFeature(const char** aFeatures, uint32_t aFeatureCount, const char* aFeature)
 {
   for (size_t i = 0; i < aFeatureCount; i++) {
     if (strcmp(aFeatures[i], aFeature) == 0) {
@@ -1918,36 +1886,36 @@ hasFeature(const char** aFeatures, uint3
   return false;
 }
 
 // XXX: an empty class left behind after refactoring. Will be removed soon.
 class Sampler {};
 
 // Values are only honored on the first start
 void
-profiler_start(int aProfileEntries, double aInterval,
+profiler_start(int aEntries, double aInterval,
                const char** aFeatures, uint32_t aFeatureCount,
                const char** aThreadNameFilters, uint32_t aFilterCount)
 
 {
   MOZ_RELEASE_ASSERT(NS_IsMainThread());
 
   LOG("BEGIN profiler_start");
 
   if (!stack_key_initialized)
     profiler_init(nullptr);
 
   /* If the sampling interval was set using env vars, use that
      in preference to anything else. */
-  if (gUnwindInterval > 0)
-    aInterval = gUnwindInterval;
+  if (gEnvVarInterval > 0)
+    aInterval = gEnvVarInterval;
 
   /* If the entry count was set using env vars, use that, too: */
-  if (gProfileEntries > 0)
-    aProfileEntries = gProfileEntries;
+  if (gEnvVarEntries > 0)
+    aEntries = gEnvVarEntries;
 
   // Reset the current state if the profiler is running
   profiler_stop();
 
   // Deep copy aThreadNameFilters. Must happen before the MaybeSetProfile()
   // call below.
   {
     StaticMutexAutoLock lock(gThreadNameFiltersMutex);
@@ -1982,19 +1950,19 @@ profiler_start(int aProfileEntries, doub
   gProfileRestyle   = hasFeature(aFeatures, aFeatureCount, "restyle");
   // Profile non-main threads if we have a filter, because users sometimes ask
   // to filter by a list of threads but forget to explicitly request.
   // gProfileThreads must be set before the MaybeSetProfile() call below.
   gProfileThreads   = hasFeature(aFeatures, aFeatureCount, "threads") ||
                       aFilterCount > 0;
   gUseStackWalk     = hasFeature(aFeatures, aFeatureCount, "stackwalk");
 
-  gEntrySize = aProfileEntries ? aProfileEntries : PROFILE_DEFAULT_ENTRY;
+  gEntries = aEntries ? aEntries : PROFILE_DEFAULT_ENTRIES;
   gInterval = aInterval ? aInterval : PROFILE_DEFAULT_INTERVAL;
-  gBuffer = new ProfileBuffer(gEntrySize);
+  gBuffer = new ProfileBuffer(gEntries);
   gSampler = new Sampler();
 
   bool ignore;
   gStartTime = mozilla::TimeStamp::ProcessCreation(ignore);
 
   {
     StaticMutexAutoLock lock(gRegisteredThreadsMutex);
 
@@ -2068,17 +2036,17 @@ profiler_start(int aProfileEntries, doub
         featuresArray.AppendElement(aFeatures[i]);
       }
 
       for (size_t i = 0; i < aFilterCount; ++i) {
         threadNameFiltersArray.AppendElement(aThreadNameFilters[i]);
       }
 
       nsCOMPtr<nsIProfilerStartParams> params =
-        new nsProfilerStartParams(aProfileEntries, aInterval, featuresArray,
+        new nsProfilerStartParams(aEntries, aInterval, featuresArray,
                                   threadNameFiltersArray);
 
       os->NotifyObservers(params, "profiler-started", nullptr);
     }
   }
 
   LOG("END   profiler_start");
 }
@@ -2145,17 +2113,17 @@ profiler_stop()
   if (gTaskTracer) {
     mozilla::tasktracer::StopLogging();
   }
 #endif
 
   delete gSampler;
   gSampler = nullptr;
   gBuffer = nullptr;
-  gEntrySize = 0;
+  gEntries = 0;
   gInterval = 0;
 
   // Cancel any in-flight async profile gatherering requests.
   gGatherer->Cancel();
   gGatherer = nullptr;
 
   if (disableJS) {
     PseudoStack *stack = tlsPseudoStack.get();
--- a/tools/profiler/gecko/nsProfiler.cpp
+++ b/tools/profiler/gecko/nsProfiler.cpp
@@ -275,17 +275,18 @@ nsProfiler::GetStartParams(nsIProfilerSt
                                 filtersArray);
 
     startParams.forget(aRetVal);
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsProfiler::GetBufferInfo(uint32_t *aCurrentPosition, uint32_t *aTotalSize, uint32_t *aGeneration)
+nsProfiler::GetBufferInfo(uint32_t* aCurrentPosition, uint32_t* aTotalSize,
+                          uint32_t* aGeneration)
 {
   MOZ_ASSERT(aCurrentPosition);
   MOZ_ASSERT(aTotalSize);
   MOZ_ASSERT(aGeneration);
   profiler_get_buffer_info(aCurrentPosition, aTotalSize, aGeneration);
   return NS_OK;
 }
 
--- a/tools/profiler/public/GeckoProfiler.h
+++ b/tools/profiler/public/GeckoProfiler.h
@@ -156,25 +156,27 @@ PROFILER_FUNC_VOID(profiler_init(void* s
 
 // Clean up the profiler module, stopping it if required. This function may
 // also save a shutdown profile if requested. No profiler calls should happen
 // after this point and all pseudo labels should have been popped.
 PROFILER_FUNC_VOID(profiler_shutdown())
 
 // Start the profiler with the selected options. The samples will be
 // recorded in a circular buffer.
-//   "aProfileEntries" is an abstract size indication of how big
+//   "aEntries" is an abstract size indication of how big
 //       the profile's circular buffer should be. Multiply by 4
 //       words to get the cost.
 //   "aInterval" the sampling interval. The profiler will do its
 //       best to sample at this interval. The profiler visualization
 //       should represent the actual sampling accuracy.
-PROFILER_FUNC_VOID(profiler_start(int aProfileEntries, double aInterval,
-                              const char** aFeatures, uint32_t aFeatureCount,
-                              const char** aThreadNameFilters, uint32_t aFilterCount))
+PROFILER_FUNC_VOID(profiler_start(int aEntries, double aInterval,
+                                  const char** aFeatures,
+                                  uint32_t aFeatureCount,
+                                  const char** aThreadNameFilters,
+                                  uint32_t aFilterCount))
 
 // Stop the profiler and discard the profile. Call 'profiler_save' before this
 // to retrieve the profile.
 PROFILER_FUNC_VOID(profiler_stop())
 
 // These functions pause and resume the profiler. While paused the profile will not
 // take any samples and will not record any data into its buffers. The profiler
 // remains fully initialized in this state. Timeline markers will still be stored.
@@ -229,35 +231,35 @@ extern "C" {
 PROFILER_FUNC_VOID(profiler_save_profile_to_file(const char* aFilename))
 }
 
 // Get the features supported by the profiler that are accepted by profiler_init.
 // Returns a null terminated char* array.
 PROFILER_FUNC(const char** profiler_get_features(), nullptr)
 
 PROFILER_FUNC_VOID(profiler_get_buffer_info_helper(uint32_t* aCurrentPosition,
-                                                   uint32_t* aTotalSize,
+                                                   uint32_t* aEntries,
                                                    uint32_t* aGeneration))
 
 // Get information about the current buffer status.
 // Retursn (using outparams) the current write position in the buffer,
 // the total size of the buffer, and the generation of the buffer.
 // This information may be useful to a user-interface displaying the
 // current status of the profiler, allowing the user to get a sense
 // for how fast the buffer is being written to, and how much
 // data is visible.
 static inline void profiler_get_buffer_info(uint32_t* aCurrentPosition,
-                                            uint32_t* aTotalSize,
+                                            uint32_t* aEntries,
                                             uint32_t* aGeneration)
 {
   *aCurrentPosition = 0;
-  *aTotalSize = 0;
+  *aEntries = 0;
   *aGeneration = 0;
 
-  profiler_get_buffer_info_helper(aCurrentPosition, aTotalSize, aGeneration);
+  profiler_get_buffer_info_helper(aCurrentPosition, aEntries, aGeneration);
 }
 
 // Lock the profiler. When locked the profiler is (1) stopped,
 // (2) profile data is cleared, (3) 'profiler-locked' is fired.
 // This is used to lock down the profiler during private browsing.
 PROFILER_FUNC_VOID(profiler_lock())
 
 // Unlock the profiler, leaving it stopped, and fire 'profiler-unlocked'.
@@ -428,24 +430,24 @@ void profiler_OOP_exit_profile(const nsC
 /* FIXME/bug 789667: memory constraints wouldn't much of a problem for
  * this small a sample buffer size, except that serializing the
  * profile data is extremely, unnecessarily memory intensive. */
 #ifdef MOZ_WIDGET_GONK
 # define PLATFORM_LIKELY_MEMORY_CONSTRAINED
 #endif
 
 #if !defined(PLATFORM_LIKELY_MEMORY_CONSTRAINED) && !defined(ARCH_ARMV6)
-# define PROFILE_DEFAULT_ENTRY 1000000
+# define PROFILE_DEFAULT_ENTRIES 1000000
 #else
-# define PROFILE_DEFAULT_ENTRY 100000
+# define PROFILE_DEFAULT_ENTRIES 100000
 #endif
 
 // In the case of profiler_get_backtrace we know that we only need enough space
 // for a single backtrace.
-#define GET_BACKTRACE_DEFAULT_ENTRY 1000
+#define GET_BACKTRACE_DEFAULT_ENTRIES 1000
 
 #if defined(PLATFORM_LIKELY_MEMORY_CONSTRAINED)
 /* A 1ms sampling interval has been shown to be a large perf hit
  * (10fps) on memory-contrained (low-end) platforms, and additionally
  * to yield different results from the profiler.  Where this is the
  * important case, b2g, there are also many gecko processes which
  * magnify these effects. */
 # define PROFILE_DEFAULT_INTERVAL 10
--- a/widget/android/ANRReporter.cpp
+++ b/widget/android/ANRReporter.cpp
@@ -33,18 +33,20 @@ ANRReporter::RequestNativeStack(bool aUn
         features_size = sizeof(NATIVE_STACK_UNWIND_FEATURES);
         // We want the new unwinder if the unwind mode has not been set yet
         putenv("MOZ_PROFILER_NEW=1");
     }
 
     const char *NATIVE_STACK_THREADS[] =
         {"GeckoMain", "Compositor"};
     // Buffer one sample and let the profiler wait a long time
-    profiler_start(100, 10000, features, features_size / sizeof(char*),
-        NATIVE_STACK_THREADS, sizeof(NATIVE_STACK_THREADS) / sizeof(char*));
+    profiler_start(/* entries */ 100, /* interval */ 10000,
+                   features, features_size / sizeof(char*),
+                   NATIVE_STACK_THREADS,
+                   sizeof(NATIVE_STACK_THREADS) / sizeof(char*));
     return true;
 }
 
 jni::String::LocalRef
 ANRReporter::GetNativeStack()
 {
     if (!profiler_is_active()) {
         // Maybe profiler support is disabled?