зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1634234 - Only allow powers of 2 for buffer size in about:profiling - r=gregtatum
Display the buffer size as powers of 2, using binary-friendly units (e.g., 64MiB). Presets have been adjusted to powers of 2. Note that the profiler still uses this number as maximum per process, but this will change when bug 1632750 lands. Differential Revision: https://phabricator.services.mozilla.com/D73213
This commit is contained in:
Родитель
983fefb005
Коммит
d6e98da86d
|
@ -78,6 +78,7 @@ const DirectoryPicker = createFactory(
|
|||
);
|
||||
const {
|
||||
makeExponentialScale,
|
||||
makePowerOf2Scale,
|
||||
formatFileSize,
|
||||
featureDescriptions,
|
||||
} = require("devtools/client/performance-new/utils");
|
||||
|
@ -192,7 +193,10 @@ class Settings extends PureComponent {
|
|||
this._renderThreadsColumns = this._renderThreadsColumns.bind(this);
|
||||
|
||||
this._intervalExponentialScale = makeExponentialScale(0.01, 100);
|
||||
this._entriesExponentialScale = makeExponentialScale(100000, 100000000);
|
||||
this._entriesExponentialScale = makePowerOf2Scale(
|
||||
128 * 1024,
|
||||
128 * 1024 * 1024
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -85,7 +85,7 @@ const presets = {
|
|||
label: "Web Developer",
|
||||
description:
|
||||
"Recommended preset for most web app debugging, with low overhead.",
|
||||
entries: 10000000,
|
||||
entries: 16 * 1024 * 1024,
|
||||
interval: 1,
|
||||
features: ["screenshots", "js"],
|
||||
threads: ["GeckoMain", "Compositor", "Renderer", "DOM Worker"],
|
||||
|
@ -94,7 +94,7 @@ const presets = {
|
|||
"firefox-platform": {
|
||||
label: "Firefox Platform",
|
||||
description: "Recommended preset for internal Firefox platform debugging.",
|
||||
entries: 10000000,
|
||||
entries: 16 * 1024 * 1024,
|
||||
interval: 1,
|
||||
features: ["screenshots", "js", "leaf", "stackwalk", "java"],
|
||||
threads: ["GeckoMain", "Compositor", "Renderer"],
|
||||
|
@ -103,7 +103,7 @@ const presets = {
|
|||
"firefox-front-end": {
|
||||
label: "Firefox Front-End",
|
||||
description: "Recommended preset for internal Firefox front-end debugging.",
|
||||
entries: 10000000,
|
||||
entries: 16 * 1024 * 1024,
|
||||
interval: 1,
|
||||
features: ["screenshots", "js", "leaf", "stackwalk", "java"],
|
||||
threads: ["GeckoMain", "Compositor", "Renderer", "DOM Worker"],
|
||||
|
@ -112,7 +112,7 @@ const presets = {
|
|||
media: {
|
||||
label: "Media",
|
||||
description: "Recommended preset for diagnosing audio and video problems.",
|
||||
entries: 10000000,
|
||||
entries: 16 * 1024 * 1024,
|
||||
interval: 1,
|
||||
features: ["js", "leaf", "stackwalk"],
|
||||
threads: [
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
// @ts-ignore
|
||||
const { OS } = require("resource://gre/modules/osfile.jsm");
|
||||
|
||||
const UNITS = ["B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
||||
const UNITS = ["B", "kiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"];
|
||||
|
||||
/**
|
||||
* Linearly interpolate between values.
|
||||
|
@ -42,7 +42,7 @@ function clamp(val, min, max) {
|
|||
/**
|
||||
* Formats a file size.
|
||||
* @param {number} num - The number (in bytes) to format.
|
||||
* @returns {string} e.g. "10 B", "100 MB"
|
||||
* @returns {string} e.g. "10 B", "100 MiB"
|
||||
*/
|
||||
function formatFileSize(num) {
|
||||
if (!Number.isFinite(num)) {
|
||||
|
@ -60,10 +60,10 @@ function formatFileSize(num) {
|
|||
}
|
||||
|
||||
const exponent = Math.min(
|
||||
Math.floor(Math.log(num) / Math.log(1000)),
|
||||
Math.floor(Math.log2(num) / Math.log2(1024)),
|
||||
UNITS.length - 1
|
||||
);
|
||||
const numStr = Number((num / Math.pow(1000, exponent)).toPrecision(3));
|
||||
const numStr = Number((num / Math.pow(1024, exponent)).toPrecision(3));
|
||||
const unit = UNITS[exponent];
|
||||
|
||||
return (neg ? "-" : "") + numStr + " " + unit;
|
||||
|
@ -105,6 +105,45 @@ function makeExponentialScale(rangeStart, rangeEnd) {
|
|||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates numbers that scale exponentially as powers of 2.
|
||||
*
|
||||
* @param {number} rangeStart
|
||||
* @param {number} rangeEnd
|
||||
*
|
||||
* @returns {ScaleFunctions}
|
||||
*/
|
||||
function makePowerOf2Scale(rangeStart, rangeEnd) {
|
||||
const startExp = Math.log2(rangeStart);
|
||||
const endExp = Math.log2(rangeEnd);
|
||||
|
||||
/** @type {NumberScaler} */
|
||||
const fromFractionToValue = frac =>
|
||||
Math.pow(2, Math.round((1 - frac) * startExp + frac * endExp));
|
||||
|
||||
/** @type {NumberScaler} */
|
||||
const fromValueToFraction = value =>
|
||||
(Math.log2(value) - startExp) / (endExp - startExp);
|
||||
|
||||
/** @type {NumberScaler} */
|
||||
const fromFractionToSingleDigitValue = frac => {
|
||||
// fromFractionToValue returns an exact power of 2, we don't want to change
|
||||
// its precision. Note that formatFileSize will display it in a nice binary
|
||||
// unit with up to 3 digits.
|
||||
return fromFractionToValue(frac);
|
||||
};
|
||||
|
||||
return {
|
||||
// Takes a number ranged 0-1 and returns it within the range.
|
||||
fromFractionToValue,
|
||||
// Takes a number in the range, and returns a value between 0-1
|
||||
fromValueToFraction,
|
||||
// Takes a number ranged 0-1 and returns a value in the range, but with
|
||||
// a single digit value.
|
||||
fromFractionToSingleDigitValue,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Scale a source range to a destination range, but clamp it within the
|
||||
* destination range.
|
||||
|
@ -370,6 +409,7 @@ const featureDescriptions = [
|
|||
module.exports = {
|
||||
formatFileSize,
|
||||
makeExponentialScale,
|
||||
makePowerOf2Scale,
|
||||
scaleRangeWithClamping,
|
||||
calculateOverhead,
|
||||
withCommonPathPrefixRemoved,
|
||||
|
|
Загрузка…
Ссылка в новой задаче