Bug 1215540 - Fix Telemetry reporting repeated hang annotations in Thread hangs. r=aklotz
☠☠ backed out by e9cae6188ca4 ☠ ☠
authorAlessio Placitelli <alessio.placitelli@gmail.com>
Thu, 22 Oct 2015 09:56:00 +0200
changeset 304321 a655cd7082e9354b1a40f57b28cd417efd07a6a3
parent 304320 712073c4f0b41cfa50f3d99332b44882cbeb0644
child 304322 8ac69f649c9922e301d817deed68e2f2f38eba06
push id1001
push userraliiev@mozilla.com
push dateMon, 18 Jan 2016 19:06:03 +0000
treeherdermozilla-release@8b89261f3ac4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaklotz
bugs1215540
milestone44.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 1215540 - Fix Telemetry reporting repeated hang annotations in Thread hangs. r=aklotz
toolkit/components/telemetry/Telemetry.cpp
--- a/toolkit/components/telemetry/Telemetry.cpp
+++ b/toolkit/components/telemetry/Telemetry.cpp
@@ -2905,24 +2905,39 @@ CreateJSHangStack(JSContext* cx, const T
 
 static JSObject*
 CreateJSHangAnnotations(JSContext* cx, const HangAnnotationsVector& annotations)
 {
   JS::RootedObject annotationsArray(cx, JS_NewArrayObject(cx, 0));
   if (!annotationsArray) {
     return nullptr;
   }
+  // We keep track of the annotations we reported in this hash set, so we can
+  // discard duplicated ones.
+  nsTHashtable<nsStringHashKey> reportedAnnotations;
   size_t annotationIndex = 0;
   for (const HangAnnotationsPtr *i = annotations.begin(), *e = annotations.end();
        i != e; ++i) {
     JS::RootedObject jsAnnotation(cx, JS_NewPlainObject(cx));
     if (!jsAnnotation) {
       continue;
     }
     const HangAnnotationsPtr& curAnnotations = *i;
+    // Build a key to index the current annotations in our hash set.
+    nsAutoString annotationsKey;
+    nsresult rv = ComputeAnnotationsKey(curAnnotations, annotationsKey);
+    if (NS_FAILED(rv)) {
+      continue;
+    }
+    // Check if the annotations are in the set. If that's the case, don't double report.
+    if (reportedAnnotations.GetEntry(annotationsKey)) {
+      continue;
+    }
+    // If not, report them.
+    reportedAnnotations.PutEntry(annotationsKey);
     UniquePtr<HangAnnotations::Enumerator> annotationsEnum =
       curAnnotations->GetEnumerator();
     if (!annotationsEnum) {
       continue;
     }
     nsAutoString key;
     nsAutoString value;
     while (annotationsEnum->Next(key, value)) {