Bug 1397376 - Deduplicate histogram static bucket data r=gfritzsche
authorDoug Thayer <dothayer@mozilla.com>
Thu, 07 Sep 2017 10:22:53 -0700
changeset 429653 34d4d0192028f839ca2386bb4ec54ea10e2478f0
parent 429652 1a56faf6adf5699f52f6a2a8293e10afe75dde78
child 429654 ba149daae44e54bbe19f0c78845654e94bc47cad
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgfritzsche
bugs1397376
milestone57.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 1397376 - Deduplicate histogram static bucket data r=gfritzsche Since we already have the indices array, we can just point duplicate ranges at the first occurrence's index. MozReview-Commit-ID: 3f5os1xSp89
toolkit/components/telemetry/gen-histogram-data.py
--- a/toolkit/components/telemetry/gen-histogram-data.py
+++ b/toolkit/components/telemetry/gen-histogram-data.py
@@ -154,32 +154,37 @@ def write_histogram_static_asserts(outpu
 
 def write_exponential_histogram_ranges(output, histograms):
     # For now we use this as a special cache only for exponential histograms,
     # which require exp and log calls that show up in profiles. Initialization
     # of other histograms also shows up in profiles, but it's unlikely that we
     # would see much speedup since calculating their buckets is fairly trivial,
     # and grabbing them from static data would likely incur a CPU cache miss.
     print("const int gExponentialBucketLowerBounds[] = {", file=output)
+
+    offset = 0
+    ranges_offsets = {}
     for histogram in histograms:
         if histogram.kind() == 'exponential':
-            ranges = histogram.ranges()
-            print(','.join(map(str, ranges)), ',', file=output)
+            ranges = tuple(histogram.ranges())
+            if ranges not in ranges_offsets:
+                ranges_offsets[ranges] = offset
+                offset += histogram.n_buckets()
+                print(','.join(map(str, ranges)), ',', file=output)
     print("};", file=output)
 
     print("const int gExponentialBucketLowerBoundIndex[] = {", file=output)
-    offset = 0
     for histogram in histograms:
         cpp_guard = histogram.cpp_guard()
         if cpp_guard:
             print("#if defined(%s)" % cpp_guard, file=output)
 
         if histogram.kind() == 'exponential':
-            print("%d," % offset, file=output)
-            offset += histogram.n_buckets()
+            our_offset = ranges_offsets[tuple(histogram.ranges())]
+            print("%d," % our_offset, file=output)
         else:
             print("-1,", file=output)
 
         if cpp_guard:
             print("#endif", file=output)
     print("};", file=output)