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);
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",

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

@ -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",

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

@ -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",

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

@ -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",

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

@ -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<TracingMarkerPayload>(
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<TracingMarkerPayload>(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<std::string>& aDocShellId,
const Maybe<uint32_t>& aDocShellHistoryId,
UniqueProfilerBacktrace aCause) {
AUTO_PROFILER_STATS(base_add_marker_with_TextMarkerPayload);
profiler_add_marker(
aMarkerName, aCategoryPair,
MakeUnique<TextMarkerPayload>(aText, aStartTime, aEndTime, aDocShellId,

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

@ -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<PayloadType> 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<PayloadType> parenthesizedPayloadArgs); \
} while (false)
MFBT_API void profiler_add_marker(const char* aMarkerName,
ProfilingCategoryPair aCategoryPair,

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

@ -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<HangMarkerPayload>(startTime, endTime));

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

@ -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<JsAllocationMarkerPayload>(TimeStamp::Now(), std::move(info),
@ -4070,6 +4070,7 @@ void profiler_add_network_marker(
uint32_t id = static_cast<uint32_t>(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<NetworkMarkerPayload>(
@ -4134,6 +4135,7 @@ void profiler_tracing(const char* aCategoryString, const char* aMarkerName,
return;
}
AUTO_PROFILER_STATS(add_marker_with_TracingMarkerPayload);
auto payload = MakeUnique<TracingMarkerPayload>(
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<TracingMarkerPayload>(aCategoryString, aKind, aDocShellId,
aDocShellHistoryId, std::move(aCause));
@ -4166,6 +4169,7 @@ void profiler_add_text_marker(
const mozilla::Maybe<nsID>& aDocShellId,
const mozilla::Maybe<uint32_t>& aDocShellHistoryId,
UniqueProfilerBacktrace aCause) {
AUTO_PROFILER_STATS(add_marker_with_TextMarkerPayload);
profiler_add_marker(
aMarkerName, aCategoryPair,
MakeUnique<TextMarkerPayload>(aText, aStartTime, aEndTime, aDocShellId,

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

@ -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<ProfilerBufferInfo> 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<PayloadType> 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<PayloadType> parenthesizedPayloadArgs); \
} while (false)
void profiler_add_marker(const char* aMarkerName,
JS::ProfilingCategoryPair aCategoryPair,