Bug 837271 - part 2 - add extended_statistics_ok mechanism to histogram machinery; r=vladan
authorNathan Froyd <froydnj@mozilla.com>
Wed, 13 Feb 2013 10:51:24 -0500
changeset 122051 f22ec99b6a766bc838c46a0a8ad5b2e3ef284b5d
parent 122050 6553a0cac0af08d4f420d77ad2b27d8393e1a261
child 122052 7d7f52a27a47c030a37aefd79cb5a6827183507c
push id24317
push userryanvm@gmail.com
push dateSat, 16 Feb 2013 14:49:39 +0000
treeherdermozilla-central@484dbca61133 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvladan
bugs837271
milestone21.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 837271 - part 2 - add extended_statistics_ok mechanism to histogram machinery; r=vladan
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
@@ -397,16 +397,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];
 
@@ -505,16 +506,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++) {
@@ -977,16 +981,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: