Bug 837271 - part 2 - add extended_statistics_ok mechanism to histogram machinery; r=vladan; a=lsblakk
authorNathan Froyd <froydnj@mozilla.com>
Wed, 13 Feb 2013 10:51:24 -0500
changeset 127530 31334d30379f05902e97229486f9f465ae61fd67
parent 127529 80d1bc256c835dd0ca8fe0c8f86d543a7ccd7c1d
child 127531 a5c8f85afbd594df2bba228aec4dc9761675f370
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvladan, lsblakk
bugs837271
milestone20.0a2
Bug 837271 - part 2 - add extended_statistics_ok mechanism to histogram machinery; r=vladan; a=lsblakk
toolkit/components/telemetry/Telemetry.cpp
toolkit/components/telemetry/gen-histogram-data.py
toolkit/components/telemetry/histogram_tools.py
--- a/toolkit/components/telemetry/Telemetry.cpp
+++ b/toolkit/components/telemetry/Telemetry.cpp
@@ -382,16 +382,17 @@ StatisticsRecorder gStatisticsRecorder;
 // Hardcoded probes
 struct TelemetryHistogram {
   uint32_t min;
   uint32_t max;
   uint32_t bucketCount;
   uint32_t histogramType;
   uint16_t id_offset;
   uint16_t comment_offset;
+  bool extendedStatisticsOK;
 
   const char *id() const;
   const char *comment() const;
 };
 
 #include "TelemetryHistogramData.inc"
 bool gCorruptHistograms[Telemetry::HistogramCount];
 
@@ -490,16 +491,19 @@ GetHistogramByEnumId(Telemetry::ID id, H
                "C++/Python bucket # mismatch");
     for (int i = 0; i < b.length; ++i) {
       MOZ_ASSERT(gBucketLowerBounds[b.offset + i] == h->ranges(i),
                  "C++/Python bucket mismatch");
     }
   }
 #endif
 
+  if (p.extendedStatisticsOK) {
+    h->SetFlags(Histogram::kExtendedStatisticsFlag);
+  }
   *ret = knownHistograms[id] = h;
   return NS_OK;
 }
 
 bool
 FillRanges(JSContext *cx, JSObject *array, Histogram *h)
 {
   for (size_t i = 0; i < h->bucket_count(); i++) {
@@ -875,16 +879,17 @@ TelemetryImpl::~TelemetryImpl() {
 NS_IMETHODIMP
 TelemetryImpl::NewHistogram(const nsACString &name, uint32_t min, uint32_t max, uint32_t bucketCount, uint32_t histogramType, JSContext *cx, jsval *ret)
 {
   Histogram *h;
   nsresult rv = HistogramGet(PromiseFlatCString(name).get(), min, max, bucketCount, histogramType, &h);
   if (NS_FAILED(rv))
     return rv;
   h->ClearFlags(Histogram::kUmaTargetedHistogramFlag);
+  h->SetFlags(Histogram::kExtendedStatisticsFlag);
   return WrapAndReturnHistogram(h, cx, ret);
 }
 
 bool
 TelemetryImpl::ReflectSQL(const SlowSQLEntryType *entry,
                           const Stat *stat,
                           JSContext *cx,
                           JSObject *obj)
--- a/toolkit/components/telemetry/gen-histogram-data.py
+++ b/toolkit/components/telemetry/gen-histogram-data.py
@@ -51,20 +51,21 @@ class StringTable:
                     % (offset, explodeToCharArray(string)))
         f.write("  /* %5d */ %s, '\\0' };\n\n"
                 % (entries[-1][1], explodeToCharArray(entries[-1][0])))
 
 def print_array_entry(histogram, name_index, desc_index):
     cpp_guard = histogram.cpp_guard()
     if cpp_guard:
         print "#if defined(%s)" % cpp_guard
-    print "  { %s, %s, %s, %s, %d, %d }," \
+    print "  { %s, %s, %s, %s, %d, %d, %s }," \
         % (histogram.low(), histogram.high(),
            histogram.n_buckets(), histogram.nsITelemetry_kind(),
-           name_index, desc_index)
+           name_index, desc_index,
+           "true" if histogram.extended_statistics_ok() else "false")
     if cpp_guard:
         print "#endif"
 
 def write_histogram_table(histograms):
     table = StringTable()
 
     print "const TelemetryHistogram gHistograms[] = {"
     for histogram in histograms:
--- a/toolkit/components/telemetry/histogram_tools.py
+++ b/toolkit/components/telemetry/histogram_tools.py
@@ -75,16 +75,17 @@ definition is a dict-like object that mu
 
 The key 'cpp_guard' is optional; if present, it denotes a preprocessor
 symbol that should guard C/C++ definitions associated with the histogram."""
         self.verify_attributes(name, definition)
         self._name = name
         self._description = definition['description']
         self._kind = definition['kind']
         self._cpp_guard = definition.get('cpp_guard')
+        self._extended_statistics_ok = definition.get('extended_statistics_ok', False)
         self.compute_bucket_parameters(definition)
         table = { 'boolean': 'BOOLEAN',
                   'flag': 'FLAG',
                   'enumerated': 'LINEAR',
                   'linear': 'LINEAR',
                   'exponential': 'EXPONENTIAL' }
         table_dispatch(self.kind(), table,
                        lambda k: self._set_nsITelemetry_kind(k))
@@ -122,16 +123,21 @@ the histogram."""
         """Return the number of buckets in the histogram.  May be a string."""
         return self._n_buckets
 
     def cpp_guard(self):
         """Return the preprocessor symbol that should guard C/C++ definitions
 associated with the histogram.  Returns None if no guarding is necessary."""
         return self._cpp_guard
 
+    def extended_statistics_ok(self):
+        """Return True if gathering extended statistics for this histogram
+is enabled."""
+        return self._extended_statistics_ok
+
     def ranges(self):
         """Return an array of lower bounds for each bucket in the histogram."""
         table = { 'boolean': linear_buckets,
                   'flag': linear_buckets,
                   'enumerated': linear_buckets,
                   'linear': linear_buckets,
                   'exponential': exponential_buckets }
         return table_dispatch(self.kind(), table,
@@ -152,17 +158,17 @@ associated with the histogram.  Returns 
         global always_allowed_keys
         general_keys = always_allowed_keys + ['low', 'high', 'n_buckets']
 
         table = {
             'boolean': always_allowed_keys,
             'flag': always_allowed_keys,
             'enumerated': always_allowed_keys + ['n_values'],
             'linear': general_keys,
-            'exponential': general_keys
+            'exponential': general_keys + ['extended_statistics_ok']
             }
         table_dispatch(definition['kind'], table,
                        lambda allowed_keys: Histogram.check_keys(name, definition, allowed_keys))
 
     @staticmethod
     def check_keys(name, definition, allowed_keys):
         for key in definition.iterkeys():
             if key not in allowed_keys: