Bug 1795047 - Power use feature string should clarify what's available on each platform, r=canaltinova,dlrobertson.

Differential Revision: https://phabricator.services.mozilla.com/D159685
This commit is contained in:
Florian Quèze 2022-10-20 16:01:51 +00:00
parent 6faaf10d5f
commit baad7da439
3 changed files with 61 additions and 9 deletions

View file

@ -11,6 +11,10 @@
const UNITS = ["B", "kiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"];
const AppConstants = ChromeUtils.importESModule(
"resource://gre/modules/AppConstants.sys.mjs"
).AppConstants;
/**
* Linearly interpolate between values.
* https://en.wikipedia.org/wiki/Linear_interpolation
@ -533,9 +537,24 @@ const featureDescriptions = [
{
name: "Power Use",
value: "power",
title:
"Record the value of every energy meter available on the system with " +
"each sample. Only available on Windows 11 and Apple Silicon.",
title: (() => {
switch (AppConstants.platform) {
case "win":
return (
"Record the value of every energy meter available on the system with " +
"each sample. Only available on Windows 11 with Intel CPUs."
);
case "linux":
return (
"Record the power used by the entire system with each sample. " +
"Only available with Intel CPUs and requires setting the sysctl kernel.perf_event_paranoid to 0."
);
case "macosx":
return "Record the power used by the entire system (Intel) or each process (Apple Silicon) with each sample.";
default:
return "Not supported on this platform.";
}
})(),
experimental: true,
},
];

View file

@ -143,6 +143,24 @@ class MOZ_RAII AutoProfilerStats {
// Profiler features
//---------------------------------------------------------------------------
# if defined(__APPLE__) && defined(__aarch64__)
# define POWER_HELP "Sample per process power use"
# elif defined(__APPLE__) && defined(__x86_64__)
# define POWER_HELP \
"Record the power used by the entire system with each sample."
# elif defined(__linux__) && defined(__x86_64__)
# define POWER_HELP \
"Record the power used by the entire system with each sample. " \
"Only available with Intel CPUs and requires setting " \
"the sysctl kernel.perf_event_paranoid to 0."
# elif defined(_MSC_VER)
# define POWER_HELP \
"Record the value of every energy meter available on the system with " \
"each sample. Only available on Windows 11 with Intel CPUs."
# else
# define POWER_HELP "Not supported on this platform."
# endif
// Higher-order macro containing all the feature info in one place. Define
// |MACRO| appropriately to extract the relevant parts. Note that the number
// values are used internally only and so can be changed without consequence.
@ -216,9 +234,7 @@ class MOZ_RAII AutoProfilerStats {
MACRO(21, "processcpu", ProcessCPU, \
"Sample the CPU utilization of each process") \
\
MACRO(22, "power", Power, \
"Sample energy meters on Windows 11 and per process power use on " \
"Apple Silicon")
MACRO(22, "power", Power, POWER_HELP)
// *** Synchronize with lists in ProfilerState.h and geckoProfiler.json ***
struct ProfilerFeature {

View file

@ -22,6 +22,25 @@
// Profiler features
//---------------------------------------------------------------------------
#if defined(__APPLE__) && defined(__aarch64__)
# define POWER_HELP "Sample per process power use"
#elif defined(__APPLE__) && defined(__x86_64__)
# define POWER_HELP \
"Record the power used by the entire system with each sample."
#elif defined(__linux__) && defined(__x86_64__)
# define POWER_HELP \
"Record the power used by the entire system with each sample. " \
"Only available with Intel CPUs and requires setting " \
"the sysctl kernel.perf_event_paranoid to 0."
#elif defined(_MSC_VER)
# define POWER_HELP \
"Record the value of every energy meter available on the system with " \
"each sample. Only available on Windows 11 with Intel CPUs."
#else
# define POWER_HELP "Not supported on this platform."
#endif
// Higher-order macro containing all the feature info in one place. Define
// |MACRO| appropriately to extract the relevant parts. Note that the number
// values are used internally only and so can be changed without consequence.
@ -95,9 +114,7 @@
MACRO(21, "processcpu", ProcessCPU, \
"Sample the CPU utilization of each process") \
\
MACRO(22, "power", Power, \
"Sample energy meters on Windows 11 and per process power use on " \
"Apple Silicon")
MACRO(22, "power", Power, POWER_HELP)
// *** Synchronize with lists in BaseProfilerState.h and geckoProfiler.json ***
struct ProfilerFeature {