Backout 75e72a52a0cb, 1120ae801dac, b2572a5cffa9, fa6a273a9b41 (bug 701863) for build failures
authorEd Morley <bmo@edmorley.co.uk>
Sat, 03 Dec 2011 09:13:14 +0000
changeset 82871 4f9c2774591376aae41ab13037e4fbc956f9499d
parent 82870 c7d671e9cf5899f09e7bdc5ff1b5b20504d5498a
child 82872 a68c96c1d8e0a64b9008d95ac52e381d88751521
push id519
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 00:38:35 +0000
treeherdermozilla-beta@788ea1ef610b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs701863
milestone11.0a1
backs out75e72a52a0cbd781606de11f38d57d41d3746afd
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
Backout 75e72a52a0cb, 1120ae801dac, b2572a5cffa9, fa6a273a9b41 (bug 701863) for build failures
toolkit/components/telemetry/Telemetry.cpp
toolkit/components/telemetry/TelemetryPing.js
toolkit/components/telemetry/nsITelemetry.idl
toolkit/components/telemetry/tests/unit/test_TelemetryPing.js
toolkit/components/telemetry/tests/unit/test_nsITelemetry.js
--- a/toolkit/components/telemetry/Telemetry.cpp
+++ b/toolkit/components/telemetry/Telemetry.cpp
@@ -66,18 +66,16 @@ public:
   TelemetryImpl();
   ~TelemetryImpl();
   
   static bool CanRecord();
   static already_AddRefed<nsITelemetry> CreateTelemetryInstance();
   static void ShutdownTelemetry();
 
 private:
-  // Like GetHistogramById, but returns the underlying C++ object, not the JS one.
-  nsresult GetHistogramByName(const nsACString &name, Histogram **ret);
   // This is used for speedy JS string->Telemetry::ID conversions
   typedef nsBaseHashtableET<nsCharPtrHashKey, Telemetry::ID> CharPtrEntryType;
   typedef nsTHashtable<CharPtrEntryType> HistogramMapType;
   HistogramMapType mHistogramMap;
   bool mCanRecord;
   static TelemetryImpl *sTelemetry;
 };
 
@@ -89,48 +87,27 @@ StatisticsRecorder gStatisticsRecorder;
 // Hardcoded probes
 struct TelemetryHistogram {
   Histogram *histogram;
   const char *id;
   PRUint32 min;
   PRUint32 max;
   PRUint32 bucketCount;
   PRUint32 histogramType;
-  const char *comment;
 };
 
 const TelemetryHistogram gHistograms[] = {
-#define HISTOGRAM(id, min, max, bucket_count, histogram_type, comment) \
-  { NULL, NS_STRINGIFY(id), min, max, bucket_count, \
-    nsITelemetry::HISTOGRAM_ ## histogram_type, comment },
+#define HISTOGRAM(id, min, max, bucket_count, histogram_type, b) \
+  { NULL, NS_STRINGIFY(id), min, max, bucket_count, nsITelemetry::HISTOGRAM_ ## histogram_type },
 
 #include "TelemetryHistograms.h"
 
 #undef HISTOGRAM
 };
 
-bool
-TelemetryHistogramType(Histogram *h, PRUint32 *result)
-{
-  switch (h->histogram_type()) {
-  case Histogram::HISTOGRAM:
-    *result = nsITelemetry::HISTOGRAM_EXPONENTIAL;
-    break;
-  case Histogram::LINEAR_HISTOGRAM:
-    *result = nsITelemetry::HISTOGRAM_LINEAR;
-    break;
-  case Histogram::BOOLEAN_HISTOGRAM:
-    *result = nsITelemetry::HISTOGRAM_BOOLEAN;
-    break;
-  default:
-    return false;
-  }
-  return true;
-}
-
 nsresult
 HistogramGet(const char *name, PRUint32 min, PRUint32 max, PRUint32 bucketCount,
              PRUint32 histogramType, Histogram **result)
 {
   if (histogramType != nsITelemetry::HISTOGRAM_BOOLEAN) {
     // Sanity checks for histogram parameters.
     if (min >= max)
       return NS_ERROR_ILLEGAL_VALUE;
@@ -201,16 +178,17 @@ ReflectHistogramSnapshot(JSContext *cx, 
         && JS_DefineProperty(cx, obj, "max", INT_TO_JSVAL(h->declared_max()), NULL, NULL, JSPROP_ENUMERATE)
         && JS_DefineProperty(cx, obj, "histogram_type", INT_TO_JSVAL(h->histogram_type()), NULL, NULL, JSPROP_ENUMERATE)
         && JS_DefineProperty(cx, obj, "sum", DOUBLE_TO_JSVAL(ss.sum()), NULL, NULL, JSPROP_ENUMERATE)
         && (rarray = JS_NewArrayObject(cx, count, NULL))
         && JS_DefineProperty(cx, obj, "ranges", OBJECT_TO_JSVAL(rarray), NULL, NULL, JSPROP_ENUMERATE)
         && FillRanges(cx, rarray, h)
         && (counts_array = JS_NewArrayObject(cx, count, NULL))
         && JS_DefineProperty(cx, obj, "counts", OBJECT_TO_JSVAL(counts_array), NULL, NULL, JSPROP_ENUMERATE)
+        && JS_DefineProperty(cx, obj, "static", static_histogram, NULL, NULL, JSPROP_ENUMERATE)
         )) {
     return JS_FALSE;
   }
   for (size_t i = 0; i < count; i++) {
     if (!JS_DefineElement(cx, counts_array, i, INT_TO_JSVAL(ss.counts(i)), NULL, NULL, JSPROP_ENUMERATE)) {
       return JS_FALSE;
     }
   }
@@ -304,70 +282,16 @@ TelemetryImpl::NewHistogram(const nsACSt
   Histogram *h;
   nsresult rv = HistogramGet(PromiseFlatCString(name).get(), min, max, bucketCount, histogramType, &h);
   if (NS_FAILED(rv))
     return rv;
   h->ClearFlags(Histogram::kUmaTargetedHistogramFlag);
   return WrapAndReturnHistogram(h, cx, ret);
 }
 
-nsresult
-TelemetryImpl::GetHistogramByName(const nsACString &name, Histogram **ret)
-{
-  // Cache names
-  // Note the histogram names are statically allocated
-  if (!mHistogramMap.Count()) {
-    for (PRUint32 i = 0; i < Telemetry::HistogramCount; i++) {
-      CharPtrEntryType *entry = mHistogramMap.PutEntry(gHistograms[i].id);
-      if (NS_UNLIKELY(!entry)) {
-        mHistogramMap.Clear();
-        return NS_ERROR_OUT_OF_MEMORY;
-      }
-      entry->mData = (Telemetry::ID) i;
-    }
-  }
-
-  CharPtrEntryType *entry = mHistogramMap.GetEntry(PromiseFlatCString(name).get());
-  if (!entry)
-    return NS_ERROR_FAILURE;
-
-  nsresult rv = GetHistogramByEnumId(entry->mData, ret);
-  if (NS_FAILED(rv))
-    return rv;
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-TelemetryImpl::HistogramFrom(const nsACString &name, const nsACString &existing_name,
-                             JSContext *cx, jsval *ret)
-{
-  Histogram *existing;
-  nsresult rv = GetHistogramByName(existing_name, &existing);
-  if (NS_FAILED(rv))
-    return rv;
-
-  PRUint32 histogramType;
-  bool success = TelemetryHistogramType(existing, &histogramType);
-  if (!success)
-    return NS_ERROR_INVALID_ARG;
-
-  Histogram *clone;
-  rv = NewUserHistogram(name, existing->declared_min(),
-                        existing->declared_max(), existing->bucket_count(),
-                        histogramType, &clone);
-  if (NS_FAILED(rv))
-    return rv;
-
-  Histogram::SampleSet ss;
-  existing->SnapshotSample(&ss);
-  clone->AddSampleSet(ss);
-  return WrapAndReturnHistogram(clone, cx, ret);
-}
-
 NS_IMETHODIMP
 TelemetryImpl::GetHistogramSnapshots(JSContext *cx, jsval *ret)
 {
   JSObject *root_obj = JS_NewObject(cx, NULL, NULL, NULL);
   if (!root_obj)
     return NS_ERROR_FAILURE;
   *ret = OBJECT_TO_JSVAL(root_obj);
 
@@ -381,44 +305,40 @@ TelemetryImpl::GetHistogramSnapshots(JSC
                                OBJECT_TO_JSVAL(hobj), NULL, NULL, JSPROP_ENUMERATE)
           && ReflectHistogramSnapshot(cx, hobj, h))) {
       return NS_ERROR_FAILURE;
     }
   }
   return NS_OK;
 }
 
-NS_IMETHODIMP
-TelemetryImpl::GetRegisteredHistograms(JSContext *cx, jsval *ret)
-{
-  size_t count = ArrayLength(gHistograms);
-  JSObject *info = JS_NewObject(cx, NULL, NULL, NULL);
-  if (!info)
-    return NS_ERROR_FAILURE;
-
-  for (size_t i = 0; i < count; ++i) {
-    JSString *comment = JS_InternString(cx, gHistograms[i].comment);
-    
-    if (!(comment
-          && JS_DefineProperty(cx, info, gHistograms[i].id,
-                               STRING_TO_JSVAL(comment), NULL, NULL,
-                               JSPROP_ENUMERATE))) {
-      return NS_ERROR_FAILURE;
-    }
-  }
-
-  *ret = OBJECT_TO_JSVAL(info);
-  return NS_OK;
-}
 
 NS_IMETHODIMP
 TelemetryImpl::GetHistogramById(const nsACString &name, JSContext *cx, jsval *ret)
 {
+  // Cache names
+  // Note the histogram names are statically allocated
+  if (!mHistogramMap.Count()) {
+    for (PRUint32 i = 0; i < Telemetry::HistogramCount; i++) {
+      CharPtrEntryType *entry = mHistogramMap.PutEntry(gHistograms[i].id);
+      if (NS_UNLIKELY(!entry)) {
+        mHistogramMap.Clear();
+        return NS_ERROR_OUT_OF_MEMORY;
+      }
+      entry->mData = (Telemetry::ID) i;
+    }
+  }
+
+  CharPtrEntryType *entry = mHistogramMap.GetEntry(PromiseFlatCString(name).get());
+  if (!entry)
+    return NS_ERROR_FAILURE;
+  
   Histogram *h;
-  nsresult rv = GetHistogramByName(name, &h);
+
+  nsresult rv = GetHistogramByEnumId(entry->mData, &h);
   if (NS_FAILED(rv))
     return rv;
 
   return WrapAndReturnHistogram(h, cx, ret);
 }
 
 NS_IMETHODIMP
 TelemetryImpl::GetCanRecord(bool *ret) {
--- a/toolkit/components/telemetry/TelemetryPing.js
+++ b/toolkit/components/telemetry/TelemetryPing.js
@@ -120,31 +120,40 @@ function getSimpleMeasurements() {
 }
 
 function TelemetryPing() {}
 
 TelemetryPing.prototype = {
   _histograms: {},
   _initialized: false,
   _prevValues: {},
+  _sqliteOverhead: {},
 
   /**
    * Returns a set of histograms that can be converted into JSON
    * @return a snapshot of the histograms of form:
    *  { histogram_name: {range:[minvalue,maxvalue], bucket_count:<number of buckets>,
    *    histogram_type: <0 for exponential, 1 for linear>, bucketX:countX, ....} ...}
    * where bucket[XY], count[XY] are positive integers.
    */
   getHistograms: function getHistograms() {
     let hls = Telemetry.histogramSnapshots;
-    let info = Telemetry.registeredHistograms;
     let ret = {};
 
-    function processHistogram(name, hgram) {
-      let r = hgram.ranges;;
+    // bug 701583: report sqlite overhead on startup
+    for (let key in this._sqliteOverhead) {
+      hls[key] = this._sqliteOverhead[key];
+    }
+
+    for (let key in hls) {
+      let hgram = hls[key];
+      if (!hgram.static)
+        continue;
+
+      let r = hgram.ranges;
       let c = hgram.counts;
       let retgram = {
         range: [r[1], r[r.length - 1]],
         bucket_count: r.length,
         histogram_type: hgram.histogram_type,
         values: {},
         sum: hgram.sum
       };
@@ -164,28 +173,18 @@ TelemetryPing.prototype = {
         first = false;
         last = i + 1;
         retgram.values[r[i]] = value;
       }
 
       // add an upper bound
       if (last && last < c.length)
         retgram.values[r[last]] = 0;
-      ret[name] = retgram;
-    };
-
-    for (let name in hls) {
-      if (info[name]) {
-	processHistogram(name, hls[name]);
-	let startup_name = "STARTUP_" + name;
-	if (hls[startup_name])
-	  processHistogram(startup_name, hls[startup_name]);
-      }
+      ret[key] = retgram;
     }
-
     return ret;
   },
 
   addValue: function addValue(name, id, val) {
     let h = this._histograms[name];
     if (!h) {
       h = Telemetry.getHistogramById(id);
       this._histograms[name] = h;
@@ -301,21 +300,21 @@ TelemetryPing.prototype = {
       this.addValue("explicit", "MEMORY_EXPLICIT", Math.floor(explicit / 1024));
     }
   },
   
   /** 
    * Make a copy of sqlite histograms on startup
    */
   gatherStartupSqlite: function gatherStartupSqlite() {
-    let info = Telemetry.registeredHistograms;
+    let hls = Telemetry.histogramSnapshots;
     let sqlite_re = /SQLITE/;
-    for (let name in info) {
-      if (sqlite_re.test(name))
-        Telemetry.histogramFrom("STARTUP_" + name, name);
+    for (let key in hls) {
+      if (sqlite_re.test(key))
+        this._sqliteOverhead["STARTUP_" + key] = hls[key];
     }
   },
 
   /**
    * Send data to the server. Record success/send-time in histograms
    */
   send: function send(reason, server) {
     // populate histograms one last time
--- a/toolkit/components/telemetry/nsITelemetry.idl
+++ b/toolkit/components/telemetry/nsITelemetry.idl
@@ -61,51 +61,32 @@ interface nsITelemetry : nsISupports
    *   counts - array representing contents of the buckets in the histogram
    *   ranges -  an array with calculated bucket sizes
    *   sum - sum of the bucket contents
    *   static - true for histograms defined in TelemetryHistograms.h, false for ones defined with newHistogram
    */
   [implicit_jscontext]
   readonly attribute jsval histogramSnapshots;
 
-  /**
-   * An object whose properties are the names of histograms defined in
-   * TelemetryHistograms.h and whose corresponding values are the textual
-   * comments associated with said histograms.
-   */
-  [implicit_jscontext]
-  readonly attribute jsval registeredHistograms;
-
   /** 
    * Create and return a histogram where bucket sizes increase exponentially. Parameters:
    *
    * @param name Unique histogram name
    * @param min - Minimal bucket size
    * @param max - Maximum bucket size
    * @param bucket_count - number of buckets in the histogram.
    * @param type - HISTOGRAM_EXPONENTIAL or HISTOGRAM_LINEAR
    * The returned object has the following functions:
    *   add(int) - Adds an int value to the appropriate bucket
    *   snapshot() - Returns a snapshot of the histogram with the same data fields as in histogramSnapshots()
    */
   [implicit_jscontext]
   jsval newHistogram(in ACString name, in PRUint32 min, in PRUint32 max, in PRUint32 bucket_count, in unsigned long histogram_type);
 
   /**
-   * Create a histogram using the current state of an existing histogram.  The
-   * existing histogram must be registered in TelemetryHistograms.h.
-   *
-   * @param name Unique histogram name
-   * @param existing_name Existing histogram name
-   * The returned object has the same functions as a histogram returned from newHistogram.
-   */
-  [implicit_jscontext]
-  jsval histogramFrom(in ACString name, in ACString existing_name);
-
-  /**
    * Same as newHistogram above, but for histograms registered in TelemetryHistograms.h.
    *
    * @param id - unique identifier from TelemetryHistograms.h
    */
   [implicit_jscontext]
   jsval getHistogramById(in ACString id);
 
   /**
--- a/toolkit/components/telemetry/tests/unit/test_TelemetryPing.js
+++ b/toolkit/components/telemetry/tests/unit/test_TelemetryPing.js
@@ -10,53 +10,46 @@
 
 do_load_httpd_js();
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/LightweightThemeManager.jsm");
 
 const PATH = "/submit/telemetry/test-ping";
 const SERVER = "http://localhost:4444";
 const IGNORE_HISTOGRAM = "test::ignore_me";
-const HISTOGRAM_FOR_STARTUP = "PAGE_FAULTS_HARD"
-const CLONED_STARTUP_HISTOGRAM = "STARTUP_PAGE_FAULTS_HARD"
-const IGNORE_HISTOGRAM_TO_CLONE = "MEMORY_HEAP_ALLOCATED"
-const IGNORE_CLONED_HISTOGRAM = "test::ignore_me_also"
 
 const BinaryInputStream = Components.Constructor(
   "@mozilla.org/binaryinputstream;1",
   "nsIBinaryInputStream",
   "setInputStream");
-const Telemetry = Cc["@mozilla.org/base/telemetry;1"].getService(Ci.nsITelemetry);
 
 var httpserver = new nsHttpServer();
 var gFinished = false;
 
 function telemetry_ping () {
   const TelemetryPing = Cc["@mozilla.org/base/telemetry-ping;1"].getService(Ci.nsIObserver);
   TelemetryPing.observe(null, "test-ping", SERVER);
-  TelemetryPing.observe(null, "sessionstore-windows-restored", null);
 }
 
 function nonexistentServerObserver(aSubject, aTopic, aData) {
   Services.obs.removeObserver(nonexistentServerObserver, aTopic);
 
   httpserver.start(4444);
 
   // Provide a dummy function so it returns 200 instead of 404 to telemetry.
   httpserver.registerPathHandler(PATH, function () {});
   Services.obs.addObserver(telemetryObserver, "telemetry-test-xhr-complete", false);
   telemetry_ping();
 }
 
 function telemetryObserver(aSubject, aTopic, aData) {
   Services.obs.removeObserver(telemetryObserver, aTopic);
   httpserver.registerPathHandler(PATH, checkHistograms);
+  const Telemetry = Cc["@mozilla.org/base/telemetry;1"].getService(Ci.nsITelemetry);
   Telemetry.newHistogram(IGNORE_HISTOGRAM, 1, 2, 3, Telemetry.HISTOGRAM_BOOLEAN);
-  Telemetry.histogramFrom(CLONED_STARTUP_HISTOGRAM, HISTOGRAM_FOR_STARTUP);
-  Telemetry.histogramFrom(IGNORE_CLONED_HISTOGRAM, IGNORE_HISTOGRAM_TO_CLONE);
   Services.startup.interrupted = true;
   telemetry_ping();
 }
 
 function checkHistograms(request, response) {
   // do not need the http server anymore
   httpserver.stop(do_test_finished);
   let s = request.bodyInputStream;
@@ -79,25 +72,17 @@ function checkHistograms(request, respon
 
   for (let f in expected_info) {
     do_check_eq(payload.info[f], expected_info[f]);
   }
 
   const TELEMETRY_PING = "TELEMETRY_PING";
   const TELEMETRY_SUCCESS = "TELEMETRY_SUCCESS";
   do_check_true(TELEMETRY_PING in payload.histograms);
-  do_check_true(CLONED_STARTUP_HISTOGRAM in payload.histograms);
-  let rh = Telemetry.registeredHistograms;
-  for (let name in rh) {
-    if (/SQLITE/.test(name) && name in payload.histograms) {
-      do_check_true(("STARTUP_" + name) in payload.histograms); 
-    }
-  }
   do_check_false(IGNORE_HISTOGRAM in payload.histograms);
-  do_check_false(IGNORE_CLONED_HISTOGRAM in payload.histograms);
 
   // There should be one successful report from the previous telemetry ping.
   const expected_tc = {
     range: [1, 2],
     bucket_count: 3,
     histogram_type: 2,
     values: {0:1, 1:1, 2:0},
     sum: 1
--- a/toolkit/components/telemetry/tests/unit/test_nsITelemetry.js
+++ b/toolkit/components/telemetry/tests/unit/test_nsITelemetry.js
@@ -28,16 +28,18 @@ function test_histogram(histogram_type, 
   }
   var hgrams = Telemetry.histogramSnapshots
   gh = hgrams[name]
   do_check_eq(gh.histogram_type, histogram_type);
 
   do_check_eq(gh.min, min)
   do_check_eq(gh.max, max)
 
+  do_check_false(gh.static); 
+
   // Check that booleans work with nonboolean histograms
   h.add(false);
   h.add(true);
   var s = h.snapshot().counts;
   do_check_eq(s[0], 2)
   do_check_eq(s[1], 2)
 }
 
@@ -81,16 +83,17 @@ function test_getHistogramById() {
   } catch (e) {
     
   }
   var h = Telemetry.getHistogramById("CYCLE_COLLECTOR");
   var s = h.snapshot();
   do_check_eq(s.histogram_type, Telemetry.HISTOGRAM_EXPONENTIAL);
   do_check_eq(s.min, 1);
   do_check_eq(s.max, 10000);
+  do_check_true(s.static);
 }
 
 // Check that telemetry doesn't record in private mode
 function test_privateMode() {
   var h = Telemetry.newHistogram("test::private_mode_boolean", 1,2,3, Telemetry.HISTOGRAM_BOOLEAN);
   var orig = h.snapshot();
   Telemetry.canRecord = false;
   h.add(1);