Backed out 2 changesets (bug 1475988) for causing bustage in /build/src/toolkit/components/telemetry/Telemetry.cpp on a CLOSED TREE
authorMargareta Eliza Balazs <ebalazs@mozilla.com>
Wed, 18 Jul 2018 15:24:56 +0300
changeset 819843 ebc391c0f797641205ed5cbf7e1062d35300e158
parent 819842 c19e776269d896b011a6bdcd831605d3c6afe779
child 819844 ffb7a39759332c492c681568017c57ed477179ba
push id116678
push userbmo:nchevobbe@mozilla.com
push dateWed, 18 Jul 2018 18:05:12 +0000
bugs1475988
milestone63.0a1
backs outc19e776269d896b011a6bdcd831605d3c6afe779
f32ce7c754f0180db94244ada289915c8f9c5b2e
Backed out 2 changesets (bug 1475988) for causing bustage in /build/src/toolkit/components/telemetry/Telemetry.cpp on a CLOSED TREE Backed out changeset c19e776269d8 (bug 1475988) Backed out changeset f32ce7c754f0 (bug 1475988)
toolkit/components/telemetry/KeyedStackCapturer.cpp
toolkit/components/telemetry/KeyedStackCapturer.h
toolkit/components/telemetry/Telemetry.cpp
toolkit/components/telemetry/TelemetryHistogram.cpp
toolkit/components/telemetry/TelemetryHistogram.h
--- a/toolkit/components/telemetry/KeyedStackCapturer.cpp
+++ b/toolkit/components/telemetry/KeyedStackCapturer.cpp
@@ -154,18 +154,10 @@ KeyedStackCapturer::ReflectCapturedStack
 void
 KeyedStackCapturer::Clear()
 {
   MutexAutoLock captureStackMutex(mStackCapturerMutex);
   mStackInfos.Clear();
   mStacks.Clear();
 }
 
-size_t
-KeyedStackCapturer::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const {
-  size_t n = 0;
-  n += mStackInfos.SizeOfExcludingThis(aMallocSizeOf);
-  n += mStacks.SizeOfExcludingThis();
-  return n;
-}
-
 } // namespace Telemetry
 } // namespace mozilla
--- a/toolkit/components/telemetry/KeyedStackCapturer.h
+++ b/toolkit/components/telemetry/KeyedStackCapturer.h
@@ -41,18 +41,16 @@ public:
    NS_IMETHODIMP ReflectCapturedStacks(
     JSContext *cx, JS::MutableHandle<JS::Value> ret);
 
   /**
    * Resets captured stacks and the information related to them.
    */
   void Clear();
 
-  size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
-
 private:
   /**
    * Describes how often a stack was captured.
    */
   struct StackFrequencyInfo {
     // A number of times the stack was captured.
     uint32_t mCount;
     // Index of the stack inside stacks array.
--- a/toolkit/components/telemetry/Telemetry.cpp
+++ b/toolkit/components/telemetry/Telemetry.cpp
@@ -215,117 +215,24 @@ private:
 TelemetryImpl*  TelemetryImpl::sTelemetry = nullptr;
 
 MOZ_DEFINE_MALLOC_SIZE_OF(TelemetryMallocSizeOf)
 
 NS_IMETHODIMP
 TelemetryImpl::CollectReports(nsIHandleReportCallback* aHandleReport,
                               nsISupports* aData, bool aAnonymize)
 {
-  mozilla::MallocSizeOf aMallocSizeOf = TelemetryMallocSizeOf;
-
-#define COLLECT_REPORT(name, size, desc) \
-  MOZ_COLLECT_REPORT(name, KIND_HEAP, UNITS_BYTES, size, desc)
-
-  COLLECT_REPORT("explicit/telemetry/impl", aMallocSizeOf(this),
-      "Memory used by the Telemetry core implemenation");
-
-  COLLECT_REPORT("explicit/telemetry/histogram/shallow",
-      TelemetryHistogram::GetMapShallowSizesOfExcludingThis(aMallocSizeOf),
-      "Memory used by the Telemetry Histogram implementation");
-
-  COLLECT_REPORT("explicit/telemetry/scalar/shallow",
-      TelemetryScalar::GetMapShallowSizesOfExcludingThis(aMallocSizeOf),
-      "Memory used by the Telemetry Scalar implemenation");
-
-  COLLECT_REPORT("explicit/telemetry/WebRTC",
-      mWebrtcTelemetry.SizeOfExcludingThis(aMallocSizeOf),
-      "Memory used by WebRTC Telemetry");
-
-  { // Scope for mHashMutex lock
-    MutexAutoLock lock(mHashMutex);
-    COLLECT_REPORT("explicit/telemetry/PrivateSQL",
-        mPrivateSQL.SizeOfExcludingThis(aMallocSizeOf),
-        "Memory used by the PrivateSQL Telemetry");
-
-    COLLECT_REPORT("explicit/telemetry/SanitizedSQL",
-        mSanitizedSQL.SizeOfExcludingThis(aMallocSizeOf),
-        "Memory used by the SanitizedSQL Telemetry");
-  }
-
-  if (sTelemetryIOObserver) {
-    COLLECT_REPORT("explicit/telemetry/IOObserver",
-        sTelemetryIOObserver->SizeOfIncludingThis(aMallocSizeOf),
-        "Memory used by the Telemetry IO Observer");
-  }
-
-#if defined(MOZ_GECKO_PROFILER)
-  COLLECT_REPORT("explicit/telemetry/StackCapturer",
-        mStackCapturer.SizeOfExcludingThis(aMallocSizeOf),
-        "Memory used by the Telemetry Stack capturer");
-#endif
-
-  COLLECT_REPORT("explicit/telemetry/LateWritesStacks",
-        mLateWritesStacks.SizeOfExcludingThis(),
-        "Memory used by the Telemetry LateWrites Stack capturer");
-
-  COLLECT_REPORT("explicit/telemetry/Callbacks",
-        mCallbacks.ShallowSizeOfExcludingThis(aMallocSizeOf),
-        "Memory used by the Telemetry Callbacks array (shallow)");
-
-  COLLECT_REPORT("explicit/telemetry/histogram/data",
-      TelemetryHistogram::GetHistogramSizesOfIncludingThis(aMallocSizeOf),
-      "Memory used by Telemetry Histogram data");
-
-  COLLECT_REPORT("explicit/telemetry/scalar/data",
-      TelemetryScalar::GetScalarSizesOfIncludingThis(aMallocSizeOf),
-      "Memory used by Telemetry Scalar data");
-
-  COLLECT_REPORT("explicit/telemetry/event/data",
-      TelemetryEvent::SizeOfIncludingThis(aMallocSizeOf),
-      "Memory used by Telemetry Event data");
-
-#undef COLLECT_REPORT
+  MOZ_COLLECT_REPORT(
+    "explicit/telemetry", KIND_HEAP, UNITS_BYTES,
+    SizeOfIncludingThis(TelemetryMallocSizeOf),
+    "Memory used by the telemetry system.");
 
   return NS_OK;
 }
 
-size_t
-TelemetryImpl::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf)
-{
-  size_t n = aMallocSizeOf(this);
-
-  n += TelemetryHistogram::GetMapShallowSizesOfExcludingThis(aMallocSizeOf);
-  n += TelemetryScalar::GetMapShallowSizesOfExcludingThis(aMallocSizeOf);
-  n += mWebrtcTelemetry.SizeOfExcludingThis(aMallocSizeOf);
-  { // Scope for mHashMutex lock
-    MutexAutoLock lock(mHashMutex);
-    n += mPrivateSQL.SizeOfExcludingThis(aMallocSizeOf);
-    n += mSanitizedSQL.SizeOfExcludingThis(aMallocSizeOf);
-  }
-
-  // It's a bit gross that we measure this other stuff that lives outside of
-  // TelemetryImpl... oh well.
-  if (sTelemetryIOObserver) {
-    n += sTelemetryIOObserver->SizeOfIncludingThis(aMallocSizeOf);
-  }
-
-#if defined(MOZ_GECKO_PROFILER)
-  n += mStackCapturer.SizeOfExcludingThis(aMallocSizeOf);
-#endif
-  n += mLateWritesStacks.SizeOfExcludingThis();
-  n += mCallbacks.ShallowSizeOfExcludingThis(aMallocSizeOf);
-
-  n += TelemetryHistogram::GetHistogramSizesOfIncludingThis(aMallocSizeOf);
-  n += TelemetryScalar::GetScalarSizesOfIncludingThis(aMallocSizeOf);
-  n += TelemetryEvent::SizeOfIncludingThis(aMallocSizeOf);
-
-  return n;
-}
-
 void
 InitHistogramRecordingEnabled()
 {
   TelemetryHistogram::InitHistogramRecordingEnabled();
 }
 
 using PathChar = filesystem::Path::value_type;
 using PathCharPtr = const PathChar*;
@@ -1829,16 +1736,43 @@ TelemetryImpl::SetEventRecordingEnabled(
 
 NS_IMETHODIMP
 TelemetryImpl::FlushBatchedChildTelemetry()
 {
   TelemetryIPCAccumulator::IPCTimerFired(nullptr, nullptr);
   return NS_OK;
 }
 
+size_t
+TelemetryImpl::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf)
+{
+  size_t n = aMallocSizeOf(this);
+
+  n += TelemetryHistogram::GetMapShallowSizesOfExcludingThis(aMallocSizeOf);
+  n += TelemetryScalar::GetMapShallowSizesOfExcludingThis(aMallocSizeOf);
+  n += mWebrtcTelemetry.SizeOfExcludingThis(aMallocSizeOf);
+  { // Scope for mHashMutex lock
+    MutexAutoLock lock(mHashMutex);
+    n += mPrivateSQL.SizeOfExcludingThis(aMallocSizeOf);
+    n += mSanitizedSQL.SizeOfExcludingThis(aMallocSizeOf);
+  }
+
+  // It's a bit gross that we measure this other stuff that lives outside of
+  // TelemetryImpl... oh well.
+  if (sTelemetryIOObserver) {
+    n += sTelemetryIOObserver->SizeOfIncludingThis(aMallocSizeOf);
+  }
+
+  n += TelemetryHistogram::GetHistogramSizesofIncludingThis(aMallocSizeOf);
+  n += TelemetryScalar::GetScalarSizesOfIncludingThis(aMallocSizeOf);
+  n += TelemetryEvent::SizeOfIncludingThis(aMallocSizeOf);
+
+  return n;
+}
+
 } // namespace
 
 
 ////////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////////
 //
 // EXTERNALLY VISIBLE FUNCTIONS in no name space
 // These are NOT listed in Telemetry.h
--- a/toolkit/components/telemetry/TelemetryHistogram.cpp
+++ b/toolkit/components/telemetry/TelemetryHistogram.cpp
@@ -195,18 +195,16 @@ public:
   void Clear();
 
   HistogramID GetHistogramID() const { return mId; }
 
   bool IsEmpty() const { return mHistogramMap.IsEmpty(); }
 
   bool IsExpired() const { return mIsExpired; }
 
-  size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf);
-
 private:
   typedef nsBaseHashtableET<nsCStringHashKey, Histogram*> KeyedHistogramEntry;
   typedef AutoHashtable<KeyedHistogramEntry> KeyedHistogramMapType;
   KeyedHistogramMapType mHistogramMap;
 
   const HistogramID mId;
   const HistogramInfo& mHistogramInfo;
   bool mIsExpired;
@@ -1035,25 +1033,16 @@ KeyedHistogram::Clear()
     if (h == gExpiredHistogram) {
       continue;
     }
     delete h;
   }
   mHistogramMap.Clear();
 }
 
-size_t
-KeyedHistogram::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf)
-{
-  size_t n = 0;
-  n += aMallocSizeOf(this);
-  n += mHistogramMap.SizeOfIncludingThis(aMallocSizeOf);
-  return n;
-}
-
 nsresult
 KeyedHistogram::GetJSKeys(JSContext* cx, JS::CallArgs& args)
 {
   JS::AutoValueVector keys(cx);
   if (!keys.reserve(mHistogramMap.Count())) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
@@ -2566,54 +2555,22 @@ size_t
 TelemetryHistogram::GetMapShallowSizesOfExcludingThis(mozilla::MallocSizeOf
                                                       aMallocSizeOf)
 {
   StaticMutexAutoLock locker(gTelemetryHistogramMutex);
   return gNameToHistogramIDMap.ShallowSizeOfExcludingThis(aMallocSizeOf);
 }
 
 size_t
-TelemetryHistogram::GetHistogramSizesOfIncludingThis(mozilla::MallocSizeOf
+TelemetryHistogram::GetHistogramSizesofIncludingThis(mozilla::MallocSizeOf
                                                      aMallocSizeOf)
 {
   StaticMutexAutoLock locker(gTelemetryHistogramMutex);
-
-  size_t n = 0;
-
-  // If we allocated the array, let's count the number of pointers in there and
-  // each entry's size.
-  if (gKeyedHistogramStorage) {
-    n += HistogramCount * size_t(ProcessID::Count) * sizeof(KeyedHistogram*);
-    for (size_t i = 0; i < HistogramCount * size_t(ProcessID::Count); ++i) {
-      if (gKeyedHistogramStorage[i] && gKeyedHistogramStorage[i] != gExpiredKeyedHistogram) {
-        n += gKeyedHistogramStorage[i]->SizeOfIncludingThis(aMallocSizeOf);
-      }
-    }
-  }
-
-  // If we allocated the array, let's count the number of pointers in there.
-  if (gHistogramStorage) {
-    n += HistogramCount * size_t(ProcessID::Count) * sizeof(Histogram*);
-    for (size_t i = 0; i < HistogramCount * size_t(ProcessID::Count); ++i) {
-      if (gHistogramStorage[i] && gHistogramStorage[i] != gExpiredHistogram) {
-        n += gHistogramStorage[i]->SizeOfIncludingThis(aMallocSizeOf);
-      }
-    }
-  }
-
-  // We only allocate the expired (keyed) histogram once.
-  if (gExpiredKeyedHistogram) {
-    n += gExpiredKeyedHistogram->SizeOfIncludingThis(aMallocSizeOf);
-  }
-
-  if (gExpiredHistogram) {
-    n += gExpiredHistogram->SizeOfIncludingThis(aMallocSizeOf);
-  }
-
-  return n;
+  // TODO
+  return 0;
 }
 
 ////////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////////
 //
 // PRIVATE: GeckoView specific helpers
 
 namespace base {
--- a/toolkit/components/telemetry/TelemetryHistogram.h
+++ b/toolkit/components/telemetry/TelemetryHistogram.h
@@ -75,17 +75,17 @@ CreateHistogramSnapshots(JSContext* aCx,
 nsresult
 GetKeyedHistogramSnapshots(JSContext *aCx, JS::MutableHandleValue aResult, unsigned int aDataset,
                            bool aClearSubsession);
 
 size_t
 GetMapShallowSizesOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf);
 
 size_t
-GetHistogramSizesOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf);
+GetHistogramSizesofIncludingThis(mozilla::MallocSizeOf aMallocSizeOf);
 
 // These functions are only meant to be used for GeckoView persistence.
 // They are responsible for updating in-memory probes with the data persisted
 // on the disk and vice-versa.
 nsresult SerializeHistograms(mozilla::JSONWriter &aWriter);
 nsresult SerializeKeyedHistograms(mozilla::JSONWriter &aWriter);
 nsresult DeserializeHistograms(JSContext* aCx, JS::HandleValue aData);
 nsresult DeserializeKeyedHistograms(JSContext* aCx, JS::HandleValue aData);