Bug 1576550 - AUTO_PROFILER_STATS(add_marker...) - r=gregtatum

Gather stats for most calls to `profiler_add_marker()`, including the time to
allocate payloads if any.

Differential Revision: https://phabricator.services.mozilla.com/D43420

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Gerald Squelart 2019-09-04 07:58:21 +00:00
Родитель 95f77c2409
Коммит e1481bf4bb
9 изменённых файлов: 46 добавлений и 21 удалений

Просмотреть файл

@ -109,6 +109,7 @@ void ProfilerScreenshots::SubmitScreenshot(
gfxUtils::eDataURIEncode, nullptr, &dataURL); gfxUtils::eDataURIEncode, nullptr, &dataURL);
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
// Add a marker with the data URL. // Add a marker with the data URL.
AUTO_PROFILER_STATS(add_marker_with_ScreenshotPayload);
profiler_add_marker_for_thread( profiler_add_marker_for_thread(
sourceThread, JS::ProfilingCategoryPair::GRAPHICS, sourceThread, JS::ProfilingCategoryPair::GRAPHICS,
"CompositorScreenshot", "CompositorScreenshot",

Просмотреть файл

@ -2523,6 +2523,7 @@ int32_t RecordContentFrameTime(
aUniqueStacks); aUniqueStacks);
} }
}; };
AUTO_PROFILER_STATS(add_marker_with_ContentFramePayload);
profiler_add_marker_for_thread( profiler_add_marker_for_thread(
profiler_current_thread_id(), JS::ProfilingCategoryPair::GRAPHICS, profiler_current_thread_id(), JS::ProfilingCategoryPair::GRAPHICS,
"CONTENT_FRAME_TIME", "CONTENT_FRAME_TIME",

Просмотреть файл

@ -374,6 +374,7 @@ void ContentCompositorBridgeParent::ShadowLayersUpdated(
aUniqueStacks); aUniqueStacks);
} }
}; };
AUTO_PROFILER_STATS(add_marker_with_ContentBuildPayload);
profiler_add_marker_for_thread( profiler_add_marker_for_thread(
profiler_current_thread_id(), JS::ProfilingCategoryPair::GRAPHICS, profiler_current_thread_id(), JS::ProfilingCategoryPair::GRAPHICS,
"CONTENT_FULL_PAINT_TIME", "CONTENT_FULL_PAINT_TIME",

Просмотреть файл

@ -219,6 +219,7 @@ class SceneBuiltNotification : public wr::NotificationHandler {
} }
}; };
AUTO_PROFILER_STATS(add_marker_with_ContentFullPaintPayload);
profiler_add_marker_for_thread( profiler_add_marker_for_thread(
profiler_current_thread_id(), profiler_current_thread_id(),
JS::ProfilingCategoryPair::GRAPHICS, "CONTENT_FULL_PAINT_TIME", JS::ProfilingCategoryPair::GRAPHICS, "CONTENT_FULL_PAINT_TIME",

Просмотреть файл

@ -3147,8 +3147,6 @@ static void racy_profiler_add_marker(
return; return;
} }
AUTO_PROFILER_STATS(base_racy_profiler_add_marker);
TimeStamp origin = (aPayload && !aPayload->GetStartTime().IsNull()) TimeStamp origin = (aPayload && !aPayload->GetStartTime().IsNull())
? aPayload->GetStartTime() ? aPayload->GetStartTime()
: TimeStamp::NowUnfuzzed(); : 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 // This is a simplified version of profiler_add_marker that can be easily passed
// into the JS engine. // into the JS engine.
void profiler_add_js_marker(const char* aMarkerName) { void profiler_add_js_marker(const char* aMarkerName) {
AUTO_PROFILER_STATS(base_add_marker);
profiler_add_marker(aMarkerName, ProfilingCategoryPair::JS, nullptr); profiler_add_marker(aMarkerName, ProfilingCategoryPair::JS, nullptr);
} }
@ -3237,6 +3236,7 @@ void profiler_tracing(const char* aCategoryString, const char* aMarkerName,
return; return;
} }
AUTO_PROFILER_STATS(base_add_marker_with_TracingMarkerPayload);
auto payload = MakeUnique<TracingMarkerPayload>( auto payload = MakeUnique<TracingMarkerPayload>(
aCategoryString, aKind, aDocShellId, aDocShellHistoryId); aCategoryString, aKind, aDocShellId, aDocShellHistoryId);
racy_profiler_add_marker(aMarkerName, aCategoryPair, std::move(payload)); racy_profiler_add_marker(aMarkerName, aCategoryPair, std::move(payload));
@ -3256,6 +3256,7 @@ void profiler_tracing(const char* aCategoryString, const char* aMarkerName,
return; return;
} }
AUTO_PROFILER_STATS(base_add_marker_with_TracingMarkerPayload);
auto payload = auto payload =
MakeUnique<TracingMarkerPayload>(aCategoryString, aKind, aDocShellId, MakeUnique<TracingMarkerPayload>(aCategoryString, aKind, aDocShellId,
aDocShellHistoryId, std::move(aCause)); aDocShellHistoryId, std::move(aCause));
@ -3269,6 +3270,7 @@ void profiler_add_text_marker(const char* aMarkerName, const std::string& aText,
const Maybe<std::string>& aDocShellId, const Maybe<std::string>& aDocShellId,
const Maybe<uint32_t>& aDocShellHistoryId, const Maybe<uint32_t>& aDocShellHistoryId,
UniqueProfilerBacktrace aCause) { UniqueProfilerBacktrace aCause) {
AUTO_PROFILER_STATS(base_add_marker_with_TextMarkerPayload);
profiler_add_marker( profiler_add_marker(
aMarkerName, aCategoryPair, aMarkerName, aCategoryPair,
MakeUnique<TextMarkerPayload>(aText, aStartTime, aEndTime, aDocShellId, MakeUnique<TextMarkerPayload>(aText, aStartTime, aEndTime, aDocShellId,

Просмотреть файл

@ -691,9 +691,12 @@ class MOZ_RAII AutoProfilerStats {
// mode. // mode.
# define BASE_PROFILER_ADD_MARKER(markerName, categoryPair) \ # define BASE_PROFILER_ADD_MARKER(markerName, categoryPair) \
do { \
AUTO_PROFILER_STATS(base_add_marker); \
::mozilla::baseprofiler::profiler_add_marker( \ ::mozilla::baseprofiler::profiler_add_marker( \
markerName, \ markerName, \
::mozilla::baseprofiler::ProfilingCategoryPair::categoryPair) ::mozilla::baseprofiler::ProfilingCategoryPair::categoryPair); \
} while (false)
MFBT_API void profiler_add_marker(const char* aMarkerName, MFBT_API void profiler_add_marker(const char* aMarkerName,
ProfilingCategoryPair aCategoryPair); ProfilingCategoryPair aCategoryPair);
@ -704,10 +707,13 @@ MFBT_API void profiler_add_marker(const char* aMarkerName,
// ("text", start, end, ds, dsh))` // ("text", start, end, ds, dsh))`
# define BASE_PROFILER_ADD_MARKER_WITH_PAYLOAD( \ # define BASE_PROFILER_ADD_MARKER_WITH_PAYLOAD( \
markerName, categoryPair, PayloadType, parenthesizedPayloadArgs) \ markerName, categoryPair, PayloadType, parenthesizedPayloadArgs) \
do { \
AUTO_PROFILER_STATS(base_add_marker_with_##PayloadType); \
::mozilla::baseprofiler::profiler_add_marker( \ ::mozilla::baseprofiler::profiler_add_marker( \
markerName, \ markerName, \
::mozilla::baseprofiler::ProfilingCategoryPair::categoryPair, \ ::mozilla::baseprofiler::ProfilingCategoryPair::categoryPair, \
::mozilla::MakeUnique<PayloadType> parenthesizedPayloadArgs) ::mozilla::MakeUnique<PayloadType> parenthesizedPayloadArgs); \
} while (false)
MFBT_API void profiler_add_marker(const char* aMarkerName, MFBT_API void profiler_add_marker(const char* aMarkerName,
ProfilingCategoryPair aCategoryPair, ProfilingCategoryPair aCategoryPair,

Просмотреть файл

@ -497,6 +497,7 @@ void BackgroundHangThread::ReportHang(TimeDuration aHangTime) {
if (profiler_is_active()) { if (profiler_is_active()) {
TimeStamp endTime = TimeStamp::Now(); TimeStamp endTime = TimeStamp::Now();
TimeStamp startTime = endTime - aHangTime; TimeStamp startTime = endTime - aHangTime;
AUTO_PROFILER_STATS(add_marker_with_HangMarkerPayload);
profiler_add_marker_for_thread( profiler_add_marker_for_thread(
mStackHelper.GetThreadId(), JS::ProfilingCategoryPair::OTHER, mStackHelper.GetThreadId(), JS::ProfilingCategoryPair::OTHER,
"BHR-detected hang", MakeUnique<HangMarkerPayload>(startTime, endTime)); "BHR-detected hang", MakeUnique<HangMarkerPayload>(startTime, endTime));

Просмотреть файл

@ -4008,8 +4008,6 @@ static void racy_profiler_add_marker(
return; return;
} }
AUTO_PROFILER_STATS(gecko_racy_profiler_add_marker);
TimeStamp origin = (aPayload && !aPayload->GetStartTime().IsNull()) TimeStamp origin = (aPayload && !aPayload->GetStartTime().IsNull())
? aPayload->GetStartTime() ? aPayload->GetStartTime()
: TimeStamp::NowUnfuzzed(); : 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 // This is a simplified version of profiler_add_marker that can be easily passed
// into the JS engine. // into the JS engine.
void profiler_add_js_marker(const char* aMarkerName) { void profiler_add_js_marker(const char* aMarkerName) {
AUTO_PROFILER_STATS(add_marker);
profiler_add_marker(aMarkerName, JS::ProfilingCategoryPair::JS, nullptr); profiler_add_marker(aMarkerName, JS::ProfilingCategoryPair::JS, nullptr);
} }
void profiler_add_js_allocation_marker(JS::RecordAllocationInfo&& info) { void profiler_add_js_allocation_marker(JS::RecordAllocationInfo&& info) {
AUTO_PROFILER_STATS(add_marker_with_JsAllocationMarkerPayload);
profiler_add_marker( profiler_add_marker(
"JS allocation", JS::ProfilingCategoryPair::JS, "JS allocation", JS::ProfilingCategoryPair::JS,
MakeUnique<JsAllocationMarkerPayload>(TimeStamp::Now(), std::move(info), MakeUnique<JsAllocationMarkerPayload>(TimeStamp::Now(), std::move(info),
@ -4070,6 +4070,7 @@ void profiler_add_network_marker(
uint32_t id = static_cast<uint32_t>(aChannelId & 0xFFFFFFFF); uint32_t id = static_cast<uint32_t>(aChannelId & 0xFFFFFFFF);
char name[2048]; char name[2048];
SprintfLiteral(name, "Load %d: %s", id, PromiseFlatCString(spec).get()); SprintfLiteral(name, "Load %d: %s", id, PromiseFlatCString(spec).get());
AUTO_PROFILER_STATS(add_marker_with_NetworkMarkerPayload);
profiler_add_marker( profiler_add_marker(
name, JS::ProfilingCategoryPair::NETWORK, name, JS::ProfilingCategoryPair::NETWORK,
MakeUnique<NetworkMarkerPayload>( MakeUnique<NetworkMarkerPayload>(
@ -4134,6 +4135,7 @@ void profiler_tracing(const char* aCategoryString, const char* aMarkerName,
return; return;
} }
AUTO_PROFILER_STATS(add_marker_with_TracingMarkerPayload);
auto payload = MakeUnique<TracingMarkerPayload>( auto payload = MakeUnique<TracingMarkerPayload>(
aCategoryString, aKind, aDocShellId, aDocShellHistoryId); aCategoryString, aKind, aDocShellId, aDocShellHistoryId);
racy_profiler_add_marker(aMarkerName, aCategoryPair, std::move(payload)); racy_profiler_add_marker(aMarkerName, aCategoryPair, std::move(payload));
@ -4153,6 +4155,7 @@ void profiler_tracing(const char* aCategoryString, const char* aMarkerName,
return; return;
} }
AUTO_PROFILER_STATS(add_marker_with_TracingMarkerPayload);
auto payload = auto payload =
MakeUnique<TracingMarkerPayload>(aCategoryString, aKind, aDocShellId, MakeUnique<TracingMarkerPayload>(aCategoryString, aKind, aDocShellId,
aDocShellHistoryId, std::move(aCause)); aDocShellHistoryId, std::move(aCause));
@ -4166,6 +4169,7 @@ void profiler_add_text_marker(
const mozilla::Maybe<nsID>& aDocShellId, const mozilla::Maybe<nsID>& aDocShellId,
const mozilla::Maybe<uint32_t>& aDocShellHistoryId, const mozilla::Maybe<uint32_t>& aDocShellHistoryId,
UniqueProfilerBacktrace aCause) { UniqueProfilerBacktrace aCause) {
AUTO_PROFILER_STATS(add_marker_with_TextMarkerPayload);
profiler_add_marker( profiler_add_marker(
aMarkerName, aCategoryPair, aMarkerName, aCategoryPair,
MakeUnique<TextMarkerPayload>(aText, aStartTime, aEndTime, aDocShellId, MakeUnique<TextMarkerPayload>(aText, aStartTime, aEndTime, aDocShellId,

Просмотреть файл

@ -71,6 +71,7 @@
#else // !MOZ_GECKO_PROFILER #else // !MOZ_GECKO_PROFILER
# include "BaseProfiler.h"
# include "js/AllocationRecording.h" # include "js/AllocationRecording.h"
# include "js/ProfilingFrameIterator.h" # include "js/ProfilingFrameIterator.h"
# include "js/ProfilingStack.h" # include "js/ProfilingStack.h"
@ -677,7 +678,11 @@ mozilla::Maybe<ProfilerBufferInfo> profiler_get_buffer_info();
// mode. // mode.
# define PROFILER_ADD_MARKER(markerName, categoryPair) \ # define PROFILER_ADD_MARKER(markerName, categoryPair) \
::profiler_add_marker(markerName, ::JS::ProfilingCategoryPair::categoryPair) do { \
AUTO_PROFILER_STATS(add_marker); \
::profiler_add_marker(markerName, \
::JS::ProfilingCategoryPair::categoryPair); \
} while (false)
void profiler_add_marker(const char* aMarkerName, void profiler_add_marker(const char* aMarkerName,
JS::ProfilingCategoryPair aCategoryPair); JS::ProfilingCategoryPair aCategoryPair);
@ -688,9 +693,12 @@ void profiler_add_marker(const char* aMarkerName,
// ("text", start, end, ds, dsh))` // ("text", start, end, ds, dsh))`
# define PROFILER_ADD_MARKER_WITH_PAYLOAD( \ # define PROFILER_ADD_MARKER_WITH_PAYLOAD( \
markerName, categoryPair, PayloadType, parenthesizedPayloadArgs) \ markerName, categoryPair, PayloadType, parenthesizedPayloadArgs) \
do { \
AUTO_PROFILER_STATS(add_marker_with_##PayloadType); \
::profiler_add_marker( \ ::profiler_add_marker( \
markerName, ::JS::ProfilingCategoryPair::categoryPair, \ markerName, ::JS::ProfilingCategoryPair::categoryPair, \
::mozilla::MakeUnique<PayloadType> parenthesizedPayloadArgs) ::mozilla::MakeUnique<PayloadType> parenthesizedPayloadArgs); \
} while (false)
void profiler_add_marker(const char* aMarkerName, void profiler_add_marker(const char* aMarkerName,
JS::ProfilingCategoryPair aCategoryPair, JS::ProfilingCategoryPair aCategoryPair,