diff --git a/tools/profiler/public/ETWTools.h b/tools/profiler/public/ETWTools.h index 4a9310016080..aeb9214058c0 100644 --- a/tools/profiler/public/ETWTools.h +++ b/tools/profiler/public/ETWTools.h @@ -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 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 static inline void EmitETWMarker(const mozilla::ProfilerString8View& aName, const mozilla::MarkerCategory& aCategory, diff --git a/tools/profiler/public/ProfilerRunnable.h b/tools/profiler/public/ProfilerRunnable.h index b3e1cb5ae89e..7aa3b155953f 100644 --- a/tools/profiler/public/ProfilerRunnable.h +++ b/tools/profiler/public/ProfilerRunnable.h @@ -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 raiiRunnableMarker; \ - if (profiler_thread_is_being_profiled_for_markers()) { \ + if (profiler_thread_is_profiling_runnables()) { \ raiiRunnableMarker.emplace(runnable); \ }