Commit Graph

108 Commits

Author SHA1 Message Date
Tom Schuster
6698b9aad3 Bug 1255800 - Remove JS_THIS_OBJECT from dom/xpconnect. r=bz 2018-03-07 14:35:22 +01:00
Aditya Bharti
4c45e24322 Bug 1442667 - Refactor internal_JSKeyedHistogram_Add r=chutten
Use the type checking utility function introduced in bug 1428893
Added more tests to increase code coveragea and ensure no regressions
2018-03-24 10:29:29 +05:30
Nathan Froyd
8b87608a7f Bug 1443587 - part 5 - more efficient string serialization; r=chutten
The code for serializing an EventKey in SerializeEventsArray does
something peculiar: it creates a temporary array of nsCStrings, copies
the appropriate strings from the event info for the key, and then
converts those into JavaScript strings.  But we shouldn't need to do any
copying into the temporary array.  We can do everything directly on the
strings from the event info themselves.

It seemed best to introduce a ToJSString for this purpose, which comes
in handy in a couple other places as well.
2018-03-07 11:00:44 -05:00
Chris H-C
c719b84365 bug 1440832 - Only log on debug builds when clamping. r=gfritzsche
MozReview-Commit-ID: E7Am8rwmaut
2018-03-02 14:53:41 -05:00
Aditya Bharti
c1c7c6ee3d Bug 1428893 - Allow JSHistogram APIs to accumulate multiple values in one call. r=chutten
This patch adds support for value arrays to the internal_JSHistogram_Add method.

The histogram.add() js method can now be called with a single value or an array of values.
The accumulation is "all-or-nothing", i.e. if there is even a single invalid value in the
array, then nothing is accumulated.

The logic for type checking arguments before accumulation has been moved into a separate
function: internal_JSHistogram_CoerceValue. This function can also be used for
internal_JSKeyedHistogram_* methods in the future. This patch includes logic for clamping
values greater than UINT32_MAX to UINT32_MAX.

Added xpcshell tests in telemetry/tests/unit/test_TelemetryHistograms.js to check functionality.
2018-02-24 02:11:41 +05:30
Chris H-C
2d3474f12f bug 1438335 - Record when we have to clamp large Telemetry accumulations. r=Dexter,francois
We need to clamp accumulations to fit in our data representation (int). This
patch records the number of times, and for which probes, we had to do so.

MozReview-Commit-ID: GSs3oFvLKlL
2018-02-15 16:13:36 -05:00
Chris H-C
39cedb8089 bug 1438335 - Clamp the samples accumulated to histograms. r=Dexter
Internally Histograms use int, which is signed.

Our API uses uint32_t, which is not.

Our JS API uses ToUint32, which takes provided values modulo UINT32_MAX.

This patch consolidates behaviour so that all values greater than INT_MAX will
be correctly recorded in the highest bucket of a Histogram... instead of
having values between INT_MAX and UINT32_MAX end up as 0s, and values above
UINT32_MAX being taken modulo UINT32_MAX, but only from the JS API.

MozReview-Commit-ID: CzaaNZkPEji
2018-02-15 13:32:13 -05:00
Andrew McCreight
c509a522ed Bug 1437689 - Add basic memory reporting for gNameToHistogramIDMap. r=gfritzsche
MozReview-Commit-ID: 8QGudRuXmWh
2018-02-12 14:24:03 -08:00
Aditya Bharti
4b0c63ce5b Bug 1428888 - Allow C++ to accumulate multiple samples into a categorical histogram in one call r=chutten
Telemetry::Accumulate now supports two new signatures: Accumulate(HistogramId, nsTArray stringLabels) and
Accumulate(nsTArray enumValues). In the stringLabels case, if the array contains an invalid label, then no
samples are accumulated at all. In the enumValues array case, the class template ensures that we do not have
a mismatch of labels in the array, since the enumValues class is tied to the id of the histogram we want to
accumulate to.
2018-01-28 16:53:40 +05:30
Chris H-C
695225d7e0 bug 1432855 - Early-return if we're asked to clear the expired histogram. r=gfritzsche
MozReview-Commit-ID: IH4BCDq8fgz
2018-01-25 14:05:05 -05:00
Eric Rahm
4a23f36203 Bug 1428612 - Part 2: Add an assertion to check the histogram name pointer. r=gfritzsche
This adds a dignostic assertion that the name pointer is actually within the
static name table.
2018-01-17 16:52:37 -08:00
Eric Rahm
741514933e Bug 1428612 - Part 1: Use nsLiteralCString to wrap histogram names. r=gfritzsche
This switches from `nsDependentCString` to `nsLiteralCString` when adding
histograms to the table. It will help save some memory and should avoid the OOM
smalls we have been seeing.
2018-01-17 16:38:18 -08:00
fernando
0d775bcfde Bug 1278821 - Re-factor JS-exposed functions in TelemetryHistogram.cpp to avoid deadlocks. r=Dexter 2018-01-11 22:01:15 +00:00
Aditya Bharti
bfc368ad56 bug 1428885 - Allow C++ to accumulate multiple samples into a keyed histogram in one call r=chutten
Extended the Telemetry::Accumulate API to take a Histogram ID, string key, and a nsTArray<uint32_t> of samples.
Test cases check for linear, count and histograms with a set of allowed keys. Made changes to fix try failures.
2018-01-12 03:26:04 +05:30
Aditya Bharti
4cfa0ad19f bug 1364043 - Allow C++ to accumulate multiple samples into histograms with one call. r=chutten
Added another Telemetry::Accumulate function that takes a histogram id and an array of samples as arguments.
As of this patch, adding multiple samples to keyed and categorical histograms is not supported.
2018-01-09 02:16:30 +05:30
FSeita
bc9e6fa603 Bug 1376333 - Improve naming of accumulation types & variables r=Dexter
MozReview-Commit-ID: F9w7CLUOP6r
2017-09-13 11:20:36 +02:00
Doug Thayer
297ca9d1d7 Bug 1397376 - Avoid copying on initializing histogram ranges r=gfritzsche
Since LinearHistogram and its descendants inherit ranges_ from
Histogram, and we wanted to replace the copying into a std::vec
for Histogram, the simplest approach seemed to just be to
precompute ranges for all histograms, exponential or otherwise.
This should have the added benefit of reducing the memory
footprint for those histograms, since they will benefit from the
deduplication work that the precomputing script already does.

MozReview-Commit-ID: JTV5Dej5ZIb
2017-09-08 12:13:44 -07:00
Chris H-C
97ba53dc5e bug 1373240 - Use somewhat-more-dynamically-allocated histogram storage r=Dexter,gfritzsche
Switch from static multi-dimensional arrays to dynamic one-dimensional arrays
that are only allocated in the parent process.

MozReview-Commit-ID: tyGEFhU2Fq
2017-08-29 15:05:35 -04:00
Sebastian Hengst
656ad5ff03 Backed out changeset 0181bf16af4f (bug 1373240) for leaks detected by asan. r=backout 2017-09-08 16:47:04 +02:00
Chris H-C
3dddcf48de bug 1373240 - Use somewhat-more-dynamically-allocated histogram storage r=Dexter,gfritzsche
Switch from static multi-dimensional arrays to dynamic one-dimensional arrays
that are only allocated in the parent process.

MozReview-Commit-ID: tyGEFhU2Fq
2017-08-29 15:05:35 -04:00
Chris H-C
eabcba7afb bug 1376600 - Remove registered(Keyed)Histograms r=Dexter
With the removal of the old addonHistograms, all histograms are now registered.
So removing registered(Keyed)Histograms should be straightforward?

Unfortunately not, as this was how we filtered data based on dataset
(opt-in/opt-out), so a little more fiddling was needed to get C++ to only
serialize dataset-appropriate data (instead of post-facto filtering it in JS).

MozReview-Commit-ID: HDplhmzmzJl
2017-08-22 09:42:09 -04:00
Jan de Mooij
f9f0443c9f Bug 1389510 part 3 - Remove getProperty/setProperty hooks from ClassOps. r=evilpie 2017-08-25 10:12:16 +02:00
Alessio Placitelli
5329b408e3 Bug 1343855 - Part 2 - Add support for key whitelists in keyed histograms. r=gfritzsche, data-review=francois
MozReview-Commit-ID: H2pE3VivWIX
2017-05-17 04:10:00 +02:00
Doug Thayer
b419dc7f86 Bug 1383210 - Use precomputed histogram buckets r=gfritzsche
The log and exp calls in base::Histogram::InitializeBucketRange()
were showing up in profiles. This patch uses the precomputed
buckets for exponential histograms instead of computing them at
runtime. Though linear histograms do show up in the profile that
prompted this change, they contribute much less, and due to the
trivial nature of generating these, it's unlikely that a static
cache would provide much if any speedup.

MozReview-Commit-ID: IavFwoWjFhk
2017-08-04 10:02:28 -07:00
Wes Kocher
5f9ee65672 Backed out changeset 277c7e4952a8 (bug 1383210) for flake8 failures a=backout
MozReview-Commit-ID: 3j1ROBxjf2Z
2017-08-08 12:38:41 -07:00
Doug Thayer
da71c2e874 Bug 1383210 - Use precomputed histogram buckets r=gfritzsche
The log and exp calls in base::Histogram::InitializeBucketRange()
were showing up in profiles. This patch uses the precomputed
buckets for exponential histograms instead of computing them at
runtime. Though linear histograms do show up in the profile that
prompted this change, they contribute much less, and due to the
trivial nature of generating these, it's unlikely that a static
cache would provide much if any speedup.

MozReview-Commit-ID: IavFwoWjFhk
2017-08-04 10:02:28 -07:00
Dean
deb71c0ef5 Bug 1381470 - Added a less memory consuming method to tell if a histogram is empty. r=chutten 2017-07-31 21:38:48 +02:00
Chris H-C
bb4cb30677 bug 1366294 - Part 12 - Clean up after onesself. r=gfritzsche
Without the StatisticsRecorder cleaning up after us we need to now manually
delete the Histograms we create.

MozReview-Commit-ID: 8jrPPBQmU0Z
2017-07-24 09:52:26 -04:00
Chris H-C
f0f263244d bug 1366294 - Part 10 - Nail down count histogram semantics. r=gfritzsche
Previously we assumed count histograms were always present in payloads.
This was an erroneous assumption as count histograms were only 0 if they were
session histograms, or if they were from subsession histograms from subsessions
_after_ a subsession when they held a non-0 value.

So let's just treat count histograms as normal histograms from now on, without
any of this "sometimes 0" nonsense. This simplifies the code, tests, and our
understanding... and _should_ have few/zero downstream effects since the
existing behaviour was so poorly-understood (though exactly tested).

MozReview-Commit-ID: BH108ksygGw
2017-07-24 09:52:26 -04:00
Chris H-C
43ee3b33fc bug 1366294 - Part 7 - Use keyed histogram snaphots to build payloads. r=gfritzsche
TelemetrySession's getKeyedHistograms asks for each keyed histogram
individually. This is inefficient and doesn't work well with the storage
refactor.

So, plumb through a subsession keyed histogram snapshot API and convert
TelemetrySession over to using it.

MozReview-Commit-ID: Af9dTqw99UA
2017-07-24 09:52:26 -04:00
Chris H-C
1c9b6f562a bug 1366294 - Part 5 - Send appropriately-structured Telemetry data to JS r=gfritzsche
Previously we were doing bad string manipulation nonsense. Now when asked for
snapshots C++ can return a properly-formated Object tree.

MozReview-Commit-ID: HAvIbgzUvMU
2017-07-24 09:52:26 -04:00
Chris H-C
52df6d3dce bug 1366294 - Part 4 - Small cleanups to previous patches. r=gfritzsche
MozReview-Commit-ID: 7PioVNfUUNZ
2017-07-24 09:52:26 -04:00
Georg Fritzsche
ea803304a2 Bug 1366294 - Part 3 - Refactor TelemetryHistogram storage. r=chutten
Previously we used the base::StatisticsRecorder object for storage by name.
This is keyed by histogram name, which doesn't match our storage reality anymore.
Instead we use a name to refer to a set of histogram instances that record data from different processes, as well as separating session and subsession data.

In this re-write, we instead introduce the following lookup paths (managed in TelemetryHistogram.cpp):
- Main storage:
  - (histogramId, processId, sessionOrSubsession) -> Histogram*
  - (histogramId, processId) -> KeyedHistogram* (this handles subsessions internally)
- Lookup:
  - (histogramName) -> histogramId
  - (HistogramID) -> bool (is recording enabled for this histogram?)

This is wrapped with a few lookup functions.

This also allows us to keep HistogramIDs in the JS histogram instances now, instead of pointers to Histogram instances.
That means Histogram instance life-time management is now properly contained inside TelemetryHistogram.cpp.

MozReview-Commit-ID: 5yijGv7mc89
2017-07-24 09:52:26 -04:00
Georg Fritzsche
bccaccd801 Bug 1366294 - Part 1 - Remove base::StatisticsRecorder. r=chutten
The Chromium IPC histogram code used the StatisticsRecorder object for storage.
This is keyed by histogram name, which doesn't match our storage reality anymore.
Instead we use a name to refer to a set of histogram instances that record data from different processes, as well as separating session and subsession data.
Consequently we need to rewrite this storage, which means StatisticsRecorder is not used anymore.

MozReview-Commit-ID: 1LC7YubpKaD
2017-07-24 09:52:26 -04:00
Bill McCloskey
69b44c007d Bug 1380880 - Use process type to distinguish keyed histograms (r=chutten)
MozReview-Commit-ID: 8pcou7DsU7S
2017-07-14 12:44:54 -07:00
Igor Timofeev
2c1ec45b58 Bug 1374628 - Improve static_asserts in TelemetryHistogram.cpp. r=gfritzsche
With bug 1374419 solved, static asserts in TelemetryHistogram.cpp can be improved.

Specifically, JS::gcreason::NUM_TELEMETRY_REASONS can now be compared against GC_MINOR_REASON, GC_MINOR_REASON_LONG, and GC_REASON_2 in the now constexpr gHistograms. Likewise, mozilla::StartupTimeline::MAX_EVENT_ID can be compared against STARTUP_MEASUREMENT_ERRORS.

This commit modifies the static asserts to perform these comparisons in place of ones against hardcoded values and modifies the accompanying comment to remove the TODO section.
2017-06-21 14:02:36 +01:00
Chris H-C
89b1d30556 Bug 1335343 - Prevent histogram recording in disallowed processes. r=Dexter
Unfortunately it means using FLAG histograms because I need to test that their
"we have a hidden default value" behaviour is appropriately silenced as well.

MozReview-Commit-ID: J8xGXwCTRIg
2017-06-13 07:10:00 -04:00
Georg Fritzsche
940a7067c5 Bug 1361661 - Part 3 - Update the Telemetry core. r=dexter
Updates the core Telemetry code to use the new headers and support the extension process.
TelemetryHistogram is not cleanly refactored here; doing this uncovered a few time consuming issues with the various lookup code paths.
2017-05-23 13:48:13 +07:00
Sebastian Hengst
2d99162f7f Backed out changeset 42a4e28e6210 (bug 1361661) 2017-05-22 20:40:17 +02:00
Georg Fritzsche
ab50d638c5 Bug 1361661 - Part 3: Update the Telemetry core. r=dexter
Updates the core Telemetry code to use the new headers and support the extension process.
TelemetryHistogram is not cleanly refactored here; doing this uncovered a few time consuming issues with the various lookup code paths.
2017-05-22 15:41:14 +07:00
Sebastian Hengst
de9a911353 Backed out changeset d1932fb366d4 (bug 1361661) 2017-05-22 16:19:21 +02:00
Georg Fritzsche
0f76edd4d9 Bug 1361661 - Part 3: Update the Telemetry core. r=dexter
Updates the core Telemetry code to use the new headers and support the extension process.
TelemetryHistogram is not cleanly refactored here; doing this uncovered a few time consuming issues with the various lookup code paths.
2017-05-22 15:41:14 +07:00
Ehsan Akhgari
88afb100de Backout bug 1350765 for having caused bug 1358259 2017-04-25 11:20:04 -04:00
Ehsan Akhgari
9d584db59a Bug 1350765 - Avoid recomputing the histogram ID when it's available in the caller; r=chutten 2017-04-19 12:02:30 -04:00
Chris H-C
a2a550854b bug 1353295 - Remove addonHistograms from Telemetry r=Dexter
addonHistograms isn't being used and has started getting in the way.
So it goes.

Leave the "Addon Histograms" section in about:telemetry for 60 days.
Remove it in bug 1355882

MozReview-Commit-ID: 4lm7ONirofl
2017-04-06 15:31:58 -04:00
Markus Stange
600220e2a0 Bug 1356898 - Use nsAutoCString in two places in TelemetryHistogram.cpp. r=froydnj
MozReview-Commit-ID: 3njPBvdhwRj
2017-04-16 14:18:00 -04:00
Carsten "Tomcat" Book
6d5a053fe2 Backed out changeset cfe47bace342 (bug 1353295) for assertion failures 2017-04-13 09:39:17 +02:00
Chris H-C
79504a7b9d bug 1353295 - Remove addonHistograms from Telemetry r=Dexter
addonHistograms isn't being used and has started getting in the way.
So it goes.

Leave the "Addon Histograms" section in about:telemetry for 60 days.
Remove it in bug 1355882

MozReview-Commit-ID: 4lm7ONirofl
2017-04-06 15:31:58 -04:00
Georg Fritzsche
7d536d302f Bug 1347216 - Fix categorical keyed histograms. r=Dexter
This also fixes an existing bug where we checked for the wrong type in JSKeyedHistogram_Add().
KeyedHistogram::GetHistogramType() returns one of the histogram types from nsITelemetry.idl, not one of the chromium types (base::*).

I extended the test coverage accordingly, as it seemed to be lacking.
2017-04-07 20:55:51 +07:00
Gregory Moore
58aad3a66b Bug 1120409 - nsITelemetry.histogramSnapshots will no longer return keyed histograms. r=chutten 2017-03-24 12:38:24 -07:00