Bug 1476757 - Change {a,m}EntrySize to {a,m}Capacity in ProfileBuffer r=njn
authorNazım Can Altınova <canaltinova@gmail.com>
Fri, 12 Oct 2018 13:39:45 +0000
changeset 490762 1924a400dfa461fc3ec3e47fd290838d78ed38a1
parent 490761 1c9f10e217d127c8476fe624b579b8a8cb3cc03b
child 490763 ef82ba4b7f22f673870bc71ad4564bf0ef228b06
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersnjn
bugs1476757
milestone64.0a1
Bug 1476757 - Change {a,m}EntrySize to {a,m}Capacity in ProfileBuffer r=njn Differential Revision: https://phabricator.services.mozilla.com/D8218
tools/profiler/core/ProfileBuffer.cpp
tools/profiler/core/ProfileBuffer.h
tools/profiler/core/platform.cpp
tools/profiler/public/GeckoProfiler.h
--- a/tools/profiler/core/ProfileBuffer.cpp
+++ b/tools/profiler/core/ProfileBuffer.cpp
@@ -10,48 +10,48 @@
 
 #include "ProfilerMarker.h"
 #include "jsfriendapi.h"
 #include "nsScriptSecurityManager.h"
 #include "nsJSPrincipals.h"
 
 using namespace mozilla;
 
-ProfileBuffer::ProfileBuffer(uint32_t aEntrySize)
+ProfileBuffer::ProfileBuffer(uint32_t aCapacity)
   : mEntryIndexMask(0)
   , mRangeStart(0)
   , mRangeEnd(0)
-  , mEntrySize(0)
+  , mCapacity(0)
 {
-  // Round aEntrySize up to the nearest power of two, so that we can index
+  // Round aCapacity up to the nearest power of two, so that we can index
   // mEntries with a simple mask and don't need to do a slow modulo operation.
   const uint32_t UINT32_MAX_POWER_OF_TWO = 1 << 31;
-  MOZ_RELEASE_ASSERT(aEntrySize <= UINT32_MAX_POWER_OF_TWO,
-                     "aEntrySize is larger than what we support");
-  mEntrySize = RoundUpPow2(aEntrySize);
-  mEntryIndexMask = mEntrySize - 1;
-  mEntries = MakeUnique<ProfileBufferEntry[]>(mEntrySize);
+  MOZ_RELEASE_ASSERT(aCapacity <= UINT32_MAX_POWER_OF_TWO,
+                     "aCapacity is larger than what we support");
+  mCapacity = RoundUpPow2(aCapacity);
+  mEntryIndexMask = mCapacity - 1;
+  mEntries = MakeUnique<ProfileBufferEntry[]>(mCapacity);
 }
 
 ProfileBuffer::~ProfileBuffer()
 {
   while (mStoredMarkers.peek()) {
     delete mStoredMarkers.popHead();
   }
 }
 
 // Called from signal, call only reentrant functions
 void
 ProfileBuffer::AddEntry(const ProfileBufferEntry& aEntry)
 {
   GetEntry(mRangeEnd++) = aEntry;
 
   // The distance between mRangeStart and mRangeEnd must never exceed
-  // mEntrySize, so advance mRangeStart if necessary.
-  if (mRangeEnd - mRangeStart > mEntrySize) {
+  // mCapacity, so advance mRangeStart if necessary.
+  if (mRangeEnd - mRangeStart > mCapacity) {
     mRangeStart++;
   }
 }
 
 uint64_t
 ProfileBuffer::AddThreadIdEntry(int aThreadId)
 {
   uint64_t pos = mRangeEnd;
--- a/tools/profiler/core/ProfileBuffer.h
+++ b/tools/profiler/core/ProfileBuffer.h
@@ -25,19 +25,19 @@
 // Internally, the buffer uses a fixed-size storage and applies a modulo
 // operation when accessing entries in that storage buffer. "Evicting" an entry
 // really just means that an existing entry in the storage buffer gets
 // overwritten and that mRangeStart gets incremented.
 class ProfileBuffer final
 {
 public:
   // ProfileBuffer constructor
-  // @param aEntrySize The minimum capacity of the buffer. The actual buffer
+  // @param aCapacity The minimum capacity of the buffer. The actual buffer
   //                   capacity will be rounded up to the next power of two.
-  explicit ProfileBuffer(uint32_t aEntrySize);
+  explicit ProfileBuffer(uint32_t aCapacity);
 
   ~ProfileBuffer();
 
   // Add |aEntry| to the buffer, ignoring what kind of entry it is.
   void AddEntry(const ProfileBufferEntry& aEntry);
 
   // Add to the buffer a sample start (ThreadId) entry for aThreadId.
   // Returns the position of the entry.
@@ -101,46 +101,46 @@ public:
   ProfileBufferEntry& GetEntry(uint64_t aPosition) const
   {
     return mEntries[aPosition & mEntryIndexMask];
   }
 
   size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
 
 private:
-  // The storage that backs our buffer. Holds mEntrySize entries.
+  // The storage that backs our buffer. Holds mCapacity entries.
   // All accesses to entries in mEntries need to go through GetEntry(), which
   // translates the given buffer position from the near-infinite uint64_t space
   // into the entry storage space.
   mozilla::UniquePtr<ProfileBufferEntry[]> mEntries;
 
-  // A mask such that pos & mEntryIndexMask == pos % mEntrySize.
+  // A mask such that pos & mEntryIndexMask == pos % mCapacity.
   uint32_t mEntryIndexMask;
 
 public:
   // mRangeStart and mRangeEnd are uint64_t values that strictly advance and
   // never wrap around. mRangeEnd is always greater than or equal to
-  // mRangeStart, but never gets more than mEntrySize steps ahead of
+  // mRangeStart, but never gets more than mCapacity steps ahead of
   // mRangeStart, because we can only store a fixed number of entries in the
   // buffer. Once the entire buffer is in use, adding a new entry will evict an
   // entry from the front of the buffer (and increase mRangeStart).
   // In other words, the following conditions hold true at all times:
   //  (1) mRangeStart <= mRangeEnd
-  //  (2) mRangeEnd - mRangeStart <= mEntrySize
+  //  (2) mRangeEnd - mRangeStart <= mCapacity
   //
   // If there are no live entries, then mRangeStart == mRangeEnd.
   // Otherwise, mRangeStart is the first live entry and mRangeEnd is one past
   // the last live entry, and also the position at which the next entry will be
   // added.
   // (mRangeEnd - mRangeStart) always gives the number of live entries.
   uint64_t mRangeStart;
   uint64_t mRangeEnd;
 
   // The number of entries in our buffer. Always a power of two.
-  uint32_t mEntrySize;
+  uint32_t mCapacity;
 
   // Markers that marker entries in the buffer might refer to.
   ProfilerMarkerLinkedList mStoredMarkers;
 };
 
 /**
  * Helper type used to implement ProfilerStackCollector. This type is used as
  * the collector for MergeStacks by ProfileBuffer. It holds a reference to the
--- a/tools/profiler/core/platform.cpp
+++ b/tools/profiler/core/platform.cpp
@@ -379,23 +379,23 @@ private:
     // explicitly specify ProfilerFeature::Threads.
     if (aFilterCount > 0) {
       aFeatures |= ProfilerFeature::Threads;
     }
 
     return aFeatures;
   }
 
-  ActivePS(PSLockRef aLock, uint32_t aEntries, double aInterval,
+  ActivePS(PSLockRef aLock, uint32_t aCapacity, double aInterval,
            uint32_t aFeatures, const char** aFilters, uint32_t aFilterCount)
     : mGeneration(sNextGeneration++)
-    , mEntries(aEntries)
+    , mCapacity(aCapacity)
     , mInterval(aInterval)
     , mFeatures(AdjustFeatures(aFeatures, aFilterCount))
-    , mBuffer(MakeUnique<ProfileBuffer>(aEntries))
+    , mBuffer(MakeUnique<ProfileBuffer>(aCapacity))
       // The new sampler thread doesn't start sampling immediately because the
       // main loop within Run() is blocked until this function's caller unlocks
       // gPSMutex.
     , mSamplerThread(NewSamplerThread(aLock, mGeneration, aInterval))
     , mInterposeObserver(ProfilerFeature::HasMainThreadIO(aFeatures)
                          ? new ProfilerIOInterposeObserver()
                          : nullptr)
 #undef HAS_FEATURE
@@ -476,40 +476,40 @@ private:
         }
       }
     }
 
     return false;
   }
 
 public:
-  static void Create(PSLockRef aLock, uint32_t aEntries, double aInterval,
+  static void Create(PSLockRef aLock, uint32_t aCapacity, double aInterval,
                      uint32_t aFeatures,
                      const char** aFilters, uint32_t aFilterCount)
   {
-    sInstance = new ActivePS(aLock, aEntries, aInterval, aFeatures,
+    sInstance = new ActivePS(aLock, aCapacity, aInterval, aFeatures,
                              aFilters, aFilterCount);
   }
 
   static MOZ_MUST_USE SamplerThread* Destroy(PSLockRef aLock)
   {
     auto samplerThread = sInstance->mSamplerThread;
     delete sInstance;
     sInstance = nullptr;
 
     return samplerThread;
   }
 
   static bool Exists(PSLockRef) { return !!sInstance; }
 
   static bool Equals(PSLockRef,
-                     uint32_t aEntries, double aInterval, uint32_t aFeatures,
+                     uint32_t aCapacity, double aInterval, uint32_t aFeatures,
                      const char** aFilters, uint32_t aFilterCount)
   {
-    if (sInstance->mEntries != aEntries ||
+    if (sInstance->mCapacity != aCapacity ||
         sInstance->mInterval != aInterval ||
         sInstance->mFeatures != aFeatures ||
         sInstance->mFilters.length() != aFilterCount) {
       return false;
     }
 
     for (uint32_t i = 0; i < sInstance->mFilters.length(); ++i) {
       if (strcmp(sInstance->mFilters[i].c_str(), aFilters[i]) != 0) {
@@ -539,17 +539,17 @@ public:
     MOZ_RELEASE_ASSERT(sInstance);
 
     return ((aInfo->IsMainThread() || FeatureThreads(aLock)) &&
             sInstance->ThreadSelected(aInfo->Name()));
   }
 
   PS_GET(uint32_t, Generation)
 
-  PS_GET(uint32_t, Entries)
+  PS_GET(uint32_t, Capacity)
 
   PS_GET(double, Interval)
 
   PS_GET(uint32_t, Features)
 
   #define PS_GET_FEATURE(n_, str_, Name_) \
     static bool Feature##Name_(PSLockRef) \
     { \
@@ -688,18 +688,18 @@ private:
   //   profiler_stop() is stuck, unable to finish.
   //
   // By checking ActivePS *and* the generation, we can avoid this scenario.
   // sNextGeneration is used to track the next generation number; it is static
   // because it must persist across different ActivePS instantiations.
   const uint32_t mGeneration;
   static uint32_t sNextGeneration;
 
-  // The number of entries in mBuffer.
-  const uint32_t mEntries;
+  // The maximum number of entries in mBuffer.
+  const uint32_t mCapacity;
 
   // The interval between samples, measured in milliseconds.
   const double mInterval;
 
   // The profile features that are enabled.
   const uint32_t mFeatures;
 
   // Substrings of names of threads we want to profile.
@@ -2466,33 +2466,33 @@ NotifyObservers(const char* aTopic, nsIS
   }
 
   if (nsCOMPtr<nsIObserverService> os = services::GetObserverService()) {
     os->NotifyObservers(aSubject, aTopic, nullptr);
   }
 }
 
 static void
-NotifyProfilerStarted(const int aEntries, double aInterval, uint32_t aFeatures,
+NotifyProfilerStarted(const int aCapacity, double aInterval, uint32_t aFeatures,
                       const char** aFilters, uint32_t aFilterCount)
 {
   nsTArray<nsCString> filtersArray;
   for (size_t i = 0; i < aFilterCount; ++i) {
     filtersArray.AppendElement(aFilters[i]);
   }
 
   nsCOMPtr<nsIProfilerStartParams> params =
-    new nsProfilerStartParams(aEntries, aInterval, aFeatures, filtersArray);
+    new nsProfilerStartParams(aCapacity, aInterval, aFeatures, filtersArray);
 
   ProfilerParent::ProfilerStarted(params);
   NotifyObservers("profiler-started", params);
 }
 
 static void
-locked_profiler_start(PSLockRef aLock, uint32_t aEntries, double aInterval,
+locked_profiler_start(PSLockRef aLock, uint32_t aCapacity, double aInterval,
                       uint32_t aFeatures,
                       const char** aFilters, uint32_t aFilterCount);
 
 // This basically duplicates AutoProfilerLabel's constructor.
 ProfilingStack*
 MozGlueLabelEnter(const char* aLabel, const char* aDynamicString, void* aSp,
                   uint32_t aLine)
 {
@@ -2566,17 +2566,17 @@ profiler_init(void* aStackTop)
 
   UniquePtr<char[]> filterStorage;
 
   nsTArray<const char*> filters;
   filters.AppendElement("GeckoMain");
   filters.AppendElement("Compositor");
   filters.AppendElement("DOM Worker");
 
-  int entries = PROFILER_DEFAULT_ENTRIES;
+  int capacity = PROFILER_DEFAULT_ENTRIES;
   double interval = PROFILER_DEFAULT_INTERVAL;
 
   {
     PSAutoLock lock(gPSMutex);
 
     // We've passed the possible failure point. Instantiate CorePS, which
     // indicates that the profiler has initialized successfully.
     CorePS::Create(lock);
@@ -2607,25 +2607,25 @@ profiler_init(void* aStackTop)
 
     const char* startupEnv = getenv("MOZ_PROFILER_STARTUP");
     if (!startupEnv || startupEnv[0] == '\0') {
       return;
     }
 
     LOG("- MOZ_PROFILER_STARTUP is set");
 
-    const char* startupEntries = getenv("MOZ_PROFILER_STARTUP_ENTRIES");
-    if (startupEntries && startupEntries[0] != '\0') {
+    const char* startupCapacity = getenv("MOZ_PROFILER_STARTUP_ENTRIES");
+    if (startupCapacity && startupCapacity[0] != '\0') {
       errno = 0;
-      entries = strtol(startupEntries, nullptr, 10);
-      if (errno == 0 && entries > 0) {
-        LOG("- MOZ_PROFILER_STARTUP_ENTRIES = %d", entries);
+      capacity = strtol(startupCapacity, nullptr, 10);
+      if (errno == 0 && capacity > 0) {
+        LOG("- MOZ_PROFILER_STARTUP_ENTRIES = %d", capacity);
       } else {
         LOG("- MOZ_PROFILER_STARTUP_ENTRIES not a valid integer: %s",
-            startupEntries);
+            startupCapacity);
         PrintUsageThenExit(1);
       }
     }
 
     const char* startupInterval = getenv("MOZ_PROFILER_STARTUP_INTERVAL");
     if (startupInterval && startupInterval[0] != '\0') {
       errno = 0;
       interval = PR_strtod(startupInterval, nullptr);
@@ -2665,23 +2665,23 @@ profiler_init(void* aStackTop)
     }
 
     const char* startupFilters = getenv("MOZ_PROFILER_STARTUP_FILTERS");
     if (startupFilters && startupFilters[0] != '\0') {
       filters = SplitAtCommas(startupFilters, filterStorage);
       LOG("- MOZ_PROFILER_STARTUP_FILTERS = %s", startupFilters);
     }
 
-    locked_profiler_start(lock, entries, interval, features,
+    locked_profiler_start(lock, capacity, interval, features,
                           filters.Elements(), filters.Length());
   }
 
   // We do this with gPSMutex unlocked. The comment in profiler_stop() explains
   // why.
-  NotifyProfilerStarted(entries, interval, features,
+  NotifyProfilerStarted(capacity, interval, features,
                         filters.Elements(), filters.Length());
 }
 
 static void
 locked_profiler_save_profile_to_file(PSLockRef aLock, const char* aFilename,
                                      bool aIsShuttingDown);
 
 static SamplerThread*
@@ -2783,69 +2783,69 @@ profiler_get_profile_json_into_lazily_al
   if (!WriteProfileToJSONWriter(b, aSinceTime, aIsShuttingDown)) {
     return;
   }
 
   b.WriteFunc()->CopyDataIntoLazilyAllocatedBuffer(aAllocator);
 }
 
 void
-profiler_get_start_params(int* aEntries, double* aInterval, uint32_t* aFeatures,
+profiler_get_start_params(int* aCapacity, double* aInterval, uint32_t* aFeatures,
                           Vector<const char*>* aFilters)
 {
   MOZ_RELEASE_ASSERT(CorePS::Exists());
 
-  if (NS_WARN_IF(!aEntries) || NS_WARN_IF(!aInterval) ||
+  if (NS_WARN_IF(!aCapacity) || NS_WARN_IF(!aInterval) ||
       NS_WARN_IF(!aFeatures) || NS_WARN_IF(!aFilters)) {
     return;
   }
 
   PSAutoLock lock(gPSMutex);
 
   if (!ActivePS::Exists(lock)) {
-    *aEntries = 0;
+    *aCapacity = 0;
     *aInterval = 0;
     *aFeatures = 0;
     aFilters->clear();
     return;
   }
 
-  *aEntries = ActivePS::Entries(lock);
+  *aCapacity = ActivePS::Capacity(lock);
   *aInterval = ActivePS::Interval(lock);
   *aFeatures = ActivePS::Features(lock);
 
   const Vector<std::string>& filters = ActivePS::Filters(lock);
   MOZ_ALWAYS_TRUE(aFilters->resize(filters.length()));
   for (uint32_t i = 0; i < filters.length(); ++i) {
     (*aFilters)[i] = filters[i].c_str();
   }
 }
 
 AutoSetProfilerEnvVarsForChildProcess::AutoSetProfilerEnvVarsForChildProcess(
   MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM_IN_IMPL)
-  : mSetEntries()
+  : mSetCapacity()
   , mSetInterval()
   , mSetFeaturesBitfield()
   , mSetFilters()
 {
   MOZ_GUARD_OBJECT_NOTIFIER_INIT;
 
   MOZ_RELEASE_ASSERT(CorePS::Exists());
 
   PSAutoLock lock(gPSMutex);
 
   if (!ActivePS::Exists(lock)) {
     PR_SetEnv("MOZ_PROFILER_STARTUP=");
     return;
   }
 
   PR_SetEnv("MOZ_PROFILER_STARTUP=1");
-  SprintfLiteral(mSetEntries, "MOZ_PROFILER_STARTUP_ENTRIES=%d",
-                 ActivePS::Entries(lock));
-  PR_SetEnv(mSetEntries);
+  SprintfLiteral(mSetCapacity, "MOZ_PROFILER_STARTUP_ENTRIES=%d",
+                 ActivePS::Capacity(lock));
+  PR_SetEnv(mSetCapacity);
 
   // Use AppendFloat instead of SprintfLiteral with %f because the decimal
   // separator used by %f is locale-dependent. But the string we produce needs
   // to be parseable by strtod, which only accepts the period character as a
   // decimal separator. AppendFloat always uses the period character.
   nsCString setInterval;
   setInterval.AppendLiteral("MOZ_PROFILER_STARTUP_INTERVAL=");
   setInterval.AppendFloat(ActivePS::Interval(lock));
@@ -2965,17 +2965,17 @@ profiler_get_buffer_info()
 
   if (!ActivePS::Exists(lock)) {
     return Nothing();
   }
 
   return Some(ProfilerBufferInfo {
     ActivePS::Buffer(lock).mRangeStart,
     ActivePS::Buffer(lock).mRangeEnd,
-    ActivePS::Entries(lock)
+    ActivePS::Capacity(lock)
   });
 }
 
 static void
 PollJSSamplingForCurrentThread()
 {
   MOZ_RELEASE_ASSERT(CorePS::Exists());
 
@@ -3011,23 +3011,23 @@ TriggerPollJSSamplingOnMainThread()
       NS_NewRunnableFunction("TriggerPollJSSamplingOnMainThread", []() {
         PollJSSamplingForCurrentThread();
       });
     SystemGroup::Dispatch(TaskCategory::Other, task.forget());
   }
 }
 
 static void
-locked_profiler_start(PSLockRef aLock, uint32_t aEntries, double aInterval,
+locked_profiler_start(PSLockRef aLock, uint32_t aCapacity, double aInterval,
                       uint32_t aFeatures,
                       const char** aFilters, uint32_t aFilterCount)
 {
   if (LOG_TEST) {
     LOG("locked_profiler_start");
-    LOG("- entries  = %d", aEntries);
+    LOG("- capacity  = %d", aCapacity);
     LOG("- interval = %.2f", aInterval);
 
     #define LOG_FEATURE(n_, str_, Name_) \
       if (ProfilerFeature::Has##Name_(aFeatures)) { \
         LOG("- feature  = %s", str_); \
       }
 
     PROFILER_FOR_EACH_FEATURE(LOG_FEATURE)
@@ -3041,20 +3041,20 @@ locked_profiler_start(PSLockRef aLock, u
 
   MOZ_RELEASE_ASSERT(CorePS::Exists() && !ActivePS::Exists(aLock));
 
 #if defined(GP_PLAT_amd64_windows)
   InitializeWin64ProfilerHooks();
 #endif
 
   // Fall back to the default values if the passed-in values are unreasonable.
-  uint32_t entries = aEntries > 0 ? aEntries : PROFILER_DEFAULT_ENTRIES;
+  uint32_t capacity = aCapacity > 0 ? aCapacity : PROFILER_DEFAULT_ENTRIES;
   double interval = aInterval > 0 ? aInterval : PROFILER_DEFAULT_INTERVAL;
 
-  ActivePS::Create(aLock, entries, interval, aFeatures, aFilters, aFilterCount);
+  ActivePS::Create(aLock, capacity, interval, aFeatures, aFilters, aFilterCount);
 
   // Set up profiling for each registered thread, if appropriate.
   int tid = Thread::GetCurrentId();
   const nsTArray<UniquePtr<RegisteredThread>>& registeredThreads =
     CorePS::RegisteredThreads(aLock);
   for (auto& registeredThread : registeredThreads) {
     RefPtr<ThreadInfo> info = registeredThread->Info();
 
@@ -3102,17 +3102,17 @@ locked_profiler_start(PSLockRef aLock, u
   }
 #endif
 
   // At the very end, set up RacyFeatures.
   RacyFeatures::SetActive(ActivePS::Features(aLock));
 }
 
 void
-profiler_start(uint32_t aEntries, double aInterval, uint32_t aFeatures,
+profiler_start(uint32_t aCapacity, double aInterval, uint32_t aFeatures,
                const char** aFilters, uint32_t aFilterCount)
 {
   LOG("profiler_start");
 
 
   SamplerThread* samplerThread = nullptr;
   {
     PSAutoLock lock(gPSMutex);
@@ -3122,79 +3122,79 @@ profiler_start(uint32_t aEntries, double
       profiler_init(nullptr);
     }
 
     // Reset the current state if the profiler is running.
     if (ActivePS::Exists(lock)) {
       samplerThread = locked_profiler_stop(lock);
     }
 
-    locked_profiler_start(lock, aEntries, aInterval, aFeatures,
+    locked_profiler_start(lock, aCapacity, aInterval, aFeatures,
                           aFilters, aFilterCount);
   }
 
 #if defined(MOZ_REPLACE_MALLOC) && defined(MOZ_PROFILER_MEMORY)
   // start counting memory allocations (outside of lock)
   mozilla::profiler::install_memory_counter(true);
 #endif
 
   // We do these operations with gPSMutex unlocked. The comments in
   // profiler_stop() explain why.
   if (samplerThread) {
     ProfilerParent::ProfilerStopped();
     NotifyObservers("profiler-stopped");
     delete samplerThread;
   }
-  NotifyProfilerStarted(aEntries, aInterval, aFeatures,
+  NotifyProfilerStarted(aCapacity, aInterval, aFeatures,
                         aFilters, aFilterCount);
 }
 
 void
-profiler_ensure_started(uint32_t aEntries, double aInterval, uint32_t aFeatures,
+profiler_ensure_started(uint32_t aCapacity, double aInterval, uint32_t aFeatures,
                         const char** aFilters, uint32_t aFilterCount)
 {
   LOG("profiler_ensure_started");
 
   bool startedProfiler = false;
   SamplerThread* samplerThread = nullptr;
   {
     PSAutoLock lock(gPSMutex);
 
     // Initialize if necessary.
     if (!CorePS::Exists()) {
       profiler_init(nullptr);
     }
 
     if (ActivePS::Exists(lock)) {
       // The profiler is active.
-      if (!ActivePS::Equals(lock, aEntries, aInterval, aFeatures,
+      if (!ActivePS::Equals(lock, aCapacity, aInterval, aFeatures,
                             aFilters, aFilterCount)) {
         // Stop and restart with different settings.
         samplerThread = locked_profiler_stop(lock);
-        locked_profiler_start(lock, aEntries, aInterval, aFeatures,
+        locked_profiler_start(lock, aCapacity, aInterval, aFeatures,
                               aFilters, aFilterCount);
         startedProfiler = true;
       }
     } else {
       // The profiler is stopped.
-      locked_profiler_start(lock, aEntries, aInterval, aFeatures,
+      locked_profiler_start(lock, aCapacity, aInterval, aFeatures,
                             aFilters, aFilterCount);
       startedProfiler = true;
     }
   }
 
   // We do these operations with gPSMutex unlocked. The comments in
   // profiler_stop() explain why.
   if (samplerThread) {
     ProfilerParent::ProfilerStopped();
     NotifyObservers("profiler-stopped");
     delete samplerThread;
   }
   if (startedProfiler) {
-    NotifyProfilerStarted(aEntries, aInterval, aFeatures,
+    NotifyProfilerStarted(aCapacity, aInterval, aFeatures,
                           aFilters, aFilterCount);
   }
 }
 
 static MOZ_MUST_USE SamplerThread*
 locked_profiler_stop(PSLockRef aLock)
 {
   LOG("locked_profiler_stop");
--- a/tools/profiler/public/GeckoProfiler.h
+++ b/tools/profiler/public/GeckoProfiler.h
@@ -249,39 +249,39 @@ void profiler_init(void* stackTop);
 // also save a shutdown profile if requested. No profiler calls should happen
 // after this point and all profiling stack labels should have been popped.
 void profiler_shutdown();
 
 // Start the profiler -- initializing it first if necessary -- with the
 // selected options. Stops and restarts the profiler if it is already active.
 // After starting the profiler is "active". The samples will be recorded in a
 // circular buffer.
-//   "aEntries" is the number of entries in the profiler's circular buffer.
+//   "aCapacity" is the maximum number of entries in the profiler's circular buffer.
 //   "aInterval" the sampling interval, measured in millseconds.
 //   "aFeatures" is the feature set. Features unsupported by this
 //               platform/configuration are ignored.
 //   "aFilters" is the list of thread filters. Threads that do not match any
 //              of the filters are not profiled. A filter matches a thread if
 //              (a) the thread name contains the filter as a case-insensitive
 //                  substring, or
 //              (b) the filter is of the form "pid:<n>" where n is the process
 //                  id of the process that the thread is running in.
-void profiler_start(uint32_t aEntries, double aInterval, uint32_t aFeatures,
+void profiler_start(uint32_t aCapacity, double aInterval, uint32_t aFeatures,
                     const char** aFilters, uint32_t aFilterCount);
 
 // Stop the profiler and discard the profile without saving it. A no-op if the
 // profiler is inactive. After stopping the profiler is "inactive".
 void profiler_stop();
 
 // If the profiler is inactive, start it. If it's already active, restart it if
 // the requested settings differ from the current settings. Both the check and
 // the state change are performed while the profiler state is locked.
 // The only difference to profiler_start is that the current buffer contents are
 // not discarded if the profiler is already running with the requested settings.
-void profiler_ensure_started(uint32_t aEntries, double aInterval,
+void profiler_ensure_started(uint32_t aCapacity, double aInterval,
                              uint32_t aFeatures, const char** aFilters,
                              uint32_t aFilterCount);
 
 //---------------------------------------------------------------------------
 // Control the profiler
 //---------------------------------------------------------------------------
 
 // Register/unregister threads with the profiler. Both functions operate the
@@ -818,17 +818,17 @@ protected:
 class MOZ_RAII AutoSetProfilerEnvVarsForChildProcess
 {
 public:
   explicit AutoSetProfilerEnvVarsForChildProcess(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM);
   ~AutoSetProfilerEnvVarsForChildProcess();
 
 private:
   MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
-  char mSetEntries[64];
+  char mSetCapacity[64];
   char mSetInterval[64];
   char mSetFeaturesBitfield[64];
   char mSetFilters[1024];
 };
 
 } // namespace mozilla
 
 #endif // !MOZ_GECKO_PROFILER