Bug 1923463: Avoid profiling runnables when using ETW and not collecting scheduling information. r=mstange,profiler-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D233251
This commit is contained in:
Bas Schouten
2025-01-07 13:01:58 +00:00
parent a0058eb37c
commit cf6b852da3
2 changed files with 18 additions and 1 deletions

View File

@@ -31,6 +31,10 @@ TRACELOGGING_DECLARE_PROVIDER(kFirefoxTraceLoggingProvider);
void Init();
void Shutdown();
static inline bool IsProfilingGroup(
mozilla::MarkerSchema::ETWMarkerGroup aGroup) {
return gETWCollectionMask & uint64_t(aGroup);
}
template <typename T, typename = void>
struct MarkerHasPayload : std::false_type {};
@@ -410,6 +414,9 @@ void OutputMarkerSchema(void* aContext, MarkerType aMarkerType,
namespace ETW {
static inline void Init() {}
static inline void Shutdown() {}
static inline bool IsProfilingGroup(mozilla::MarkerSchema::ETWMarkerGroup) {
return false;
}
template <typename MarkerType, typename... PayloadArguments>
static inline void EmitETWMarker(const mozilla::ProfilerString8View& aName,
const mozilla::MarkerCategory& aCategory,

View File

@@ -10,12 +10,22 @@
#include "GeckoProfiler.h"
#include "nsIThreadPool.h"
// Treat runnable profiling separately, as this can add considerable overhead
// and ETW allows disabling it explicitly.
static inline bool profiler_thread_is_profiling_runnables() {
return profiler_thread_is_being_profiled(ThreadProfilingFeatures::Markers) ||
(profiler_is_etw_collecting_markers() &&
ETW::IsProfilingGroup(
mozilla::MarkerSchema::ETWMarkerGroup::Scheduling)) ||
profiler_is_perfetto_tracing();
}
#if !defined(MOZ_GECKO_PROFILER) || !defined(MOZ_COLLECTING_RUNNABLE_TELEMETRY)
# define AUTO_PROFILE_FOLLOWING_RUNNABLE(runnable)
#else
# define AUTO_PROFILE_FOLLOWING_RUNNABLE(runnable) \
mozilla::Maybe<mozilla::AutoProfileRunnable> raiiRunnableMarker; \
if (profiler_thread_is_being_profiled_for_markers()) { \
if (profiler_thread_is_profiling_runnables()) { \
raiiRunnableMarker.emplace(runnable); \
}