зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1780621 test size limits of updated Memory Distribution Accumulate r=Dexter
Also adds a small guardrail consistent with the implementation in Timing Distribution Differential Revision: https://phabricator.services.mozilla.com/D153384
This commit is contained in:
Родитель
a93fa7b019
Коммит
709403b68a
|
@ -72,7 +72,12 @@ impl MemoryDistribution for MemoryDistributionMetric {
|
|||
// If the value doesn't fit into `i64` it's definitely to large
|
||||
// and cause an error.
|
||||
// glean-core handles that.
|
||||
let sample = sample.try_into().unwrap_or(i64::MAX);
|
||||
let sample = sample.try_into().unwrap_or_else(|_| {
|
||||
log::warn!(
|
||||
"Memory size too large to fit into into 64-bytes. Saturating at i64::MAX."
|
||||
);
|
||||
i64::MAX
|
||||
});
|
||||
inner.accumulate(sample);
|
||||
}
|
||||
MemoryDistributionMetric::Child(c) => {
|
||||
|
|
|
@ -92,6 +92,32 @@ add_task(function test_gifft_memory_dist() {
|
|||
Telemetry.getHistogramById("TELEMETRY_TEST_LINEAR").clear();
|
||||
Assert.equal(24, data.sum, "Histogram's in `memory_unit` units");
|
||||
Assert.equal(2, data.values["1"], "Both samples in a low bucket");
|
||||
|
||||
// MemoryDistribution's Accumulate method to takes
|
||||
// a platform specific type (size_t).
|
||||
// Glean's, however, is i64, and, glean_memory_dist is uint64_t
|
||||
// What happens when we give accumulate dubious values?
|
||||
// This may occur on some uncommon platforms.
|
||||
// Note: there are issues in JS with numbers above 2**53
|
||||
Glean.testOnlyIpc.aMemoryDist.accumulate(36893488147419103232);
|
||||
let dubiousValue = Object.entries(
|
||||
Glean.testOnlyIpc.aMemoryDist.testGetValue().values
|
||||
)[0][1];
|
||||
Assert.equal(
|
||||
dubiousValue,
|
||||
1,
|
||||
"Greater than 64-Byte number did not accumulate correctly"
|
||||
);
|
||||
|
||||
// Values lower than the out-of-range value are not clamped
|
||||
// resulting in an exception being thrown from the glean side
|
||||
// when the value exceeds the glean maximum allowed value
|
||||
Glean.testOnlyIpc.aMemoryDist.accumulate(Math.pow(2, 31));
|
||||
Assert.throws(
|
||||
() => Glean.testOnlyIpc.aMemoryDist.testGetValue(),
|
||||
/NS_ERROR_LOSS_OF_SIGNIFICANT_DATA/,
|
||||
"Did not accumulate correctly"
|
||||
);
|
||||
});
|
||||
|
||||
add_task(function test_gifft_custom_dist() {
|
||||
|
|
Загрузка…
Ссылка в новой задаче