diff --git a/gfx/layers/ProfilerScreenshots.cpp b/gfx/layers/ProfilerScreenshots.cpp index 220c500b3e5c..1fd3e2f11167 100644 --- a/gfx/layers/ProfilerScreenshots.cpp +++ b/gfx/layers/ProfilerScreenshots.cpp @@ -109,6 +109,7 @@ void ProfilerScreenshots::SubmitScreenshot( gfxUtils::eDataURIEncode, nullptr, &dataURL); if (NS_SUCCEEDED(rv)) { // Add a marker with the data URL. + AUTO_PROFILER_STATS(add_marker_with_ScreenshotPayload); profiler_add_marker_for_thread( sourceThread, JS::ProfilingCategoryPair::GRAPHICS, "CompositorScreenshot", diff --git a/gfx/layers/ipc/CompositorBridgeParent.cpp b/gfx/layers/ipc/CompositorBridgeParent.cpp index 598d362bf0a6..12d0a6d6e65d 100644 --- a/gfx/layers/ipc/CompositorBridgeParent.cpp +++ b/gfx/layers/ipc/CompositorBridgeParent.cpp @@ -2523,6 +2523,7 @@ int32_t RecordContentFrameTime( aUniqueStacks); } }; + AUTO_PROFILER_STATS(add_marker_with_ContentFramePayload); profiler_add_marker_for_thread( profiler_current_thread_id(), JS::ProfilingCategoryPair::GRAPHICS, "CONTENT_FRAME_TIME", diff --git a/gfx/layers/ipc/ContentCompositorBridgeParent.cpp b/gfx/layers/ipc/ContentCompositorBridgeParent.cpp index f69b8c6550e9..28f6a44dacd6 100644 --- a/gfx/layers/ipc/ContentCompositorBridgeParent.cpp +++ b/gfx/layers/ipc/ContentCompositorBridgeParent.cpp @@ -374,6 +374,7 @@ void ContentCompositorBridgeParent::ShadowLayersUpdated( aUniqueStacks); } }; + AUTO_PROFILER_STATS(add_marker_with_ContentBuildPayload); profiler_add_marker_for_thread( profiler_current_thread_id(), JS::ProfilingCategoryPair::GRAPHICS, "CONTENT_FULL_PAINT_TIME", diff --git a/gfx/layers/wr/WebRenderBridgeParent.cpp b/gfx/layers/wr/WebRenderBridgeParent.cpp index 8d1c08e55cfe..6596bde61399 100644 --- a/gfx/layers/wr/WebRenderBridgeParent.cpp +++ b/gfx/layers/wr/WebRenderBridgeParent.cpp @@ -219,6 +219,7 @@ class SceneBuiltNotification : public wr::NotificationHandler { } }; + AUTO_PROFILER_STATS(add_marker_with_ContentFullPaintPayload); profiler_add_marker_for_thread( profiler_current_thread_id(), JS::ProfilingCategoryPair::GRAPHICS, "CONTENT_FULL_PAINT_TIME", diff --git a/mozglue/baseprofiler/core/platform.cpp b/mozglue/baseprofiler/core/platform.cpp index 6ed2616b831b..783251a2d808 100644 --- a/mozglue/baseprofiler/core/platform.cpp +++ b/mozglue/baseprofiler/core/platform.cpp @@ -3147,8 +3147,6 @@ static void racy_profiler_add_marker( return; } - AUTO_PROFILER_STATS(base_racy_profiler_add_marker); - TimeStamp origin = (aPayload && !aPayload->GetStartTime().IsNull()) ? aPayload->GetStartTime() : TimeStamp::NowUnfuzzed(); @@ -3178,6 +3176,7 @@ void profiler_add_marker(const char* aMarkerName, // This is a simplified version of profiler_add_marker that can be easily passed // into the JS engine. void profiler_add_js_marker(const char* aMarkerName) { + AUTO_PROFILER_STATS(base_add_marker); profiler_add_marker(aMarkerName, ProfilingCategoryPair::JS, nullptr); } @@ -3237,6 +3236,7 @@ void profiler_tracing(const char* aCategoryString, const char* aMarkerName, return; } + AUTO_PROFILER_STATS(base_add_marker_with_TracingMarkerPayload); auto payload = MakeUnique( aCategoryString, aKind, aDocShellId, aDocShellHistoryId); racy_profiler_add_marker(aMarkerName, aCategoryPair, std::move(payload)); @@ -3256,6 +3256,7 @@ void profiler_tracing(const char* aCategoryString, const char* aMarkerName, return; } + AUTO_PROFILER_STATS(base_add_marker_with_TracingMarkerPayload); auto payload = MakeUnique(aCategoryString, aKind, aDocShellId, aDocShellHistoryId, std::move(aCause)); @@ -3269,6 +3270,7 @@ void profiler_add_text_marker(const char* aMarkerName, const std::string& aText, const Maybe& aDocShellId, const Maybe& aDocShellHistoryId, UniqueProfilerBacktrace aCause) { + AUTO_PROFILER_STATS(base_add_marker_with_TextMarkerPayload); profiler_add_marker( aMarkerName, aCategoryPair, MakeUnique(aText, aStartTime, aEndTime, aDocShellId, diff --git a/mozglue/baseprofiler/public/BaseProfiler.h b/mozglue/baseprofiler/public/BaseProfiler.h index 9a9b00425d50..065b2d3bb736 100644 --- a/mozglue/baseprofiler/public/BaseProfiler.h +++ b/mozglue/baseprofiler/public/BaseProfiler.h @@ -690,10 +690,13 @@ class MOZ_RAII AutoProfilerStats { // certain length of time. A no-op if the profiler is inactive or in privacy // mode. -# define BASE_PROFILER_ADD_MARKER(markerName, categoryPair) \ - ::mozilla::baseprofiler::profiler_add_marker( \ - markerName, \ - ::mozilla::baseprofiler::ProfilingCategoryPair::categoryPair) +# define BASE_PROFILER_ADD_MARKER(markerName, categoryPair) \ + do { \ + AUTO_PROFILER_STATS(base_add_marker); \ + ::mozilla::baseprofiler::profiler_add_marker( \ + markerName, \ + ::mozilla::baseprofiler::ProfilingCategoryPair::categoryPair); \ + } while (false) MFBT_API void profiler_add_marker(const char* aMarkerName, ProfilingCategoryPair aCategoryPair); @@ -702,12 +705,15 @@ MFBT_API void profiler_add_marker(const char* aMarkerName, // is the argument list used to construct that `PayloadType`. E.g.: // `BASE_PROFILER_ADD_MARKER_WITH_PAYLOAD("Load", DOM, TextMarkerPayload, // ("text", start, end, ds, dsh))` -# define BASE_PROFILER_ADD_MARKER_WITH_PAYLOAD( \ - markerName, categoryPair, PayloadType, parenthesizedPayloadArgs) \ - ::mozilla::baseprofiler::profiler_add_marker( \ - markerName, \ - ::mozilla::baseprofiler::ProfilingCategoryPair::categoryPair, \ - ::mozilla::MakeUnique parenthesizedPayloadArgs) +# define BASE_PROFILER_ADD_MARKER_WITH_PAYLOAD( \ + markerName, categoryPair, PayloadType, parenthesizedPayloadArgs) \ + do { \ + AUTO_PROFILER_STATS(base_add_marker_with_##PayloadType); \ + ::mozilla::baseprofiler::profiler_add_marker( \ + markerName, \ + ::mozilla::baseprofiler::ProfilingCategoryPair::categoryPair, \ + ::mozilla::MakeUnique parenthesizedPayloadArgs); \ + } while (false) MFBT_API void profiler_add_marker(const char* aMarkerName, ProfilingCategoryPair aCategoryPair, diff --git a/toolkit/components/backgroundhangmonitor/BackgroundHangMonitor.cpp b/toolkit/components/backgroundhangmonitor/BackgroundHangMonitor.cpp index c8da6f268217..bcb5ec84e54a 100644 --- a/toolkit/components/backgroundhangmonitor/BackgroundHangMonitor.cpp +++ b/toolkit/components/backgroundhangmonitor/BackgroundHangMonitor.cpp @@ -497,6 +497,7 @@ void BackgroundHangThread::ReportHang(TimeDuration aHangTime) { if (profiler_is_active()) { TimeStamp endTime = TimeStamp::Now(); TimeStamp startTime = endTime - aHangTime; + AUTO_PROFILER_STATS(add_marker_with_HangMarkerPayload); profiler_add_marker_for_thread( mStackHelper.GetThreadId(), JS::ProfilingCategoryPair::OTHER, "BHR-detected hang", MakeUnique(startTime, endTime)); diff --git a/tools/profiler/core/platform.cpp b/tools/profiler/core/platform.cpp index b8cfcbdafe95..e3f1561a67ab 100644 --- a/tools/profiler/core/platform.cpp +++ b/tools/profiler/core/platform.cpp @@ -4008,8 +4008,6 @@ static void racy_profiler_add_marker( return; } - AUTO_PROFILER_STATS(gecko_racy_profiler_add_marker); - TimeStamp origin = (aPayload && !aPayload->GetStartTime().IsNull()) ? aPayload->GetStartTime() : TimeStamp::NowUnfuzzed(); @@ -4039,10 +4037,12 @@ void profiler_add_marker(const char* aMarkerName, // This is a simplified version of profiler_add_marker that can be easily passed // into the JS engine. void profiler_add_js_marker(const char* aMarkerName) { + AUTO_PROFILER_STATS(add_marker); profiler_add_marker(aMarkerName, JS::ProfilingCategoryPair::JS, nullptr); } void profiler_add_js_allocation_marker(JS::RecordAllocationInfo&& info) { + AUTO_PROFILER_STATS(add_marker_with_JsAllocationMarkerPayload); profiler_add_marker( "JS allocation", JS::ProfilingCategoryPair::JS, MakeUnique(TimeStamp::Now(), std::move(info), @@ -4070,6 +4070,7 @@ void profiler_add_network_marker( uint32_t id = static_cast(aChannelId & 0xFFFFFFFF); char name[2048]; SprintfLiteral(name, "Load %d: %s", id, PromiseFlatCString(spec).get()); + AUTO_PROFILER_STATS(add_marker_with_NetworkMarkerPayload); profiler_add_marker( name, JS::ProfilingCategoryPair::NETWORK, MakeUnique( @@ -4134,6 +4135,7 @@ void profiler_tracing(const char* aCategoryString, const char* aMarkerName, return; } + AUTO_PROFILER_STATS(add_marker_with_TracingMarkerPayload); auto payload = MakeUnique( aCategoryString, aKind, aDocShellId, aDocShellHistoryId); racy_profiler_add_marker(aMarkerName, aCategoryPair, std::move(payload)); @@ -4153,6 +4155,7 @@ void profiler_tracing(const char* aCategoryString, const char* aMarkerName, return; } + AUTO_PROFILER_STATS(add_marker_with_TracingMarkerPayload); auto payload = MakeUnique(aCategoryString, aKind, aDocShellId, aDocShellHistoryId, std::move(aCause)); @@ -4166,6 +4169,7 @@ void profiler_add_text_marker( const mozilla::Maybe& aDocShellId, const mozilla::Maybe& aDocShellHistoryId, UniqueProfilerBacktrace aCause) { + AUTO_PROFILER_STATS(add_marker_with_TextMarkerPayload); profiler_add_marker( aMarkerName, aCategoryPair, MakeUnique(aText, aStartTime, aEndTime, aDocShellId, diff --git a/tools/profiler/public/GeckoProfiler.h b/tools/profiler/public/GeckoProfiler.h index d4eded0fbbc2..e4fedb549907 100644 --- a/tools/profiler/public/GeckoProfiler.h +++ b/tools/profiler/public/GeckoProfiler.h @@ -71,6 +71,7 @@ #else // !MOZ_GECKO_PROFILER +# include "BaseProfiler.h" # include "js/AllocationRecording.h" # include "js/ProfilingFrameIterator.h" # include "js/ProfilingStack.h" @@ -676,8 +677,12 @@ mozilla::Maybe profiler_get_buffer_info(); // certain length of time. A no-op if the profiler is inactive or in privacy // mode. -# define PROFILER_ADD_MARKER(markerName, categoryPair) \ - ::profiler_add_marker(markerName, ::JS::ProfilingCategoryPair::categoryPair) +# define PROFILER_ADD_MARKER(markerName, categoryPair) \ + do { \ + AUTO_PROFILER_STATS(add_marker); \ + ::profiler_add_marker(markerName, \ + ::JS::ProfilingCategoryPair::categoryPair); \ + } while (false) void profiler_add_marker(const char* aMarkerName, JS::ProfilingCategoryPair aCategoryPair); @@ -686,11 +691,14 @@ void profiler_add_marker(const char* aMarkerName, // the argument list used to construct that `PayloadType`. E.g.: // `PROFILER_ADD_MARKER_WITH_PAYLOAD("Load", DOM, TextMarkerPayload, // ("text", start, end, ds, dsh))` -# define PROFILER_ADD_MARKER_WITH_PAYLOAD( \ - markerName, categoryPair, PayloadType, parenthesizedPayloadArgs) \ - ::profiler_add_marker( \ - markerName, ::JS::ProfilingCategoryPair::categoryPair, \ - ::mozilla::MakeUnique parenthesizedPayloadArgs) +# define PROFILER_ADD_MARKER_WITH_PAYLOAD( \ + markerName, categoryPair, PayloadType, parenthesizedPayloadArgs) \ + do { \ + AUTO_PROFILER_STATS(add_marker_with_##PayloadType); \ + ::profiler_add_marker( \ + markerName, ::JS::ProfilingCategoryPair::categoryPair, \ + ::mozilla::MakeUnique parenthesizedPayloadArgs); \ + } while (false) void profiler_add_marker(const char* aMarkerName, JS::ProfilingCategoryPair aCategoryPair,