Skip to content

Commit

Permalink
Bug 1754424 - Add profiler markers for CPU and GPU time recorded in G…
Browse files Browse the repository at this point in the history
…lean, r=gerald.

Differential Revision: https://phabricator.services.mozilla.com/D138267
  • Loading branch information
fqueze committed Feb 9, 2022
1 parent 8fb7eec commit 7fb7ffd
Showing 1 changed file with 33 additions and 4 deletions.
37 changes: 33 additions & 4 deletions toolkit/components/glean/ipc/FOGIPC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,34 @@ using mozilla::ipc::UtilityProcessManager;
using mozilla::ipc::UtilityProcessParent;
using FlushFOGDataPromise = mozilla::dom::ContentParent::FlushFOGDataPromise;

namespace mozilla {
namespace glean {
namespace geckoprofiler::markers {

using namespace mozilla;

struct ProcessingTimeMarker {
static constexpr Span<const char> MarkerTypeName() {
return MakeStringSpan("ProcessingTime");
}
static void StreamJSONMarkerData(baseprofiler::SpliceableJSONWriter& aWriter,
int64_t aDiffMs,
const ProfilerString8View& aType) {
aWriter.IntProperty("time", aDiffMs);
aWriter.StringProperty("label", aType);
}
static MarkerSchema MarkerTypeDisplay() {
using MS = MarkerSchema;
MS schema{MS::Location::MarkerChart, MS::Location::MarkerTable};
schema.AddKeyLabelFormat("time", "Recorded Time", MS::Format::Milliseconds);
schema.SetTooltipLabel("{marker.name} - {marker.data.label}");
schema.SetTableLabel(
"{marker.name} - {marker.data.label}: {marker.data.time}");
return schema;
}
};

} // namespace geckoprofiler::markers

namespace mozilla::glean {

void RecordPowerMetrics() {
static uint64_t previousCpuTime = 0, previousGpuTime = 0;
Expand Down Expand Up @@ -116,6 +142,8 @@ void RecordPowerMetrics() {
}
power::total_cpu_time_ms.Add(nNewCpuTime);
power::cpu_time_per_process_type_ms.Get(type).Add(nNewCpuTime);
PROFILER_MARKER("CPU Time", OTHER, {}, ProcessingTimeMarker, nNewCpuTime,
type);
previousCpuTime += newCpuTime;
}

Expand All @@ -126,6 +154,8 @@ void RecordPowerMetrics() {
}
power::total_gpu_time_ms.Add(nNewGpuTime);
power::gpu_time_per_process_type_ms.Get(type).Add(nNewGpuTime);
PROFILER_MARKER("GPU Time", OTHER, {}, ProcessingTimeMarker, nNewGpuTime,
type);
previousGpuTime += newGpuTime;
}
}
Expand Down Expand Up @@ -341,5 +371,4 @@ void TestTriggerMetrics(uint32_t aProcessType,
}
}

} // namespace glean
} // namespace mozilla
} // namespace mozilla::glean

0 comments on commit 7fb7ffd

Please sign in to comment.