summaryrefslogtreecommitdiffstats
path: root/toolkit/components
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-20 04:02:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-20 04:02:43 +0000
commit8ef7f43d9d880ce1c7da687c3c0bf2caf44bcbcd (patch)
tree16a27151176f80644677f4007d17dbd5f4d0f204 /toolkit/components
parentReleasing progress-linux version 127.0-1~progress7.99u1. (diff)
downloadfirefox-8ef7f43d9d880ce1c7da687c3c0bf2caf44bcbcd.tar.xz
firefox-8ef7f43d9d880ce1c7da687c3c0bf2caf44bcbcd.zip
Merging upstream version 127.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components')
-rw-r--r--toolkit/components/glean/ipc/FOGIPC.cpp65
-rw-r--r--toolkit/components/processtools/metrics.yaml16
2 files changed, 80 insertions, 1 deletions
diff --git a/toolkit/components/glean/ipc/FOGIPC.cpp b/toolkit/components/glean/ipc/FOGIPC.cpp
index e44cf3e863..4ce009e4fa 100644
--- a/toolkit/components/glean/ipc/FOGIPC.cpp
+++ b/toolkit/components/glean/ipc/FOGIPC.cpp
@@ -37,6 +37,10 @@
#include "nsTArray.h"
#include "nsThreadUtils.h"
+#if defined(__APPLE__) && defined(__aarch64__)
+# define HAS_PROCESS_ENERGY
+#endif
+
using mozilla::dom::ContentParent;
using mozilla::gfx::GPUChild;
using mozilla::gfx::GPUProcessManager;
@@ -76,6 +80,29 @@ struct ProcessingTimeMarker {
}
};
+#ifdef HAS_PROCESS_ENERGY
+struct ProcessEnergyMarker {
+ static constexpr Span<const char> MarkerTypeName() {
+ return MakeStringSpan("ProcessEnergy");
+ }
+ static void StreamJSONMarkerData(baseprofiler::SpliceableJSONWriter& aWriter,
+ int64_t aUWh,
+ const ProfilerString8View& aType) {
+ aWriter.IntProperty("energy", aUWh);
+ aWriter.StringProperty("label", aType);
+ }
+ static MarkerSchema MarkerTypeDisplay() {
+ using MS = MarkerSchema;
+ MS schema{MS::Location::MarkerChart, MS::Location::MarkerTable};
+ schema.AddKeyLabelFormat("energy", "Energy (µWh)", MS::Format::Integer);
+ schema.SetTooltipLabel("{marker.name} - {marker.data.label}");
+ schema.SetTableLabel(
+ "{marker.name} - {marker.data.label}: {marker.data.energy}µWh");
+ return schema;
+ }
+};
+#endif
+
} // namespace geckoprofiler::markers
namespace mozilla::glean {
@@ -248,8 +275,26 @@ void GetTrackerType(nsAutoCString& aTrackerType) {
}
}
+#ifdef HAS_PROCESS_ENERGY
+static int64_t GetTaskEnergy() {
+ task_power_info_v2_data_t task_power_info;
+ mach_msg_type_number_t count = TASK_POWER_INFO_V2_COUNT;
+ kern_return_t kr = task_info(mach_task_self(), TASK_POWER_INFO_V2,
+ (task_info_t)&task_power_info, &count);
+ if (kr != KERN_SUCCESS) {
+ return 0;
+ }
+
+ // task_energy is in nanojoules. We want microwatt-hours.
+ return task_power_info.task_energy / 3.6 / 1e6;
+}
+#endif
+
void RecordPowerMetrics() {
static uint64_t previousCpuTime = 0, previousGpuTime = 0;
+#ifdef HAS_PROCESS_ENERGY
+ static int64_t previousProcessEnergy = 0;
+#endif
uint64_t cpuTime, newCpuTime = 0;
if (NS_SUCCEEDED(GetCpuTimeSinceProcessStartInMs(&cpuTime)) &&
@@ -265,7 +310,16 @@ void RecordPowerMetrics() {
newGpuTime = gpuTime - previousGpuTime;
}
- if (!newCpuTime && !newGpuTime) {
+#ifdef HAS_PROCESS_ENERGY
+ int64_t processEnergy = GetTaskEnergy();
+ int64_t newProcessEnergy = processEnergy - previousProcessEnergy;
+#endif
+
+ if (!newCpuTime && !newGpuTime
+#ifdef HAS_PROCESS_ENERGY
+ && newProcessEnergy <= 0
+#endif
+ ) {
// Nothing to record.
return;
}
@@ -358,6 +412,15 @@ void RecordPowerMetrics() {
previousGpuTime += newGpuTime;
}
+#ifdef HAS_PROCESS_ENERGY
+ if (newProcessEnergy) {
+ power::energy_per_process_type.Get(type).Add(newProcessEnergy);
+ PROFILER_MARKER("Process Energy", OTHER, {}, ProcessEnergyMarker,
+ newProcessEnergy, type);
+ previousProcessEnergy += newProcessEnergy;
+ }
+#endif
+
profiler_record_wakeup_count(type);
}
diff --git a/toolkit/components/processtools/metrics.yaml b/toolkit/components/processtools/metrics.yaml
index 6efbd22fa5..1d6e6bf133 100644
--- a/toolkit/components/processtools/metrics.yaml
+++ b/toolkit/components/processtools/metrics.yaml
@@ -112,6 +112,22 @@ power:
expires: never
telemetry_mirror: POWER_GPU_TIME_BOGUS_VALUES
+ energy_per_process_type:
+ type: labeled_counter
+ description: >
+ How much energy (in µWh) has been used, broken down by process type.
+ Only available on Apple Silicon.
+ bugs:
+ - https://bugzilla.mozilla.org/show_bug.cgi?id=1898057
+ data_reviews:
+ - https://bugzilla.mozilla.org/show_bug.cgi?id=1898057
+ data_sensitivity:
+ - technical
+ notification_emails:
+ - florian@mozilla.com
+ expires: never
+ labels: *per_process_type_labels
+
wakeups_per_process_type:
type: labeled_counter
description: >