Closed Bug 1145164 Opened 9 years ago Closed 8 years ago

Allow adding values >1 to "count" histograms

Categories

(Toolkit :: Telemetry, defect, P1)

defect

Tracking

()

RESOLVED FIXED
mozilla49
Tracking Status
firefox49 --- fixed

People

(Reporter: rvitillo, Assigned: Dexter)

References

Details

(Whiteboard: [measurement:client])

Attachments

(1 file, 3 obsolete files)

Currently a count histogram can only be incremented by one with each add/accumulate call. Ingoring the passed value is confusing and makes it easy to use the interface in the wrong way (see https://bugzilla.mozilla.org/show_bug.cgi?id=1141915#c5). 

Either we remove the parameter or we use it to increment the count by its value. The latter option though would break the semantic of a histogram. Using a histogram to represent a count doesn't seem to me a good idea in the first place.
This really shouldn't be a histogram, it's just a counter. We're using the histogram mechanism because it's a good way to list and record measurements. But I do think we should increment by the passed value.
Depends on: 1261052
OS: Mac OS X → All
Priority: -- → P1
Hardware: x86 → All
Whiteboard: [measurement:client]
No longer depends on: 1261052
OS: All → Mac OS X
Priority: P1 → --
Hardware: All → x86
Whiteboard: [measurement:client]
Depends on: 1261052
OS: Mac OS X → All
Hardware: x86 → All
Whiteboard: [measurement:client]
Priority: -- → P1
Summary: Count histogram limitation → Allow adding values >1 to "count" histograms
Attached patch WIP patch (obsolete) — Splinter Review
Assignee: nobody → alessio.placitelli
Attached patch bug1145164.patch (obsolete) — Splinter Review
This patch allows non-unitary increments to count histograms, adds test coverage and (bonus) fixes some JS syntax errors in the test file.
Attachment #8750861 - Attachment is obsolete: true
Attachment #8753734 - Flags: review?(gfritzsche)
Status: NEW → ASSIGNED
Comment on attachment 8753734 [details] [diff] [review]
bug1145164.patch

Review of attachment 8753734 [details] [diff] [review]:
-----------------------------------------------------------------

Have you checked whether anyone already accumulates values > 1 for count histograms and might see regressions because of this patch?
A rough test run with an assertion on calls with values > 1 could be a simple sanity check.

::: ipc/chromium/src/base/histogram.cc
@@ +1075,5 @@
>  void
>  CountHistogram::Accumulate(Sample value, Count count, size_t index)
>  {
>    size_t zero_index = BucketIndex(0);
> +  LinearHistogram::Accumulate(value, 1, zero_index);

I think we should flip the order of those.
The sum increases correctly with this approach, but not the count of values in the zero bucket - see e.g. the visualization in about:telemetry when adding values > 1.

::: toolkit/components/telemetry/TelemetryHistogram.cpp
@@ +1003,4 @@
>    int32_t value = 1;
> +  bool shouldCheckArgs =
> +    (type != base::CountHistogram::COUNT_HISTOGRAM) ||
> +    ((type == base::CountHistogram::COUNT_HISTOGRAM) && args.length());

This looks redundant?
(!a || (a && b)) -> (!a || b)

@@ +1235,4 @@
>    int32_t value = 1;
> +  bool shouldCheckArgs =
> +    (type != base::CountHistogram::COUNT_HISTOGRAM) ||
> +    ((type == base::CountHistogram::COUNT_HISTOGRAM) && args.length() == 2);

Ditto on the condition.
Attachment #8753734 - Flags: review?(gfritzsche)
(In reply to Georg Fritzsche [:gfritzsche] from comment #4)
> Comment on attachment 8753734 [details] [diff] [review]
> bug1145164.patch
> 
> Review of attachment 8753734 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> Have you checked whether anyone already accumulates values > 1 for count
> histograms and might see regressions because of this patch?
> A rough test run with an assertion on calls with values > 1 could be a
> simple sanity check.

Try push for that: https://treeherder.mozilla.org/#/jobs?repo=try&revision=192f80158a23

The only real "issue" seems to be the test_TelemetryStopwatch.js [1] test, which is using a count histogram in the test. This shouldn't be a problem, as we're only crashing because of my MOZ_CRASH. The test runs just fine without it.

> ::: ipc/chromium/src/base/histogram.cc
> @@ +1075,5 @@
> >  void
> >  CountHistogram::Accumulate(Sample value, Count count, size_t index)
> >  {
> >    size_t zero_index = BucketIndex(0);
> > +  LinearHistogram::Accumulate(value, 1, zero_index);
> 
> I think we should flip the order of those.
> The sum increases correctly with this approach, but not the count of values
> in the zero bucket - see e.g. the visualization in about:telemetry when
> adding values > 1.

With the current patch, bucket zero contains the number of time |hist.add()| was called (e.g. the number of samples), even for values > 1. Unfortunately, swapping the parameters doesn't seem to set bucket zero to the same value as "sum". It will, instead, show the value of the last submitted sample.

[1] - https://dxr.mozilla.org/mozilla-central/rev/1806d405c8715949b39fa3a4fc142d14a60df590/toolkit/components/telemetry/tests/unit/test_TelemetryStopwatch.js#12
(In reply to Alessio Placitelli [:Dexter] from comment #5)
> (In reply to Georg Fritzsche [:gfritzsche] from comment #4)
> > Comment on attachment 8753734 [details] [diff] [review]
> > bug1145164.patch
> > 
> > Review of attachment 8753734 [details] [diff] [review]:
> > -----------------------------------------------------------------
> > 
> > Have you checked whether anyone already accumulates values > 1 for count
> > histograms and might see regressions because of this patch?
> > A rough test run with an assertion on calls with values > 1 could be a
> > simple sanity check.
> 
> Try push for that:
> https://treeherder.mozilla.org/#/jobs?repo=try&revision=192f80158a23

Also worth mentioning that I ran the patch through some manual browsing/search/navigation tests. Nothing blew up.
Attached patch bug1145164.patch (obsolete) — Splinter Review
This patch addresses the |shouldCheckArgs| conditions.
Attachment #8753734 - Attachment is obsolete: true
Attachment #8754807 - Flags: review?(gfritzsche)
Comment on attachment 8754807 [details] [diff] [review]
bug1145164.patch

Review of attachment 8754807 [details] [diff] [review]:
-----------------------------------------------------------------

::: toolkit/components/telemetry/TelemetryHistogram.cpp
@@ +1003,5 @@
>    int32_t value = 1;
> +  bool shouldCheckArgs =
> +    (type != base::CountHistogram::COUNT_HISTOGRAM) || args.length();
> +
> +  if (shouldCheckArgs) {

I don't think we need the extra shouldCheckArgs here now, i'd rather have it directly in the condition.

@@ +1237,2 @@
>  
> +  if (shouldCheckArgs) {

Ditto on moving this in the branching condition.
Attachment #8754807 - Flags: review?(gfritzsche) → review+
Attached patch bug1145164.patchSplinter Review
Attachment #8754807 - Attachment is obsolete: true
Attachment #8754826 - Flags: review+
Keywords: checkin-needed
Keywords: checkin-needed
https://hg.mozilla.org/integration/fx-team/rev/62a14696a5a71de6ddea031c128f46c8662662d2
Bug 1145164 - Allow non-unitary increments to count histograms. r=gfritzsche
https://hg.mozilla.org/mozilla-central/rev/62a14696a5a7
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla49
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: