Bug 1667915 - Separate marker category from marker options - r=gregtatum

The `category.WithOptions(...)` syntax was a bit strange and difficult to explain.

Now the category and options are separate parameters. Default options can be specified with `MarkerOptions{}` or just `{}`.

As a special case, defaulted-NoPayload functions don't need `<>`, and defaulted-NoPayload functions and macros don't even need `{}` for default options, e.g.:
`profiler_add_marker("name", OTHER); PROFILER_MARKER_UNTYPED("name", OTHER);`

Differential Revision: https://phabricator.services.mozilla.com/D91680
This commit is contained in:
Gerald Squelart
2020-10-01 01:44:47 +00:00
parent 300de37f87
commit 4eb5bd3574
26 changed files with 380 additions and 360 deletions

View File

@@ -7950,7 +7950,7 @@ nsresult nsDocShell::CreateContentViewer(const nsACString& aContentType,
BasePrincipal::Cast(thisPrincipal)->GetURI(getter_AddRefs(prinURI)); BasePrincipal::Cast(thisPrincipal)->GetURI(getter_AddRefs(prinURI));
nsPrintfCString marker("Iframe loaded in background: %s", nsPrintfCString marker("Iframe loaded in background: %s",
prinURI->GetSpecOrDefault().get()); prinURI->GetSpecOrDefault().get());
PROFILER_MARKER_TEXT("Background Iframe", DOM, marker); PROFILER_MARKER_TEXT("Background Iframe", DOM, {}, marker);
#endif #endif
SetBackgroundLoadIframe(); SetBackgroundLoadIframe();
} }

View File

@@ -200,7 +200,7 @@ void ChromeUtils::AddProfilerMarker(
const Optional<DOMHighResTimeStamp>& aStartTime, const Optional<DOMHighResTimeStamp>& aStartTime,
const Optional<nsACString>& aText) { const Optional<nsACString>& aText) {
#ifdef MOZ_GECKO_PROFILER #ifdef MOZ_GECKO_PROFILER
MarkerOptions options{::geckoprofiler::category::JS}; MarkerOptions options;
if (aStartTime.WasPassed()) { if (aStartTime.WasPassed()) {
RefPtr<Performance> performance; RefPtr<Performance> performance;
@@ -231,10 +231,9 @@ void ChromeUtils::AddProfilerMarker(
} }
if (aText.WasPassed()) { if (aText.WasPassed()) {
PROFILER_MARKER_TEXT(aName, MarkerOptions(std::move(options)), PROFILER_MARKER_TEXT(aName, JS, std::move(options), aText.Value());
aText.Value());
} else { } else {
PROFILER_MARKER_UNTYPED(aName, MarkerOptions(std::move(options))); PROFILER_MARKER_UNTYPED(aName, JS, std::move(options));
} }
#endif // MOZ_GECKO_PROFILER #endif // MOZ_GECKO_PROFILER
} }

View File

@@ -6072,10 +6072,9 @@ bool nsGlobalWindowInner::RunTimeoutHandler(Timeout* aTimeout,
timeout->mScriptHandler->GetDescription(handlerDescription); timeout->mScriptHandler->GetDescription(handlerDescription);
str.Append(handlerDescription); str.Append(handlerDescription);
} }
AUTO_PROFILER_MARKER_TEXT( AUTO_PROFILER_MARKER_TEXT("setTimeout callback", JS,
"setTimeout callback", MarkerOptions(MarkerStack::TakeBacktrace(
JS.WithOptions( timeout->TakeProfilerBacktrace()),
MarkerStack::TakeBacktrace(timeout->TakeProfilerBacktrace()),
MarkerInnerWindowId(mWindowID)), MarkerInnerWindowId(mWindowID)),
str); str);
#endif #endif

View File

@@ -1064,20 +1064,18 @@ nsresult EventDispatcher::Dispatch(nsISupports* aTarget,
}; };
profiler_add_marker<DOMEventMarker>( profiler_add_marker<DOMEventMarker>(
"DOMEvent", "DOMEvent", geckoprofiler::category::DOM,
geckoprofiler::category::DOM.WithOptions( {MarkerTiming::IntervalStart(),
MarkerTiming::IntervalStart(), MarkerInnerWindowId(innerWindowId)},
MarkerInnerWindowId(innerWindowId)),
typeStr, aEvent->mTimeStamp); typeStr, aEvent->mTimeStamp);
EventTargetChainItem::HandleEventTargetChain(chain, postVisitor, EventTargetChainItem::HandleEventTargetChain(chain, postVisitor,
aCallback, cd); aCallback, cd);
profiler_add_marker<DOMEventMarker>( profiler_add_marker<DOMEventMarker>(
"DOMEvent", "DOMEvent", geckoprofiler::category::DOM,
geckoprofiler::category::DOM.WithOptions( {MarkerTiming::IntervalEnd(), std::move(innerWindowId)}, typeStr,
MarkerTiming::IntervalEnd(), std::move(innerWindowId)), aEvent->mTimeStamp);
typeStr, aEvent->mTimeStamp);
} else } else
#endif #endif
{ {

View File

@@ -286,9 +286,8 @@ void PreallocatedProcessManagerImpl::RemoveBlocker(ContentParent* aParent) {
MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug, MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug,
("Blocked preallocation for %fms", ("Blocked preallocation for %fms",
(TimeStamp::Now() - mBlockingStartTime).ToMilliseconds())); (TimeStamp::Now() - mBlockingStartTime).ToMilliseconds()));
PROFILER_MARKER_TEXT( PROFILER_MARKER_TEXT("Process", DOM,
"Process", MarkerTiming::IntervalUntilNowFrom(mBlockingStartTime),
DOM.WithOptions(MarkerTiming::IntervalUntilNowFrom(mBlockingStartTime)),
"Blocked preallocation"); "Blocked preallocation");
if (IsEmpty()) { if (IsEmpty()) {
AllocateAfterDelay(); AllocateAfterDelay();

View File

@@ -2863,9 +2863,8 @@ nsresult ScriptLoader::EvaluateScript(ScriptLoadRequest* aRequest) {
// mDataType of the request might remain set to DataType::Unknown. // mDataType of the request might remain set to DataType::Unknown.
MOZ_ASSERT(aRequest->IsTextSource() || aRequest->IsUnknownDataType()); MOZ_ASSERT(aRequest->IsTextSource() || aRequest->IsUnknownDataType());
LOG(("ScriptLoadRequest (%p): Evaluate Module", aRequest)); LOG(("ScriptLoadRequest (%p): Evaluate Module", aRequest));
AUTO_PROFILER_MARKER_TEXT( AUTO_PROFILER_MARKER_TEXT("ModuleEvaluation", JS,
"ModuleEvaluation", MarkerInnerWindowIdFromDocShell(docShell),
JS.WithOptions(MarkerInnerWindowIdFromDocShell(docShell)),
profilerLabelString); profilerLabelString);
// currentScript is set to null for modules. // currentScript is set to null for modules.
@@ -2939,9 +2938,8 @@ nsresult ScriptLoader::EvaluateScript(ScriptLoadRequest* aRequest) {
} else { } else {
LOG(("ScriptLoadRequest (%p): Decode Bytecode and Execute", LOG(("ScriptLoadRequest (%p): Decode Bytecode and Execute",
aRequest)); aRequest));
AUTO_PROFILER_MARKER_TEXT( AUTO_PROFILER_MARKER_TEXT("BytecodeDecodeMainThread", JS,
"BytecodeDecodeMainThread", MarkerInnerWindowIdFromDocShell(docShell),
JS.WithOptions(MarkerInnerWindowIdFromDocShell(docShell)),
profilerLabelString); profilerLabelString);
rv = exec.Decode(options, aRequest->mScriptBytecode, rv = exec.Decode(options, aRequest->mScriptBytecode,
@@ -2949,9 +2947,8 @@ nsresult ScriptLoader::EvaluateScript(ScriptLoadRequest* aRequest) {
} }
if (rv == NS_OK) { if (rv == NS_OK) {
AUTO_PROFILER_MARKER_TEXT( AUTO_PROFILER_MARKER_TEXT("ScriptExecution", JS,
"ScriptExecution", MarkerInnerWindowIdFromDocShell(docShell),
JS.WithOptions(MarkerInnerWindowIdFromDocShell(docShell)),
profilerLabelString); profilerLabelString);
rv = ExecuteCompiledScript(cx, aRequest, exec, classicScript); rv = ExecuteCompiledScript(cx, aRequest, exec, classicScript);
} }
@@ -2986,8 +2983,8 @@ nsresult ScriptLoader::EvaluateScript(ScriptLoadRequest* aRequest) {
LOG(("ScriptLoadRequest (%p): Compile And Exec", aRequest)); LOG(("ScriptLoadRequest (%p): Compile And Exec", aRequest));
if (aRequest->IsBinASTSource()) { if (aRequest->IsBinASTSource()) {
AUTO_PROFILER_MARKER_TEXT( AUTO_PROFILER_MARKER_TEXT(
"BinASTDecodeMainThread", "BinASTDecodeMainThread", JS,
JS.WithOptions(MarkerInnerWindowIdFromDocShell(docShell)), MarkerInnerWindowIdFromDocShell(docShell),
profilerLabelString); profilerLabelString);
rv = exec.DecodeBinAST(options, rv = exec.DecodeBinAST(options,
@@ -2999,8 +2996,8 @@ nsresult ScriptLoader::EvaluateScript(ScriptLoadRequest* aRequest) {
rv = GetScriptSource(cx, aRequest, &maybeSource); rv = GetScriptSource(cx, aRequest, &maybeSource);
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
AUTO_PROFILER_MARKER_TEXT( AUTO_PROFILER_MARKER_TEXT(
"ScriptCompileMainThread", "ScriptCompileMainThread", JS,
JS.WithOptions(MarkerInnerWindowIdFromDocShell(docShell)), MarkerInnerWindowIdFromDocShell(docShell),
profilerLabelString); profilerLabelString);
rv = maybeSource.constructed<SourceText<char16_t>>() rv = maybeSource.constructed<SourceText<char16_t>>()
@@ -3017,8 +3014,8 @@ nsresult ScriptLoader::EvaluateScript(ScriptLoadRequest* aRequest) {
if (rv == NS_OK) { if (rv == NS_OK) {
script = exec.GetScript(); script = exec.GetScript();
AUTO_PROFILER_MARKER_TEXT( AUTO_PROFILER_MARKER_TEXT(
"ScriptExecution", "ScriptExecution", JS,
JS.WithOptions(MarkerInnerWindowIdFromDocShell(docShell)), MarkerInnerWindowIdFromDocShell(docShell),
profilerLabelString); profilerLabelString);
rv = ExecuteCompiledScript(cx, aRequest, exec, classicScript); rv = ExecuteCompiledScript(cx, aRequest, exec, classicScript);
} }

View File

@@ -361,8 +361,8 @@ void WorkerGlobalScope::ImportScripts(JSContext* aCx,
} }
} }
} }
AUTO_PROFILER_MARKER_TEXT("ImportScripts", AUTO_PROFILER_MARKER_TEXT("ImportScripts", JS, MarkerStack::Capture(),
JS.WithOptions(MarkerStack::Capture()), urls); urls);
#endif #endif
workerinternals::Load(mWorkerPrivate, std::move(stack), aScriptURLs, workerinternals::Load(mWorkerPrivate, std::move(stack), aScriptURLs,
WorkerScript, aRv); WorkerScript, aRv);

View File

@@ -2365,10 +2365,9 @@ void RecordCompositionPayloadsPresented(
nsPrintfCString text( nsPrintfCString text(
"Latency: %dms", "Latency: %dms",
int32_t((presented - payload.mTimeStamp).ToMilliseconds())); int32_t((presented - payload.mTimeStamp).ToMilliseconds()));
PROFILER_MARKER_TEXT(name, PROFILER_MARKER_TEXT(
GRAPHICS.WithOptions(MarkerTiming::Interval( name, GRAPHICS,
payload.mTimeStamp, presented)), MarkerTiming::Interval(payload.mTimeStamp, presented), text);
text);
} }
#endif #endif

View File

@@ -81,7 +81,7 @@ void SurfacePoolCA::LockedPool::MutateEntryStorage(const char* aMutationType,
#ifdef MOZ_GECKO_PROFILER #ifdef MOZ_GECKO_PROFILER
if (profiler_thread_is_being_profiled()) { if (profiler_thread_is_being_profiled()) {
PROFILER_MARKER_TEXT( PROFILER_MARKER_TEXT(
"SurfacePool", GRAPHICS.WithOptions(MarkerTiming::IntervalUntilNowFrom(before)), "SurfacePool", GRAPHICS, MarkerTiming::IntervalUntilNowFrom(before),
nsPrintfCString("%d -> %d in use | %d -> %d waiting for | %d -> %d " nsPrintfCString("%d -> %d in use | %d -> %d waiting for | %d -> %d "
"available | %s %dx%d | %dMB total memory", "available | %s %dx%d | %dMB total memory",
int(inUseCountBefore), int(mInUseEntries.size()), int(pendingCountBefore), int(inUseCountBefore), int(mInUseEntries.size()), int(pendingCountBefore),

View File

@@ -50,7 +50,7 @@ void ImageComposite::UpdateBias(size_t aImageIndex, bool aFrameChanged) {
nsPrintfCString str("current %.2lfms, next %.2lfms", nsPrintfCString str("current %.2lfms, next %.2lfms",
offsetCurrent.ToMilliseconds(), offsetCurrent.ToMilliseconds(),
offsetNext.ToMilliseconds()); offsetNext.ToMilliseconds());
PROFILER_MARKER_TEXT("Video frame offsets", GRAPHICS, str); PROFILER_MARKER_TEXT("Video frame offsets", GRAPHICS, {}, str);
} }
#endif #endif
@@ -185,7 +185,7 @@ void ImageComposite::SetImages(nsTArray<TimedImage>&& aNewImages) {
") to frameID %" PRId32 " (prod %" PRId32 ")", ") to frameID %" PRId32 " (prod %" PRId32 ")",
len, len == 1 ? "image" : "images", first.mFrameID, len, len == 1 ? "image" : "images", first.mFrameID,
first.mProducerID, last.mFrameID, last.mProducerID); first.mProducerID, last.mFrameID, last.mProducerID);
PROFILER_MARKER_TEXT("ImageComposite::SetImages", GRAPHICS, str); PROFILER_MARKER_TEXT("ImageComposite::SetImages", GRAPHICS, {}, str);
} }
#endif #endif
} }
@@ -229,7 +229,7 @@ bool ImageComposite::UpdateCompositedFrame(
descr.AppendLiteral(", no change"); descr.AppendLiteral(", no change");
} }
} }
PROFILER_MARKER_TEXT("UpdateCompositedFrame", GRAPHICS, descr); PROFILER_MARKER_TEXT("UpdateCompositedFrame", GRAPHICS, {}, descr);
#endif #endif
if (mLastFrameID == image.mFrameID && mLastProducerID == image.mProducerID) { if (mLastFrameID == image.mFrameID && mLastProducerID == image.mProducerID) {
@@ -259,7 +259,7 @@ bool ImageComposite::UpdateCompositedFrame(
" (producer %" PRId32 ")", " (producer %" PRId32 ")",
dropped, frameOrFrames, mLastFrameID, image.mFrameID, dropped, frameOrFrames, mLastFrameID, image.mFrameID,
mLastProducerID); mLastProducerID);
PROFILER_MARKER_TEXT("Video frames dropped", GRAPHICS, text); PROFILER_MARKER_TEXT("Video frames dropped", GRAPHICS, {}, text);
} }
#endif #endif
} }
@@ -370,7 +370,7 @@ void ImageComposite::DetectTimeStampJitter(const TimedImage* aNewImage) {
} }
if (jitter) { if (jitter) {
nsPrintfCString text("%.2lfms", jitter->ToMilliseconds()); nsPrintfCString text("%.2lfms", jitter->ToMilliseconds());
PROFILER_MARKER_TEXT("VideoFrameTimeStampJitter", GRAPHICS, text); PROFILER_MARKER_TEXT("VideoFrameTimeStampJitter", GRAPHICS, {}, text);
} }
#endif #endif
} }

View File

@@ -88,8 +88,8 @@ void gecko_profiler_add_text_marker(const char* name, const char* text_bytes,
auto now = mozilla::TimeStamp::NowUnfuzzed(); auto now = mozilla::TimeStamp::NowUnfuzzed();
auto start = now - mozilla::TimeDuration::FromMicroseconds(microseconds); auto start = now - mozilla::TimeDuration::FromMicroseconds(microseconds);
PROFILER_MARKER_TEXT( PROFILER_MARKER_TEXT(
mozilla::ProfilerString8View::WrapNullTerminatedString(name), mozilla::ProfilerString8View::WrapNullTerminatedString(name), GRAPHICS,
GRAPHICS.WithOptions(mozilla::MarkerTiming::Interval(start, now)), mozilla::MarkerTiming::Interval(start, now),
mozilla::ProfilerString8View(text_bytes, text_len)); mozilla::ProfilerString8View(text_bytes, text_len));
} }
#endif #endif
@@ -1990,7 +1990,7 @@ void WebRenderBridgeParent::CompositeToTarget(VsyncId aId,
if (mPaused || !mReceivedDisplayList) { if (mPaused || !mReceivedDisplayList) {
ResetPreviousSampleTime(); ResetPreviousSampleTime();
mCompositionOpportunityId = mCompositionOpportunityId.Next(); mCompositionOpportunityId = mCompositionOpportunityId.Next();
PROFILER_MARKER_TEXT("SkippedComposite", GRAPHICS, PROFILER_MARKER_TEXT("SkippedComposite", GRAPHICS, {},
mPaused ? "Paused"_ns : "No display list"_ns); mPaused ? "Paused"_ns : "No display list"_ns);
return; return;
} }
@@ -2010,7 +2010,7 @@ void WebRenderBridgeParent::CompositeToTarget(VsyncId aId,
} }
} }
PROFILER_MARKER_TEXT("SkippedComposite", GRAPHICS, PROFILER_MARKER_TEXT("SkippedComposite", GRAPHICS, {},
"Too many pending frames"); "Too many pending frames");
return; return;
} }
@@ -2037,8 +2037,8 @@ void WebRenderBridgeParent::MaybeGenerateFrame(VsyncId aId,
// Skip WR render during paused state. // Skip WR render during paused state.
if (cbp->IsPaused()) { if (cbp->IsPaused()) {
TimeStamp now = TimeStamp::NowUnfuzzed(); TimeStamp now = TimeStamp::NowUnfuzzed();
PROFILER_MARKER_TEXT("SkippedComposite", PROFILER_MARKER_TEXT("SkippedComposite", GRAPHICS,
GRAPHICS.WithOptions(MarkerTiming::InstantAt(now)), MarkerTiming::InstantAt(now),
"CompositorBridgeParent is paused"); "CompositorBridgeParent is paused");
cbp->NotifyPipelineRendered(mPipelineId, mWrEpoch, VsyncId(), now, now, cbp->NotifyPipelineRendered(mPipelineId, mWrEpoch, VsyncId(), now, now,
now); now);
@@ -2073,8 +2073,8 @@ void WebRenderBridgeParent::MaybeGenerateFrame(VsyncId aId,
if (!generateFrame) { if (!generateFrame) {
// Could skip generating frame now. // Could skip generating frame now.
PROFILER_MARKER_TEXT("SkippedComposite", PROFILER_MARKER_TEXT("SkippedComposite", GRAPHICS,
GRAPHICS.WithOptions(MarkerTiming::InstantAt(start)), MarkerTiming::InstantAt(start),
"No reason to generate frame"); "No reason to generate frame");
ResetPreviousSampleTime(); ResetPreviousSampleTime();
return; return;

View File

@@ -254,9 +254,8 @@ void RenderCompositorNative::CompositorEndFrame() {
nativeLayerCount += int(it.second.mNativeLayers.size()); nativeLayerCount += int(it.second.mNativeLayers.size());
} }
PROFILER_MARKER_TEXT( PROFILER_MARKER_TEXT(
"WR OS Compositor frame", "WR OS Compositor frame", GRAPHICS,
GRAPHICS.WithOptions( MarkerTiming::IntervalUntilNowFrom(mBeginFrameTimeStamp),
MarkerTiming::IntervalUntilNowFrom(mBeginFrameTimeStamp)),
nsPrintfCString("%d%% painting, %d%% overdraw, %d used " nsPrintfCString("%d%% painting, %d%% overdraw, %d used "
"layers (%d%% memory) + %d unused layers (%d%% memory)", "layers (%d%% memory) + %d unused layers (%d%% memory)",
int(mDrawnPixelCount * 100 / windowPixelCount), int(mDrawnPixelCount * 100 / windowPixelCount),

View File

@@ -377,8 +377,7 @@ const mozilla::Module* mozJSComponentLoader::LoadModule(FileLocation& aFile) {
mInitialized = true; mInitialized = true;
AUTO_PROFILER_MARKER_TEXT("JS XPCOM", JS.WithOptions(MarkerStack::Capture()), AUTO_PROFILER_MARKER_TEXT("JS XPCOM", JS, MarkerStack::Capture(), spec);
spec);
AUTO_PROFILER_LABEL_DYNAMIC_NSCSTRING("mozJSComponentLoader::LoadModule", AUTO_PROFILER_LABEL_DYNAMIC_NSCSTRING("mozJSComponentLoader::LoadModule",
OTHER, spec); OTHER, spec);
@@ -1181,8 +1180,8 @@ nsresult mozJSComponentLoader::Import(JSContext* aCx,
bool aIgnoreExports) { bool aIgnoreExports) {
mInitialized = true; mInitialized = true;
AUTO_PROFILER_MARKER_TEXT("ChromeUtils.import", AUTO_PROFILER_MARKER_TEXT("ChromeUtils.import", JS, MarkerStack::Capture(),
JS.WithOptions(MarkerStack::Capture()), aLocation); aLocation);
ComponentLoaderInfo info(aLocation); ComponentLoaderInfo info(aLocation);

View File

@@ -416,8 +416,7 @@ nsresult mozJSSubScriptLoader::DoLoadSubScriptWithOptions(
} }
NS_LossyConvertUTF16toASCII asciiUrl(url); NS_LossyConvertUTF16toASCII asciiUrl(url);
AUTO_PROFILER_MARKER_TEXT("SubScript", JS.WithOptions(MarkerStack::Capture()), AUTO_PROFILER_MARKER_TEXT("SubScript", JS, MarkerStack::Capture(), asciiUrl);
asciiUrl);
AUTO_PROFILER_LABEL_DYNAMIC_NSCSTRING_NONSENSITIVE( AUTO_PROFILER_LABEL_DYNAMIC_NSCSTRING_NONSENSITIVE(
"mozJSSubScriptLoader::DoLoadSubScriptWithOptions", OTHER, asciiUrl); "mozJSSubScriptLoader::DoLoadSubScriptWithOptions", OTHER, asciiUrl);

View File

@@ -1283,9 +1283,8 @@ bool nsRefreshDriver::RemoveRefreshObserver(nsARefreshObserver* aObserver,
nsPrintfCString str("%s [%s]", data.mDescription, nsPrintfCString str("%s [%s]", data.mDescription,
kFlushTypeNames[aFlushType]); kFlushTypeNames[aFlushType]);
PROFILER_MARKER_TEXT( PROFILER_MARKER_TEXT(
"RefreshObserver", "RefreshObserver", GRAPHICS,
GRAPHICS.WithOptions( MarkerOptions(MarkerStack::TakeBacktrace(std::move(data.mCause)),
MarkerStack::TakeBacktrace(std::move(data.mCause)),
MarkerTiming::IntervalUntilNowFrom(data.mRegisterTime), MarkerTiming::IntervalUntilNowFrom(data.mRegisterTime),
MarkerInnerWindowId(data.mInnerWindowId)), MarkerInnerWindowId(data.mInnerWindowId)),
str); str);
@@ -2070,8 +2069,8 @@ void nsRefreshDriver::Tick(VsyncId aId, TimeStamp aNowTime) {
} }
#endif #endif
AUTO_PROFILER_MARKER_TEXT( AUTO_PROFILER_MARKER_TEXT(
"RefreshDriverTick", "RefreshDriverTick", GRAPHICS,
GRAPHICS.WithOptions( MarkerOptions(
MarkerStack::TakeBacktrace(std::move(mRefreshTimerStartedCause)), MarkerStack::TakeBacktrace(std::move(mRefreshTimerStartedCause)),
MarkerInnerWindowIdFromDocShell(GetDocShell(mPresContext))), MarkerInnerWindowIdFromDocShell(GetDocShell(mPresContext))),
profilerStr); profilerStr);
@@ -2333,9 +2332,9 @@ void nsRefreshDriver::Tick(VsyncId aId, TimeStamp aNowTime) {
transactionId.AppendInt((uint64_t)mNextTransactionId); transactionId.AppendInt((uint64_t)mNextTransactionId);
} }
#endif #endif
AUTO_PROFILER_MARKER_TEXT("ViewManagerFlush", AUTO_PROFILER_MARKER_TEXT(
GRAPHICS.WithOptions(MarkerStack::TakeBacktrace( "ViewManagerFlush", GRAPHICS,
std::move(mViewManagerFlushCause))), MarkerStack::TakeBacktrace(std::move(mViewManagerFlushCause)),
transactionId); transactionId);
RefPtr<TimelineConsumers> timelines = TimelineConsumers::Get(); RefPtr<TimelineConsumers> timelines = TimelineConsumers::Get();

View File

@@ -38,10 +38,12 @@
#ifndef MOZ_GECKO_PROFILER #ifndef MOZ_GECKO_PROFILER
# define BASE_PROFILER_MARKER_UNTYPED(markerName, options) # define BASE_PROFILER_MARKER_UNTYPED(markerName, categoryName, ...)
# define BASE_PROFILER_MARKER(markerName, options, MarkerType, ...) # define BASE_PROFILER_MARKER(markerName, categoryName, options, MarkerType, \
# define BASE_PROFILER_MARKER_TEXT(markerName, options, text) ...)
# define AUTO_BASE_PROFILER_MARKER_TEXT(markerName, options, text) # define BASE_PROFILER_MARKER_TEXT(markerName, categoryName, options, text)
# define AUTO_BASE_PROFILER_MARKER_TEXT(markerName, categoryName, options, \
text)
#else // ndef MOZ_GECKO_PROFILER #else // ndef MOZ_GECKO_PROFILER
@@ -54,29 +56,44 @@
namespace mozilla::baseprofiler { namespace mozilla::baseprofiler {
template <typename MarkerType = ::mozilla::baseprofiler::markers::NoPayload, template <typename MarkerType, typename... Ts>
typename... Ts>
ProfileBufferBlockIndex AddMarkerToBuffer(ProfileChunkedBuffer& aBuffer, ProfileBufferBlockIndex AddMarkerToBuffer(ProfileChunkedBuffer& aBuffer,
const ProfilerString8View& aName, const ProfilerString8View& aName,
const MarkerCategory& aCategory,
MarkerOptions&& aOptions, MarkerOptions&& aOptions,
const Ts&... aTs) { const Ts&... aTs) {
return base_profiler_markers_detail::AddMarkerToBuffer<MarkerType>( return base_profiler_markers_detail::AddMarkerToBuffer<MarkerType>(
aBuffer, aName, std::move(aOptions), aBuffer, aName, aCategory, std::move(aOptions),
::mozilla::baseprofiler::profiler_capture_backtrace_into, aTs...); ::mozilla::baseprofiler::profiler_capture_backtrace_into, aTs...);
} }
template <typename MarkerType = ::mozilla::baseprofiler::markers::NoPayload, // Add a marker (without payload) to a given buffer.
typename... Ts> inline ProfileBufferBlockIndex AddMarkerToBuffer(
ProfileChunkedBuffer& aBuffer, const ProfilerString8View& aName,
const MarkerCategory& aCategory, MarkerOptions&& aOptions = {}) {
return AddMarkerToBuffer<markers::NoPayload>(aBuffer, aName, aCategory,
std::move(aOptions));
}
template <typename MarkerType, typename... Ts>
ProfileBufferBlockIndex AddMarker(const ProfilerString8View& aName, ProfileBufferBlockIndex AddMarker(const ProfilerString8View& aName,
const MarkerCategory& aCategory,
MarkerOptions&& aOptions, const Ts&... aTs) { MarkerOptions&& aOptions, const Ts&... aTs) {
if (!baseprofiler::profiler_can_accept_markers()) { if (!baseprofiler::profiler_can_accept_markers()) {
return {}; return {};
} }
return ::mozilla::baseprofiler::AddMarkerToBuffer<MarkerType>( return ::mozilla::baseprofiler::AddMarkerToBuffer<MarkerType>(
base_profiler_markers_detail::CachedBaseCoreBuffer(), aName, base_profiler_markers_detail::CachedBaseCoreBuffer(), aName, aCategory,
std::move(aOptions), aTs...); std::move(aOptions), aTs...);
} }
// Add a marker (without payload) to the Base Profiler buffer.
inline ProfileBufferBlockIndex AddMarker(const ProfilerString8View& aName,
const MarkerCategory& aCategory,
MarkerOptions&& aOptions = {}) {
return AddMarker<markers::NoPayload>(aName, aCategory, std::move(aOptions));
}
// Marker types' StreamJSONMarkerData functions should use this to correctly // Marker types' StreamJSONMarkerData functions should use this to correctly
// output timestamps as a JSON property. // output timestamps as a JSON property.
inline void WritePropertyTime(JSONWriter& aWriter, inline void WritePropertyTime(JSONWriter& aWriter,
@@ -90,20 +107,22 @@ inline void WritePropertyTime(JSONWriter& aWriter,
} // namespace mozilla::baseprofiler } // namespace mozilla::baseprofiler
# define BASE_PROFILER_MARKER_UNTYPED(markerName, options) \ # define BASE_PROFILER_MARKER_UNTYPED(markerName, categoryName, ...) \
do { \ do { \
AUTO_PROFILER_STATS(BASE_PROFILER_MARKER_UNTYPED); \ AUTO_PROFILER_STATS(BASE_PROFILER_MARKER_UNTYPED); \
::mozilla::baseprofiler::AddMarker<>( \ ::mozilla::baseprofiler::AddMarker( \
markerName, ::mozilla::baseprofiler::category::options); \ markerName, ::mozilla::baseprofiler::category::categoryName, \
##__VA_ARGS__); \
} while (false) } while (false)
# define BASE_PROFILER_MARKER(markerName, options, MarkerType, ...) \ # define BASE_PROFILER_MARKER(markerName, categoryName, options, MarkerType, \
...) \
do { \ do { \
AUTO_PROFILER_STATS(BASE_PROFILER_MARKER_with_##MarkerType); \ AUTO_PROFILER_STATS(BASE_PROFILER_MARKER_with_##MarkerType); \
::mozilla::baseprofiler::AddMarker< \ ::mozilla::baseprofiler::AddMarker< \
::mozilla::baseprofiler::markers::MarkerType>( \ ::mozilla::baseprofiler::markers::MarkerType>( \
markerName, ::mozilla::baseprofiler::category::options, \ markerName, ::mozilla::baseprofiler::category::categoryName, \
##__VA_ARGS__); \ options, ##__VA_ARGS__); \
} while (false) } while (false)
namespace mozilla::baseprofiler::markers { namespace mozilla::baseprofiler::markers {
@@ -119,12 +138,13 @@ struct Text {
}; };
} // namespace mozilla::baseprofiler::markers } // namespace mozilla::baseprofiler::markers
# define BASE_PROFILER_MARKER_TEXT(markerName, options, text) \ # define BASE_PROFILER_MARKER_TEXT(markerName, categoryName, options, text) \
do { \ do { \
AUTO_PROFILER_STATS(BASE_PROFILER_MARKER_TEXT); \ AUTO_PROFILER_STATS(BASE_PROFILER_MARKER_TEXT); \
::mozilla::baseprofiler::AddMarker< \ ::mozilla::baseprofiler::AddMarker< \
::mozilla::baseprofiler::markers::Text>( \ ::mozilla::baseprofiler::markers::Text>( \
markerName, ::mozilla::baseprofiler::category::options, text); \ markerName, ::mozilla::baseprofiler::category::categoryName, \
options, text); \
} while (false) } while (false)
namespace mozilla::baseprofiler { namespace mozilla::baseprofiler {
@@ -134,9 +154,13 @@ namespace mozilla::baseprofiler {
// start time is already specified in the provided options) until destruction. // start time is already specified in the provided options) until destruction.
class MOZ_RAII AutoProfilerTextMarker { class MOZ_RAII AutoProfilerTextMarker {
public: public:
AutoProfilerTextMarker(const char* aMarkerName, MarkerOptions&& aOptions, AutoProfilerTextMarker(const char* aMarkerName,
const std::string& aText) const MarkerCategory& aCategory,
: mMarkerName(aMarkerName), mOptions(std::move(aOptions)), mText(aText) { MarkerOptions&& aOptions, const std::string& aText)
: mMarkerName(aMarkerName),
mCategory(aCategory),
mOptions(std::move(aOptions)),
mText(aText) {
MOZ_ASSERT(mOptions.Timing().EndTime().IsNull(), MOZ_ASSERT(mOptions.Timing().EndTime().IsNull(),
"AutoProfilerTextMarker options shouldn't have an end time"); "AutoProfilerTextMarker options shouldn't have an end time");
if (mOptions.Timing().StartTime().IsNull()) { if (mOptions.Timing().StartTime().IsNull()) {
@@ -146,22 +170,26 @@ class MOZ_RAII AutoProfilerTextMarker {
~AutoProfilerTextMarker() { ~AutoProfilerTextMarker() {
mOptions.TimingRef().SetIntervalEnd(); mOptions.TimingRef().SetIntervalEnd();
BASE_PROFILER_MARKER_TEXT( AUTO_PROFILER_STATS(AUTO_BASE_PROFILER_MARKER_TEXT);
ProfilerString8View::WrapNullTerminatedString(mMarkerName), AddMarker<markers::Text>(
MarkerOptions(std::move(mOptions)), mText); ProfilerString8View::WrapNullTerminatedString(mMarkerName), mCategory,
std::move(mOptions), mText);
} }
protected: protected:
const char* mMarkerName; const char* mMarkerName;
MarkerCategory mCategory;
MarkerOptions mOptions; MarkerOptions mOptions;
std::string mText; std::string mText;
}; };
} // namespace mozilla::baseprofiler } // namespace mozilla::baseprofiler
# define AUTO_BASE_PROFILER_MARKER_TEXT(markerName, options, text) \ # define AUTO_BASE_PROFILER_MARKER_TEXT(markerName, categoryName, options, \
text) \
::mozilla::baseprofiler::AutoProfilerTextMarker BASE_PROFILER_RAII( \ ::mozilla::baseprofiler::AutoProfilerTextMarker BASE_PROFILER_RAII( \
markerName, ::mozilla::baseprofiler::category::options, text) markerName, ::mozilla::baseprofiler::category::categoryName, options, \
text)
#endif // nfed MOZ_GECKO_PROFILER else #endif // nfed MOZ_GECKO_PROFILER else

View File

@@ -82,12 +82,12 @@ struct StreamFunctionTypeHelper<R(JSONWriter&, As...)> {
// references-to-const, permitted implicit conversions can happen. // references-to-const, permitted implicit conversions can happen.
static ProfileBufferBlockIndex Serialize( static ProfileBufferBlockIndex Serialize(
ProfileChunkedBuffer& aBuffer, const ProfilerString8View& aName, ProfileChunkedBuffer& aBuffer, const ProfilerString8View& aName,
MarkerOptions&& aOptions, Streaming::DeserializerTag aDeserializerTag, const MarkerCategory& aCategory, MarkerOptions&& aOptions,
const As&... aAs) { Streaming::DeserializerTag aDeserializerTag, const As&... aAs) {
// Note that options are first after the entry kind, because they contain // Note that options are first after the entry kind, because they contain
// the thread id, which is handled first to filter markers by threads. // the thread id, which is handled first to filter markers by threads.
return aBuffer.PutObjects(ProfileBufferEntryKind::Marker, aOptions, aName, return aBuffer.PutObjects(ProfileBufferEntryKind::Marker, aOptions, aName,
aDeserializerTag, aAs...); aCategory, aDeserializerTag, aAs...);
} }
}; };
@@ -111,6 +111,7 @@ struct MarkerTypeSerialization {
template <typename... Ts> template <typename... Ts>
static ProfileBufferBlockIndex Serialize(ProfileChunkedBuffer& aBuffer, static ProfileBufferBlockIndex Serialize(ProfileChunkedBuffer& aBuffer,
const ProfilerString8View& aName, const ProfilerString8View& aName,
const MarkerCategory& aCategory,
MarkerOptions&& aOptions, MarkerOptions&& aOptions,
const Ts&... aTs) { const Ts&... aTs) {
static_assert(!std::is_same_v<MarkerType, static_assert(!std::is_same_v<MarkerType,
@@ -126,8 +127,8 @@ struct MarkerTypeSerialization {
// everybody, even the majority of users not using the profiler. // everybody, even the majority of users not using the profiler.
static const Streaming::DeserializerTag tag = static const Streaming::DeserializerTag tag =
Streaming::TagForDeserializer(Deserialize); Streaming::TagForDeserializer(Deserialize);
return StreamFunctionType::Serialize(aBuffer, aName, std::move(aOptions), return StreamFunctionType::Serialize(aBuffer, aName, aCategory,
tag, aTs...); std::move(aOptions), tag, aTs...);
} }
private: private:
@@ -175,7 +176,8 @@ struct MarkerTypeSerialization<::mozilla::baseprofiler::markers::NoPayload> {
template <typename MarkerType, typename... Ts> template <typename MarkerType, typename... Ts>
static ProfileBufferBlockIndex AddMarkerWithOptionalStackToBuffer( static ProfileBufferBlockIndex AddMarkerWithOptionalStackToBuffer(
ProfileChunkedBuffer& aBuffer, const ProfilerString8View& aName, ProfileChunkedBuffer& aBuffer, const ProfilerString8View& aName,
MarkerOptions&& aOptions, const Ts&... aTs) { const MarkerCategory& aCategory, MarkerOptions&& aOptions,
const Ts&... aTs) {
if constexpr (std::is_same_v<MarkerType, if constexpr (std::is_same_v<MarkerType,
::mozilla::baseprofiler::markers::NoPayload>) { ::mozilla::baseprofiler::markers::NoPayload>) {
static_assert(sizeof...(Ts) == 0, static_assert(sizeof...(Ts) == 0,
@@ -183,11 +185,11 @@ static ProfileBufferBlockIndex AddMarkerWithOptionalStackToBuffer(
// Note that options are first after the entry kind, because they contain // Note that options are first after the entry kind, because they contain
// the thread id, which is handled first to filter markers by threads. // the thread id, which is handled first to filter markers by threads.
return aBuffer.PutObjects( return aBuffer.PutObjects(
ProfileBufferEntryKind::Marker, std::move(aOptions), aName, ProfileBufferEntryKind::Marker, std::move(aOptions), aName, aCategory,
base_profiler_markers_detail::Streaming::DeserializerTag(0)); base_profiler_markers_detail::Streaming::DeserializerTag(0));
} else { } else {
return MarkerTypeSerialization<MarkerType>::Serialize( return MarkerTypeSerialization<MarkerType>::Serialize(
aBuffer, aName, std::move(aOptions), aTs...); aBuffer, aName, aCategory, std::move(aOptions), aTs...);
} }
} }
@@ -201,7 +203,7 @@ using BacktraceCaptureFunction = bool (*)(ProfileChunkedBuffer&);
template <typename MarkerType, typename... Ts> template <typename MarkerType, typename... Ts>
ProfileBufferBlockIndex AddMarkerToBuffer( ProfileBufferBlockIndex AddMarkerToBuffer(
ProfileChunkedBuffer& aBuffer, const ProfilerString8View& aName, ProfileChunkedBuffer& aBuffer, const ProfilerString8View& aName,
MarkerOptions&& aOptions, const MarkerCategory& aCategory, MarkerOptions&& aOptions,
BacktraceCaptureFunction aBacktraceCaptureFunction, const Ts&... aTs) { BacktraceCaptureFunction aBacktraceCaptureFunction, const Ts&... aTs) {
if (aOptions.ThreadId().IsUnspecified()) { if (aOptions.ThreadId().IsUnspecified()) {
// If yet unspecified, set thread to this thread where the marker is added. // If yet unspecified, set thread to this thread where the marker is added.
@@ -226,11 +228,11 @@ ProfileBufferBlockIndex AddMarkerToBuffer(
aBacktraceCaptureFunction(chunkedBuffer) ? &chunkedBuffer : nullptr); aBacktraceCaptureFunction(chunkedBuffer) ? &chunkedBuffer : nullptr);
// This call must be made from here, while chunkedBuffer is in scope. // This call must be made from here, while chunkedBuffer is in scope.
return AddMarkerWithOptionalStackToBuffer<MarkerType>( return AddMarkerWithOptionalStackToBuffer<MarkerType>(
aBuffer, aName, std::move(aOptions), aTs...); aBuffer, aName, aCategory, std::move(aOptions), aTs...);
} }
return AddMarkerWithOptionalStackToBuffer<MarkerType>( return AddMarkerWithOptionalStackToBuffer<MarkerType>(
aBuffer, aName, std::move(aOptions), aTs...); aBuffer, aName, aCategory, std::move(aOptions), aTs...);
} }
template <typename NameCallback, typename StackCallback> template <typename NameCallback, typename StackCallback>
@@ -254,7 +256,7 @@ template <typename NameCallback, typename StackCallback>
aWriter.StartArrayElement(); aWriter.StartArrayElement();
{ {
std::forward<NameCallback>(aNameCallback)( std::forward<NameCallback>(aNameCallback)(
aEntryReader.ReadObject<mozilla::ProfilerString8View>()); aEntryReader.ReadObject<ProfilerString8View>());
const double startTime = options.Timing().GetStartTime(); const double startTime = options.Timing().GetStartTime();
aWriter.DoubleElement(startTime); aWriter.DoubleElement(startTime);
@@ -264,7 +266,8 @@ template <typename NameCallback, typename StackCallback>
aWriter.IntElement(static_cast<int64_t>(options.Timing().MarkerPhase())); aWriter.IntElement(static_cast<int64_t>(options.Timing().MarkerPhase()));
aWriter.IntElement(static_cast<int64_t>(options.Category().GetCategory())); MarkerCategory category = aEntryReader.ReadObject<MarkerCategory>();
aWriter.IntElement(static_cast<int64_t>(category.GetCategory()));
if (const auto tag = if (const auto tag =
aEntryReader.ReadObject<mozilla::base_profiler_markers_detail:: aEntryReader.ReadObject<mozilla::base_profiler_markers_detail::
@@ -422,8 +425,7 @@ template <>
struct ProfileBufferEntryReader::Deserializer<MarkerCategory> { struct ProfileBufferEntryReader::Deserializer<MarkerCategory> {
static void ReadInto(ProfileBufferEntryReader& aER, static void ReadInto(ProfileBufferEntryReader& aER,
MarkerCategory& aCategory) { MarkerCategory& aCategory) {
aCategory.mCategoryPair = static_cast<baseprofiler::ProfilingCategoryPair>( aCategory = Read(aER);
aER.ReadULEB128<uint32_t>());
} }
static MarkerCategory Read(ProfileBufferEntryReader& aER) { static MarkerCategory Read(ProfileBufferEntryReader& aER) {
@@ -584,14 +586,13 @@ struct ProfileBufferEntryReader::Deserializer<MarkerStack> {
template <> template <>
struct ProfileBufferEntryWriter::Serializer<MarkerOptions> { struct ProfileBufferEntryWriter::Serializer<MarkerOptions> {
static Length Bytes(const MarkerOptions& aOptions) { static Length Bytes(const MarkerOptions& aOptions) {
return SumBytes(aOptions.Category(), aOptions.ThreadId(), aOptions.Timing(), return SumBytes(aOptions.ThreadId(), aOptions.Timing(), aOptions.Stack(),
aOptions.Stack(), aOptions.InnerWindowId()); aOptions.InnerWindowId());
} }
static void Write(ProfileBufferEntryWriter& aEW, static void Write(ProfileBufferEntryWriter& aEW,
const MarkerOptions& aOptions) { const MarkerOptions& aOptions) {
aEW.WriteObjects(aOptions.Category(), aOptions.ThreadId(), aEW.WriteObjects(aOptions.ThreadId(), aOptions.Timing(), aOptions.Stack(),
aOptions.Timing(), aOptions.Stack(),
aOptions.InnerWindowId()); aOptions.InnerWindowId());
} }
}; };
@@ -599,8 +600,7 @@ struct ProfileBufferEntryWriter::Serializer<MarkerOptions> {
template <> template <>
struct ProfileBufferEntryReader::Deserializer<MarkerOptions> { struct ProfileBufferEntryReader::Deserializer<MarkerOptions> {
static void ReadInto(ProfileBufferEntryReader& aER, MarkerOptions& aOptions) { static void ReadInto(ProfileBufferEntryReader& aER, MarkerOptions& aOptions) {
aER.ReadIntoObjects(aOptions.mCategory, aOptions.mThreadId, aER.ReadIntoObjects(aOptions.mThreadId, aOptions.mTiming, aOptions.mStack,
aOptions.mTiming, aOptions.mStack,
aOptions.mInnerWindowId); aOptions.mInnerWindowId);
} }

View File

@@ -212,47 +212,34 @@ class MOZ_STACK_CLASS ProfilerStringView {
using ProfilerString8View = ProfilerStringView<char>; using ProfilerString8View = ProfilerStringView<char>;
using ProfilerString16View = ProfilerStringView<char16_t>; using ProfilerString16View = ProfilerStringView<char16_t>;
// The classes below are all embedded in a `MarkerOptions` object. // This compulsory marker parameter contains the required category information.
class MarkerOptions;
// This compulsory marker option contains the required category information.
class MarkerCategory { class MarkerCategory {
public: public:
// Constructor from category pair (aka sub-category) and category. // Constructor from category pair (includes both super- and sub-categories).
constexpr explicit MarkerCategory( constexpr explicit MarkerCategory(
baseprofiler::ProfilingCategoryPair aCategoryPair) baseprofiler::ProfilingCategoryPair aCategoryPair)
: mCategoryPair(aCategoryPair) {} : mCategoryPair(aCategoryPair) {}
// Returns the stored category pair.
constexpr baseprofiler::ProfilingCategoryPair CategoryPair() const { constexpr baseprofiler::ProfilingCategoryPair CategoryPair() const {
return mCategoryPair; return mCategoryPair;
} }
// Returns the super-category from the stored category pair.
baseprofiler::ProfilingCategory GetCategory() const { baseprofiler::ProfilingCategory GetCategory() const {
return GetProfilingCategoryPairInfo(mCategoryPair).mCategory; return GetProfilingCategoryPairInfo(mCategoryPair).mCategory;
} }
// Create a MarkerOptions object from this category and options.
// Definition under MarkerOptions below.
template <typename... Options>
MarkerOptions WithOptions(Options&&... aOptions) const;
private: private:
// The default constructor is only used during deserialization of
// MarkerOptions.
friend MarkerOptions;
constexpr MarkerCategory() = default;
friend ProfileBufferEntryReader::Deserializer<MarkerCategory>;
baseprofiler::ProfilingCategoryPair mCategoryPair = baseprofiler::ProfilingCategoryPair mCategoryPair =
baseprofiler::ProfilingCategoryPair::OTHER; baseprofiler::ProfilingCategoryPair::OTHER;
}; };
namespace baseprofiler::category { namespace baseprofiler::category {
// Each category-pair (aka subcategory) name constructs a MarkerCategory. // Each category pair name constructs a MarkerCategory.
// E.g.: mozilla::baseprofiler::category::OTHER_Profiling // E.g.: mozilla::baseprofiler::category::OTHER_Profiling
// Profiler macros will take the category name alone. // Profiler macros will take the category name alone without namespace.
// E.g.: `PROFILER_MARKER_UNTYPED("name", OTHER_Profiling)` // E.g.: `PROFILER_MARKER_UNTYPED("name", OTHER_Profiling)`
# define CATEGORY_ENUM_BEGIN_CATEGORY(name, labelAsString, color) # define CATEGORY_ENUM_BEGIN_CATEGORY(name, labelAsString, color)
# define CATEGORY_ENUM_SUBCATEGORY(supercategory, name, labelAsString) \ # define CATEGORY_ENUM_SUBCATEGORY(supercategory, name, labelAsString) \
@@ -267,12 +254,15 @@ MOZ_PROFILING_CATEGORY_LIST(CATEGORY_ENUM_BEGIN_CATEGORY,
// Import `MarkerCategory` into this namespace. This will allow using this type // Import `MarkerCategory` into this namespace. This will allow using this type
// dynamically in macros that prepend `::mozilla::baseprofiler::category::` to // dynamically in macros that prepend `::mozilla::baseprofiler::category::` to
// the given category, e.g.: E.g.: // the given category, e.g.:
// `PROFILER_MARKER_UNTYPED("name", MarkerCategory(...))` // `PROFILER_MARKER_UNTYPED("name", MarkerCategory(...))`
using MarkerCategory = ::mozilla::MarkerCategory; using MarkerCategory = ::mozilla::MarkerCategory;
} // namespace baseprofiler::category } // namespace baseprofiler::category
// The classes below are all embedded in a `MarkerOptions` object.
class MarkerOptions;
// This marker option captures a given thread id. // This marker option captures a given thread id.
// If left unspecified (by default construction) during the add-marker call, the // If left unspecified (by default construction) during the add-marker call, the
// current thread id will be used then. // current thread id will be used then.
@@ -585,22 +575,15 @@ class MarkerInnerWindowId {
uint64_t mInnerWindowId = scNoId; uint64_t mInnerWindowId = scNoId;
}; };
// This class combines a compulsory category with the above marker options. // This class combines each of the possible marker options above.
// To provide options to add-marker functions, first pick a MarkerCategory
// object, then options may be added with WithOptions(), e.g.:
// `mozilla::baseprofiler::category::OTHER_profiling`
// `mozilla::baseprofiler::category::DOM.WithOptions(
// MarkerThreadId(1), MarkerTiming::IntervalStart())`
class MarkerOptions { class MarkerOptions {
public: public:
// Implicit constructor from category. // Constructor from individual options (including none).
constexpr MOZ_IMPLICIT MarkerOptions(const MarkerCategory& aCategory) // Implicit to allow `{}` and one option type as-is.
: mCategory(aCategory) {} // Options that are not provided here are defaulted. In particular, timing
// defaults to `MarkerTiming::InstantNow()` when the marker is recorded.
// Constructor from category and other options.
template <typename... Options> template <typename... Options>
explicit MarkerOptions(const MarkerCategory& aCategory, Options&&... aOptions) MOZ_IMPLICIT MarkerOptions(Options&&... aOptions) {
: mCategory(aCategory) {
(Set(std::forward<Options>(aOptions)), ...); (Set(std::forward<Options>(aOptions)), ...);
} }
@@ -621,7 +604,6 @@ class MarkerOptions {
// `options.Set(MarkerThreadId(123)).Set(MarkerTiming::IntervalEnd())`. // `options.Set(MarkerThreadId(123)).Set(MarkerTiming::IntervalEnd())`.
// When passed to an add-marker function, it must be an rvalue, either created // When passed to an add-marker function, it must be an rvalue, either created
// on the spot, or `std::move`d from storage, e.g.: // on the spot, or `std::move`d from storage, e.g.:
// `PROFILER_MARKER_UNTYPED("...", OTHER.Set(...))`;
// `PROFILER_MARKER_UNTYPED("...", std::move(options).Set(...))`; // `PROFILER_MARKER_UNTYPED("...", std::move(options).Set(...))`;
// //
// Options can be read by their name (without "Marker"), e.g.: `o.ThreadId()`. // Options can be read by their name (without "Marker"), e.g.: `o.ThreadId()`.
@@ -641,7 +623,6 @@ class MarkerOptions {
\ \
Marker##NAME& NAME##Ref() { return m##NAME; } Marker##NAME& NAME##Ref() { return m##NAME; }
FUNCTIONS_ON_MEMBER(Category);
FUNCTIONS_ON_MEMBER(ThreadId); FUNCTIONS_ON_MEMBER(ThreadId);
FUNCTIONS_ON_MEMBER(Timing); FUNCTIONS_ON_MEMBER(Timing);
FUNCTIONS_ON_MEMBER(Stack); FUNCTIONS_ON_MEMBER(Stack);
@@ -651,31 +632,12 @@ class MarkerOptions {
private: private:
friend ProfileBufferEntryReader::Deserializer<MarkerOptions>; friend ProfileBufferEntryReader::Deserializer<MarkerOptions>;
// The default constructor is only used during deserialization.
constexpr MarkerOptions() = default;
MarkerCategory mCategory;
MarkerThreadId mThreadId; MarkerThreadId mThreadId;
MarkerTiming mTiming; MarkerTiming mTiming;
MarkerStack mStack; MarkerStack mStack;
MarkerInnerWindowId mInnerWindowId; MarkerInnerWindowId mInnerWindowId;
}; };
template <typename... Options>
MarkerOptions MarkerCategory::WithOptions(Options&&... aOptions) const {
return MarkerOptions(*this, std::forward<Options>(aOptions)...);
}
namespace baseprofiler::category {
// Import `MarkerOptions` into this namespace. This will allow using this type
// dynamically in macros that prepend `::mozilla::baseprofiler::category::` to
// the given category, e.g.: E.g.:
// `PROFILER_MARKER_UNTYPED("name", MarkerOptions(...))`
using MarkerOptions = ::mozilla::MarkerOptions;
} // namespace baseprofiler::category
} // namespace mozilla } // namespace mozilla
namespace mozilla::baseprofiler::markers { namespace mozilla::baseprofiler::markers {

View File

@@ -3340,8 +3340,8 @@ MOZ_NEVER_INLINE unsigned long long Fibonacci(unsigned long long n) {
} }
unsigned long long f1 = Fibonacci<NextDepth(DEPTH)>(n - 1); unsigned long long f1 = Fibonacci<NextDepth(DEPTH)>(n - 1);
if (DEPTH < MAX_MARKER_DEPTH) { if (DEPTH < MAX_MARKER_DEPTH) {
BASE_PROFILER_MARKER_TEXT( BASE_PROFILER_MARKER_TEXT("fib", OTHER,
"fib", OTHER.WithOptions(MarkerTiming::IntervalUntilNowFrom(start)), MarkerTiming::IntervalUntilNowFrom(start),
std::to_string(DEPTH)); std::to_string(DEPTH));
} }
return f2 + f1; return f2 + f1;
@@ -3387,8 +3387,7 @@ void TestProfiler() {
SleepMilli(5); SleepMilli(5);
auto cause = baseprofiler::profiler_capture_backtrace(); auto cause = baseprofiler::profiler_capture_backtrace();
AUTO_BASE_PROFILER_MARKER_TEXT( AUTO_BASE_PROFILER_MARKER_TEXT(
"fibonacci", "fibonacci", OTHER, MarkerStack::TakeBacktrace(std::move(cause)),
OTHER.WithOptions(MarkerStack::TakeBacktrace(std::move(cause))),
"First leaf call"); "First leaf call");
static const unsigned long long fibStart = 37; static const unsigned long long fibStart = 37;
printf("Fibonacci(%llu)...\n", fibStart); printf("Fibonacci(%llu)...\n", fibStart);
@@ -3401,7 +3400,7 @@ void TestProfiler() {
std::thread threadCancelFib([]() { std::thread threadCancelFib([]() {
AUTO_BASE_PROFILER_REGISTER_THREAD("fibonacci canceller"); AUTO_BASE_PROFILER_REGISTER_THREAD("fibonacci canceller");
SleepMilli(5); SleepMilli(5);
AUTO_BASE_PROFILER_MARKER_TEXT("fibonacci", OTHER, "Canceller"); AUTO_BASE_PROFILER_MARKER_TEXT("fibonacci", OTHER, {}, "Canceller");
static const int waitMaxSeconds = 10; static const int waitMaxSeconds = 10;
for (int i = 0; i < waitMaxSeconds; ++i) { for (int i = 0; i < waitMaxSeconds; ++i) {
if (sStopFibonacci) { if (sStopFibonacci) {
@@ -3418,14 +3417,14 @@ void TestProfiler() {
}); });
{ {
AUTO_BASE_PROFILER_MARKER_TEXT("main thread", OTHER, AUTO_BASE_PROFILER_MARKER_TEXT("main thread", OTHER, {},
"joining fibonacci thread"); "joining fibonacci thread");
AUTO_BASE_PROFILER_THREAD_SLEEP; AUTO_BASE_PROFILER_THREAD_SLEEP;
threadFib.join(); threadFib.join();
} }
{ {
AUTO_BASE_PROFILER_MARKER_TEXT("main thread", OTHER, AUTO_BASE_PROFILER_MARKER_TEXT("main thread", OTHER, {},
"joining fibonacci-canceller thread"); "joining fibonacci-canceller thread");
sStopFibonacci = true; sStopFibonacci = true;
AUTO_BASE_PROFILER_THREAD_SLEEP; AUTO_BASE_PROFILER_THREAD_SLEEP;
@@ -3451,18 +3450,14 @@ void TestProfiler() {
"operation", "source", "filename", TimeStamp::NowUnfuzzed(), "operation", "source", "filename", TimeStamp::NowUnfuzzed(),
TimeStamp::NowUnfuzzed(), std::move(cause))); TimeStamp::NowUnfuzzed(), std::move(cause)));
baseprofiler::AddMarker<mozilla::baseprofiler::markers::FileIO>( baseprofiler::AddMarker<mozilla::baseprofiler::markers::FileIO>(
"m2fileio", mozilla::baseprofiler::category::OTHER, "op2", "src2", "f2", "m2fileio", mozilla::baseprofiler::category::OTHER, {}, "op2", "src2",
MarkerThreadId{}); "f2", MarkerThreadId{});
baseprofiler::AddMarker<mozilla::baseprofiler::markers::FileIO>( baseprofiler::AddMarker<mozilla::baseprofiler::markers::FileIO>(
"m2fileio-capture", "m2fileio-capture", mozilla::baseprofiler::category::OTHER,
mozilla::baseprofiler::category::OTHER.WithOptions( MarkerStack::Capture(), "op2", "src2", "f2", MarkerThreadId{});
MarkerStack::Capture()),
"op2", "src2", "f2", MarkerThreadId{});
baseprofiler::AddMarker<mozilla::baseprofiler::markers::FileIO>( baseprofiler::AddMarker<mozilla::baseprofiler::markers::FileIO>(
"m2fileio-take-backtrace", "m2fileio-take-backtrace", mozilla::baseprofiler::category::OTHER,
mozilla::baseprofiler::category::OTHER.WithOptions( MarkerStack::TakeBacktrace(baseprofiler::profiler_capture_backtrace()),
MarkerStack::TakeBacktrace(
baseprofiler::profiler_capture_backtrace())),
"op2", "src2", "f2", MarkerThreadId{}); "op2", "src2", "f2", MarkerThreadId{});
baseprofiler::profiler_add_marker( baseprofiler::profiler_add_marker(
@@ -3493,66 +3488,107 @@ void TestProfiler() {
baseprofiler::LogMarkerPayload("module", "text", baseprofiler::LogMarkerPayload("module", "text",
TimeStamp::NowUnfuzzed())); TimeStamp::NowUnfuzzed()));
MOZ_RELEASE_ASSERT(baseprofiler::AddMarker( MOZ_RELEASE_ASSERT(
"markers 2.0 without options", mozilla::baseprofiler::category::OTHER)); baseprofiler::AddMarker("markers 2.0 without options (omitted)",
MOZ_RELEASE_ASSERT(baseprofiler::AddMarker(
"markers 2.0 with option",
mozilla::baseprofiler::category::OTHER.WithOptions(
MarkerInnerWindowId(123))));
MOZ_RELEASE_ASSERT(baseprofiler::AddMarker<>(
"default-templated markers 2.0 without options",
mozilla::baseprofiler::category::OTHER)); mozilla::baseprofiler::category::OTHER));
MOZ_RELEASE_ASSERT(baseprofiler::AddMarker<>( MOZ_RELEASE_ASSERT(baseprofiler::AddMarker(
"markers 2.0 without options (implicit brace-init)",
mozilla::baseprofiler::category::OTHER, {}));
MOZ_RELEASE_ASSERT(baseprofiler::AddMarker(
"markers 2.0 without options (explicit init)",
mozilla::baseprofiler::category::OTHER, MarkerOptions()));
MOZ_RELEASE_ASSERT(baseprofiler::AddMarker(
"markers 2.0 without options (explicit brace-init)",
mozilla::baseprofiler::category::OTHER, MarkerOptions{}));
MOZ_RELEASE_ASSERT(baseprofiler::AddMarker(
"markers 2.0 with one option (implicit)",
mozilla::baseprofiler::category::OTHER, MarkerInnerWindowId(123)));
MOZ_RELEASE_ASSERT(baseprofiler::AddMarker(
"markers 2.0 with one option (implicit brace-init)",
mozilla::baseprofiler::category::OTHER, {MarkerInnerWindowId(123)}));
MOZ_RELEASE_ASSERT(
baseprofiler::AddMarker("markers 2.0 with one option (explicit init)",
mozilla::baseprofiler::category::OTHER,
MarkerOptions(MarkerInnerWindowId(123))));
MOZ_RELEASE_ASSERT(baseprofiler::AddMarker(
"markers 2.0 with one option (explicit brace-init)",
mozilla::baseprofiler::category::OTHER,
MarkerOptions{MarkerInnerWindowId(123)}));
MOZ_RELEASE_ASSERT(baseprofiler::AddMarker(
"markers 2.0 with two options (implicit brace-init)",
mozilla::baseprofiler::category::OTHER,
{MarkerInnerWindowId(123), MarkerStack::Capture()}));
MOZ_RELEASE_ASSERT(baseprofiler::AddMarker(
"markers 2.0 with two options (explicit init)",
mozilla::baseprofiler::category::OTHER,
MarkerOptions(MarkerInnerWindowId(123), MarkerStack::Capture())));
MOZ_RELEASE_ASSERT(baseprofiler::AddMarker(
"markers 2.0 with two options (explicit brace-init)",
mozilla::baseprofiler::category::OTHER,
MarkerOptions{MarkerInnerWindowId(123), MarkerStack::Capture()}));
MOZ_RELEASE_ASSERT(
baseprofiler::AddMarker("default-templated markers 2.0 without options",
mozilla::baseprofiler::category::OTHER));
MOZ_RELEASE_ASSERT(baseprofiler::AddMarker(
"default-templated markers 2.0 with option", "default-templated markers 2.0 with option",
mozilla::baseprofiler::category::OTHER.WithOptions( mozilla::baseprofiler::category::OTHER, MarkerInnerWindowId(123)));
MarkerInnerWindowId(123))));
MOZ_RELEASE_ASSERT( MOZ_RELEASE_ASSERT(
baseprofiler::AddMarker<::mozilla::baseprofiler::markers::NoPayload>( baseprofiler::AddMarker<::mozilla::baseprofiler::markers::NoPayload>(
"explicitly-default-templated markers 2.0 without options", "explicitly-default-templated markers 2.0 without options",
mozilla::baseprofiler::category::OTHER)); mozilla::baseprofiler::category::OTHER, {}));
MOZ_RELEASE_ASSERT( MOZ_RELEASE_ASSERT(
baseprofiler::AddMarker<::mozilla::baseprofiler::markers::NoPayload>( baseprofiler::AddMarker<::mozilla::baseprofiler::markers::NoPayload>(
"explicitly-default-templated markers 2.0 with option", "explicitly-default-templated markers 2.0 with option",
mozilla::baseprofiler::category::OTHER.WithOptions( mozilla::baseprofiler::category::OTHER, MarkerInnerWindowId(123)));
MarkerInnerWindowId(123))));
MOZ_RELEASE_ASSERT( MOZ_RELEASE_ASSERT(
baseprofiler::AddMarker<mozilla::baseprofiler::markers::Tracing>( baseprofiler::AddMarker<mozilla::baseprofiler::markers::Tracing>(
"tracing", mozilla::baseprofiler::category::OTHER, "category")); "tracing", mozilla::baseprofiler::category::OTHER, {}, "category"));
MOZ_RELEASE_ASSERT( MOZ_RELEASE_ASSERT(
baseprofiler::AddMarker<mozilla::baseprofiler::markers::UserTimingMark>( baseprofiler::AddMarker<mozilla::baseprofiler::markers::UserTimingMark>(
"mark", mozilla::baseprofiler::category::OTHER, "mark name")); "mark", mozilla::baseprofiler::category::OTHER, {}, "mark name"));
MOZ_RELEASE_ASSERT(baseprofiler::AddMarker< MOZ_RELEASE_ASSERT(baseprofiler::AddMarker<
mozilla::baseprofiler::markers::UserTimingMeasure>( mozilla::baseprofiler::markers::UserTimingMeasure>(
"measure", mozilla::baseprofiler::category::OTHER, "measure name", "measure", mozilla::baseprofiler::category::OTHER, {}, "measure name",
Some(ProfilerString8View("start")), Some(ProfilerString8View("end")))); Some(ProfilerString8View("start")), Some(ProfilerString8View("end"))));
MOZ_RELEASE_ASSERT( MOZ_RELEASE_ASSERT(
baseprofiler::AddMarker<mozilla::baseprofiler::markers::Hang>( baseprofiler::AddMarker<mozilla::baseprofiler::markers::Hang>(
"hang", mozilla::baseprofiler::category::OTHER)); "hang", mozilla::baseprofiler::category::OTHER, {}));
MOZ_RELEASE_ASSERT( MOZ_RELEASE_ASSERT(
baseprofiler::AddMarker<mozilla::baseprofiler::markers::LongTask>( baseprofiler::AddMarker<mozilla::baseprofiler::markers::LongTask>(
"longtask", mozilla::baseprofiler::category::OTHER)); "longtask", mozilla::baseprofiler::category::OTHER, {}));
MOZ_RELEASE_ASSERT( MOZ_RELEASE_ASSERT(
baseprofiler::AddMarker<mozilla::baseprofiler::markers::Text>( baseprofiler::AddMarker<mozilla::baseprofiler::markers::Text>(
"text", mozilla::baseprofiler::category::OTHER, "text text")); "text", mozilla::baseprofiler::category::OTHER, {}, "text text"));
MOZ_RELEASE_ASSERT( MOZ_RELEASE_ASSERT(
baseprofiler::AddMarker<mozilla::baseprofiler::markers::Log>( baseprofiler::AddMarker<mozilla::baseprofiler::markers::Log>(
"log", mozilla::baseprofiler::category::OTHER, "module", "text")); "log", mozilla::baseprofiler::category::OTHER, {}, "module",
"text"));
MOZ_RELEASE_ASSERT( MOZ_RELEASE_ASSERT(
baseprofiler::AddMarker<mozilla::baseprofiler::markers::MediaSample>( baseprofiler::AddMarker<mozilla::baseprofiler::markers::MediaSample>(
"media sample", mozilla::baseprofiler::category::OTHER, 123, 456)); "media sample", mozilla::baseprofiler::category::OTHER, {}, 123,
456));
printf("Sleep 1s...\n"); printf("Sleep 1s...\n");
{ {
@@ -3703,12 +3739,6 @@ void TestMarkerCategory() {
# undef CATEGORY_ENUM_SUBCATEGORY # undef CATEGORY_ENUM_SUBCATEGORY
# undef CATEGORY_ENUM_END_CATEGORY # undef CATEGORY_ENUM_END_CATEGORY
static_assert(
std::is_same_v<decltype(
std::declval<mozilla::MarkerCategory>().WithOptions()),
mozilla::MarkerOptions>,
"MarkerCategory::WithOptions() should return a MarkerOptions");
printf("TestMarkerCategory done\n"); printf("TestMarkerCategory done\n");
} }
@@ -3720,22 +3750,22 @@ void TestMarkerNoPayload() {
mozilla::ProfileChunkedBuffer::ThreadSafety::WithoutMutex, chunkManager); mozilla::ProfileChunkedBuffer::ThreadSafety::WithoutMutex, chunkManager);
mozilla::ProfileBufferBlockIndex i0 = mozilla::ProfileBufferBlockIndex i0 =
mozilla::baseprofiler::AddMarkerToBuffer<>( mozilla::baseprofiler::AddMarkerToBuffer(
buffer, "literal", mozilla::baseprofiler::category::OTHER_Profiling); buffer, "literal", mozilla::baseprofiler::category::OTHER_Profiling);
MOZ_RELEASE_ASSERT(i0); MOZ_RELEASE_ASSERT(i0);
const std::string dynamic = "dynamic"; const std::string dynamic = "dynamic";
mozilla::ProfileBufferBlockIndex i1 = mozilla::ProfileBufferBlockIndex i1 =
mozilla::baseprofiler::AddMarkerToBuffer<>( mozilla::baseprofiler::AddMarkerToBuffer(
buffer, dynamic, buffer, dynamic,
mozilla::baseprofiler::category::GRAPHICS_FlushingAsyncPaints); mozilla::baseprofiler::category::GRAPHICS_FlushingAsyncPaints, {});
MOZ_RELEASE_ASSERT(i1); MOZ_RELEASE_ASSERT(i1);
MOZ_RELEASE_ASSERT(i1 > i0); MOZ_RELEASE_ASSERT(i1 > i0);
mozilla::ProfileBufferBlockIndex i2 = mozilla::ProfileBufferBlockIndex i2 =
mozilla::baseprofiler::AddMarkerToBuffer<>( mozilla::baseprofiler::AddMarkerToBuffer(
buffer, std::string_view("string_view"), buffer, std::string_view("string_view"),
mozilla::baseprofiler::category::GRAPHICS_FlushingAsyncPaints); mozilla::baseprofiler::category::GRAPHICS_FlushingAsyncPaints, {});
MOZ_RELEASE_ASSERT(i2); MOZ_RELEASE_ASSERT(i2);
MOZ_RELEASE_ASSERT(i2 > i1); MOZ_RELEASE_ASSERT(i2 > i1);
@@ -3769,69 +3799,59 @@ void TestUserMarker() {
MOZ_RELEASE_ASSERT( MOZ_RELEASE_ASSERT(
mozilla::baseprofiler::AddMarkerToBuffer<MarkerTypeTestMinimal>( mozilla::baseprofiler::AddMarkerToBuffer<MarkerTypeTestMinimal>(
buffer, "test2", mozilla::baseprofiler::category::OTHER_Profiling, buffer, "test2", mozilla::baseprofiler::category::OTHER_Profiling, {},
std::string("payload text"))); std::string("payload text")));
MOZ_RELEASE_ASSERT( MOZ_RELEASE_ASSERT(
mozilla::baseprofiler::AddMarkerToBuffer<MarkerTypeTestMinimal>( mozilla::baseprofiler::AddMarkerToBuffer<MarkerTypeTestMinimal>(
buffer, "test2", buffer, "test2", mozilla::baseprofiler::category::OTHER_Profiling,
mozilla::baseprofiler::category::OTHER_Profiling.WithOptions( mozilla::MarkerThreadId(123), std::string("ThreadId(123)")));
mozilla::MarkerThreadId(123)),
std::string("ThreadId(123)")));
auto start = mozilla::TimeStamp::NowUnfuzzed(); auto start = mozilla::TimeStamp::NowUnfuzzed();
MOZ_RELEASE_ASSERT( MOZ_RELEASE_ASSERT(
mozilla::baseprofiler::AddMarkerToBuffer<MarkerTypeTestMinimal>( mozilla::baseprofiler::AddMarkerToBuffer<MarkerTypeTestMinimal>(
buffer, "test2", buffer, "test2", mozilla::baseprofiler::category::OTHER_Profiling,
mozilla::baseprofiler::category::OTHER_Profiling.WithOptions( mozilla::MarkerTiming::InstantAt(start),
mozilla::MarkerTiming::InstantAt(start)),
std::string("InstantAt(start)"))); std::string("InstantAt(start)")));
auto then = mozilla::TimeStamp::NowUnfuzzed(); auto then = mozilla::TimeStamp::NowUnfuzzed();
MOZ_RELEASE_ASSERT( MOZ_RELEASE_ASSERT(
mozilla::baseprofiler::AddMarkerToBuffer<MarkerTypeTestMinimal>( mozilla::baseprofiler::AddMarkerToBuffer<MarkerTypeTestMinimal>(
buffer, "test2", buffer, "test2", mozilla::baseprofiler::category::OTHER_Profiling,
mozilla::baseprofiler::category::OTHER_Profiling.WithOptions( mozilla::MarkerTiming::IntervalStart(start),
mozilla::MarkerTiming::IntervalStart(start)),
std::string("IntervalStart(start)"))); std::string("IntervalStart(start)")));
MOZ_RELEASE_ASSERT( MOZ_RELEASE_ASSERT(
mozilla::baseprofiler::AddMarkerToBuffer<MarkerTypeTestMinimal>( mozilla::baseprofiler::AddMarkerToBuffer<MarkerTypeTestMinimal>(
buffer, "test2", buffer, "test2", mozilla::baseprofiler::category::OTHER_Profiling,
mozilla::baseprofiler::category::OTHER_Profiling.WithOptions( mozilla::MarkerTiming::IntervalEnd(then),
mozilla::MarkerTiming::IntervalEnd(then)),
std::string("IntervalEnd(then)"))); std::string("IntervalEnd(then)")));
MOZ_RELEASE_ASSERT( MOZ_RELEASE_ASSERT(
mozilla::baseprofiler::AddMarkerToBuffer<MarkerTypeTestMinimal>( mozilla::baseprofiler::AddMarkerToBuffer<MarkerTypeTestMinimal>(
buffer, "test2", buffer, "test2", mozilla::baseprofiler::category::OTHER_Profiling,
mozilla::baseprofiler::category::OTHER_Profiling.WithOptions( mozilla::MarkerTiming::Interval(start, then),
mozilla::MarkerTiming::Interval(start, then)),
std::string("Interval(start, then)"))); std::string("Interval(start, then)")));
MOZ_RELEASE_ASSERT( MOZ_RELEASE_ASSERT(
mozilla::baseprofiler::AddMarkerToBuffer<MarkerTypeTestMinimal>( mozilla::baseprofiler::AddMarkerToBuffer<MarkerTypeTestMinimal>(
buffer, "test2", buffer, "test2", mozilla::baseprofiler::category::OTHER_Profiling,
mozilla::baseprofiler::category::OTHER_Profiling.WithOptions( mozilla::MarkerTiming::IntervalUntilNowFrom(start),
mozilla::MarkerTiming::IntervalUntilNowFrom(start)),
std::string("IntervalUntilNowFrom(start)"))); std::string("IntervalUntilNowFrom(start)")));
MOZ_RELEASE_ASSERT( MOZ_RELEASE_ASSERT(
mozilla::baseprofiler::AddMarkerToBuffer<MarkerTypeTestMinimal>( mozilla::baseprofiler::AddMarkerToBuffer<MarkerTypeTestMinimal>(
buffer, "test2", buffer, "test2", mozilla::baseprofiler::category::OTHER_Profiling,
mozilla::baseprofiler::category::OTHER_Profiling.WithOptions( mozilla::MarkerStack::NoStack(), std::string("NoStack")));
mozilla::MarkerStack::NoStack()),
std::string("NoStack")));
// Note: We cannot test stack-capture here, because the profiler is not // Note: We cannot test stack-capture here, because the profiler is not
// initialized. // initialized.
MOZ_RELEASE_ASSERT( MOZ_RELEASE_ASSERT(
mozilla::baseprofiler::AddMarkerToBuffer<MarkerTypeTestMinimal>( mozilla::baseprofiler::AddMarkerToBuffer<MarkerTypeTestMinimal>(
buffer, "test2", buffer, "test2", mozilla::baseprofiler::category::OTHER_Profiling,
mozilla::baseprofiler::category::OTHER_Profiling.WithOptions( mozilla::MarkerInnerWindowId(123),
mozilla::MarkerInnerWindowId(123)),
std::string("InnerWindowId(123)"))); std::string("InnerWindowId(123)")));
# ifdef DEBUG # ifdef DEBUG
@@ -3865,44 +3885,44 @@ void TestPredefinedMarkers() {
MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer< MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer<
mozilla::baseprofiler::markers::Tracing>( mozilla::baseprofiler::markers::Tracing>(
buffer, std::string_view("tracing"), buffer, std::string_view("tracing"),
mozilla::baseprofiler::category::OTHER, "category")); mozilla::baseprofiler::category::OTHER, {}, "category"));
MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer< MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer<
mozilla::baseprofiler::markers::UserTimingMark>( mozilla::baseprofiler::markers::UserTimingMark>(
buffer, std::string_view("mark"), mozilla::baseprofiler::category::OTHER, buffer, std::string_view("mark"), mozilla::baseprofiler::category::OTHER,
"mark name")); {}, "mark name"));
MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer< MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer<
mozilla::baseprofiler::markers::UserTimingMeasure>( mozilla::baseprofiler::markers::UserTimingMeasure>(
buffer, std::string_view("measure"), buffer, std::string_view("measure"),
mozilla::baseprofiler::category::OTHER, "measure name ", mozilla::baseprofiler::category::OTHER, {}, "measure name ",
mozilla::Some(mozilla::ProfilerString8View(" start ")), mozilla::Some(mozilla::ProfilerString8View(" start ")),
mozilla::Some(mozilla::ProfilerString8View("end")))); mozilla::Some(mozilla::ProfilerString8View("end"))));
MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer< MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer<
mozilla::baseprofiler::markers::Hang>( mozilla::baseprofiler::markers::Hang>(
buffer, std::string_view("hang"), buffer, std::string_view("hang"), mozilla::baseprofiler::category::OTHER,
mozilla::baseprofiler::category::OTHER)); {}));
MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer< MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer<
mozilla::baseprofiler::markers::LongTask>( mozilla::baseprofiler::markers::LongTask>(
buffer, std::string_view("long task"), buffer, std::string_view("long task"),
mozilla::baseprofiler::category::OTHER)); mozilla::baseprofiler::category::OTHER, {}));
MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer< MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer<
mozilla::baseprofiler::markers::Text>( mozilla::baseprofiler::markers::Text>(
buffer, std::string_view("text"), mozilla::baseprofiler::category::OTHER, buffer, std::string_view("text"), mozilla::baseprofiler::category::OTHER,
"text text")); {}, "text text"));
MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer< MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer<
mozilla::baseprofiler::markers::Log>( mozilla::baseprofiler::markers::Log>(
buffer, std::string_view("log"), mozilla::baseprofiler::category::OTHER, buffer, std::string_view("log"), mozilla::baseprofiler::category::OTHER,
"module", "text")); {}, "module", "text"));
MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer< MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer<
mozilla::baseprofiler::markers::MediaSample>( mozilla::baseprofiler::markers::MediaSample>(
buffer, std::string_view("media"), mozilla::baseprofiler::category::OTHER, buffer, std::string_view("media"), mozilla::baseprofiler::category::OTHER,
123, 456)); {}, 123, 456));
# ifdef DEBUG # ifdef DEBUG
buffer.Dump(); buffer.Dump();
@@ -3944,7 +3964,7 @@ void TestProfiler() {
# ifndef AUTO_BASE_PROFILER_MARKER_TEXT # ifndef AUTO_BASE_PROFILER_MARKER_TEXT
# error AUTO_BASE_PROFILER_MARKER_TEXT not #defined # error AUTO_BASE_PROFILER_MARKER_TEXT not #defined
# endif // AUTO_BASE_PROFILER_MARKER_TEXT # endif // AUTO_BASE_PROFILER_MARKER_TEXT
AUTO_BASE_PROFILER_MARKER_TEXT(catch, catch, catch); AUTO_BASE_PROFILER_MARKER_TEXT(catch, catch, catch, catch);
# ifndef AUTO_BASE_PROFILER_LABEL # ifndef AUTO_BASE_PROFILER_LABEL
# error AUTO_BASE_PROFILER_LABEL not #defined # error AUTO_BASE_PROFILER_LABEL not #defined
@@ -3960,17 +3980,18 @@ void TestProfiler() {
# error BASE_PROFILER_MARKER_UNTYPED not #defined # error BASE_PROFILER_MARKER_UNTYPED not #defined
# endif // BASE_PROFILER_MARKER_UNTYPED # endif // BASE_PROFILER_MARKER_UNTYPED
BASE_PROFILER_MARKER_UNTYPED(catch, catch); BASE_PROFILER_MARKER_UNTYPED(catch, catch);
BASE_PROFILER_MARKER_UNTYPED(catch, catch, catch);
# ifndef BASE_PROFILER_MARKER # ifndef BASE_PROFILER_MARKER
# error BASE_PROFILER_MARKER not #defined # error BASE_PROFILER_MARKER not #defined
# endif // BASE_PROFILER_MARKER # endif // BASE_PROFILER_MARKER
BASE_PROFILER_MARKER(catch, catch, catch);
BASE_PROFILER_MARKER(catch, catch, catch, catch); BASE_PROFILER_MARKER(catch, catch, catch, catch);
BASE_PROFILER_MARKER(catch, catch, catch, catch, catch);
# ifndef BASE_PROFILER_MARKER_TEXT # ifndef BASE_PROFILER_MARKER_TEXT
# error BASE_PROFILER_MARKER_TEXT not #defined # error BASE_PROFILER_MARKER_TEXT not #defined
# endif // BASE_PROFILER_MARKER_TEXT # endif // BASE_PROFILER_MARKER_TEXT
BASE_PROFILER_MARKER_TEXT(catch, catch, catch); BASE_PROFILER_MARKER_TEXT(catch, catch, catch, catch);
MOZ_RELEASE_ASSERT(!mozilla::baseprofiler::profiler_get_backtrace(), MOZ_RELEASE_ASSERT(!mozilla::baseprofiler::profiler_get_backtrace(),
"profiler_get_backtrace should return nullptr"); "profiler_get_backtrace should return nullptr");

View File

@@ -265,9 +265,8 @@ void ChannelWrapper::Resume(const nsCString& aText, ErrorResult& aRv) {
if (nsCOMPtr<nsIChannel> chan = MaybeChannel()) { if (nsCOMPtr<nsIChannel> chan = MaybeChannel()) {
rv = chan->Resume(); rv = chan->Resume();
PROFILER_MARKER_TEXT( PROFILER_MARKER_TEXT("Extension Suspend", NETWORK,
"Extension Suspend", MarkerTiming::IntervalUntilNowFrom(mSuspendTime),
NETWORK.WithOptions(MarkerTiming::IntervalUntilNowFrom(mSuspendTime)),
aText); aText);
} }
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {

View File

@@ -341,9 +341,8 @@ int32_t Timers::Finish(JSContext* aCx, const nsAString& aHistogram,
markerText.AppendLiteral(":"); markerText.AppendLiteral(":");
markerText.Append(NS_ConvertUTF16toUTF8(aKey)); markerText.Append(NS_ConvertUTF16toUTF8(aKey));
} }
PROFILER_MARKER_TEXT( PROFILER_MARKER_TEXT("TelemetryStopwatch", OTHER,
"TelemetryStopwatch", MarkerTiming::IntervalUntilNowFrom(timer->StartTime()),
OTHER.WithOptions(MarkerTiming::IntervalUntilNowFrom(timer->StartTime())),
markerText); markerText);
#endif #endif
if (NS_FAILED(rv) && rv != NS_ERROR_NOT_AVAILABLE && !mSuppressErrors) { if (NS_FAILED(rv) && rv != NS_ERROR_NOT_AVAILABLE && !mSuppressErrors) {

View File

@@ -40,10 +40,10 @@
#ifndef MOZ_GECKO_PROFILER #ifndef MOZ_GECKO_PROFILER
# define PROFILER_MARKER_UNTYPED(markerName, options) # define PROFILER_MARKER_UNTYPED(markerName, categoryName, ...)
# define PROFILER_MARKER(markerName, options, MarkerType, ...) # define PROFILER_MARKER(markerName, categoryName, options, MarkerType, ...)
# define PROFILER_MARKER_TEXT(markerName, options, text) # define PROFILER_MARKER_TEXT(markerName, categoryName, options, text)
# define AUTO_PROFILER_MARKER_TEXT(markerName, options, text) # define AUTO_PROFILER_MARKER_TEXT(markerName, categoryName, options, text)
#else // ndef MOZ_GECKO_PROFILER #else // ndef MOZ_GECKO_PROFILER
@@ -53,41 +53,62 @@ namespace geckoprofiler::category {
using namespace ::mozilla::baseprofiler::category; using namespace ::mozilla::baseprofiler::category;
} }
template <typename MarkerType = ::mozilla::baseprofiler::markers::NoPayload, template <typename MarkerType, typename... Ts>
typename... Ts>
mozilla::ProfileBufferBlockIndex AddMarkerToBuffer( mozilla::ProfileBufferBlockIndex AddMarkerToBuffer(
mozilla::ProfileChunkedBuffer& aBuffer, mozilla::ProfileChunkedBuffer& aBuffer,
const mozilla::ProfilerString8View& aName, const mozilla::ProfilerString8View& aName,
mozilla::MarkerOptions&& aOptions, const Ts&... aTs) { const mozilla::MarkerCategory& aCategory, mozilla::MarkerOptions&& aOptions,
const Ts&... aTs) {
return mozilla::base_profiler_markers_detail::AddMarkerToBuffer<MarkerType>( return mozilla::base_profiler_markers_detail::AddMarkerToBuffer<MarkerType>(
aBuffer, aName, std::move(aOptions), ::profiler_capture_backtrace_into, aBuffer, aName, aCategory, std::move(aOptions),
aTs...); ::profiler_capture_backtrace_into, aTs...);
} }
template <typename MarkerType = ::mozilla::baseprofiler::markers::NoPayload, // Add a marker (without payload) to a given buffer.
typename... Ts> inline mozilla::ProfileBufferBlockIndex AddMarkerToBuffer(
mozilla::ProfileChunkedBuffer& aBuffer,
const mozilla::ProfilerString8View& aName,
const mozilla::MarkerCategory& aCategory,
mozilla::MarkerOptions&& aOptions = {}) {
return AddMarkerToBuffer<mozilla::baseprofiler::markers::NoPayload>(
aBuffer, aName, aCategory, std::move(aOptions));
}
template <typename MarkerType, typename... Ts>
mozilla::ProfileBufferBlockIndex profiler_add_marker( mozilla::ProfileBufferBlockIndex profiler_add_marker(
const mozilla::ProfilerString8View& aName, const mozilla::ProfilerString8View& aName,
mozilla::MarkerOptions&& aOptions, const Ts&... aTs) { const mozilla::MarkerCategory& aCategory, mozilla::MarkerOptions&& aOptions,
const Ts&... aTs) {
if (!profiler_can_accept_markers()) { if (!profiler_can_accept_markers()) {
return {}; return {};
} }
return ::AddMarkerToBuffer<MarkerType>( return ::AddMarkerToBuffer<MarkerType>(
profiler_markers_detail::CachedCoreBuffer(), aName, std::move(aOptions), profiler_markers_detail::CachedCoreBuffer(), aName, aCategory,
aTs...); std::move(aOptions), aTs...);
} }
# define PROFILER_MARKER_UNTYPED(markerName, options) \ // Add a marker (without payload) to the Gecko Profiler buffer.
inline mozilla::ProfileBufferBlockIndex profiler_add_marker(
const mozilla::ProfilerString8View& aName,
const mozilla::MarkerCategory& aCategory,
mozilla::MarkerOptions&& aOptions = {}) {
return profiler_add_marker<mozilla::baseprofiler::markers::NoPayload>(
aName, aCategory, std::move(aOptions));
}
# define PROFILER_MARKER_UNTYPED(markerName, categoryName, ...) \
do { \ do { \
AUTO_PROFILER_STATS(PROFILER_MARKER_UNTYPED); \ AUTO_PROFILER_STATS(PROFILER_MARKER_UNTYPED); \
::profiler_add_marker<>(markerName, ::geckoprofiler::category::options); \ ::profiler_add_marker( \
markerName, ::geckoprofiler::category::categoryName, ##__VA_ARGS__); \
} while (false) } while (false)
# define PROFILER_MARKER(markerName, options, MarkerType, ...) \ # define PROFILER_MARKER(markerName, categoryName, options, MarkerType, ...) \
do { \ do { \
AUTO_PROFILER_STATS(PROFILER_MARKER_with_##MarkerType); \ AUTO_PROFILER_STATS(PROFILER_MARKER_with_##MarkerType); \
::profiler_add_marker<::geckoprofiler::markers::MarkerType>( \ ::profiler_add_marker<::geckoprofiler::markers::MarkerType>( \
markerName, ::geckoprofiler::category::options, ##__VA_ARGS__); \ markerName, ::geckoprofiler::category::categoryName, options, \
##__VA_ARGS__); \
} while (false) } while (false)
namespace geckoprofiler::markers { namespace geckoprofiler::markers {
@@ -95,11 +116,11 @@ namespace geckoprofiler::markers {
using Text = ::mozilla::baseprofiler::markers::Text; using Text = ::mozilla::baseprofiler::markers::Text;
} // namespace geckoprofiler::markers } // namespace geckoprofiler::markers
# define PROFILER_MARKER_TEXT(markerName, options, text) \ # define PROFILER_MARKER_TEXT(markerName, categoryName, options, text) \
do { \ do { \
AUTO_PROFILER_STATS(PROFILER_MARKER_TEXT); \ AUTO_PROFILER_STATS(PROFILER_MARKER_TEXT); \
::profiler_add_marker<::geckoprofiler::markers::Text>( \ ::profiler_add_marker<::geckoprofiler::markers::Text>( \
markerName, ::geckoprofiler::category::options, text); \ markerName, ::geckoprofiler::category::categoryName, options, text); \
} while (false) } while (false)
// RAII object that adds a PROFILER_MARKER_TEXT when destroyed; the marker's // RAII object that adds a PROFILER_MARKER_TEXT when destroyed; the marker's
@@ -108,9 +129,13 @@ using Text = ::mozilla::baseprofiler::markers::Text;
class MOZ_RAII AutoProfilerTextMarker { class MOZ_RAII AutoProfilerTextMarker {
public: public:
AutoProfilerTextMarker(const char* aMarkerName, AutoProfilerTextMarker(const char* aMarkerName,
const mozilla::MarkerCategory& aCategory,
mozilla::MarkerOptions&& aOptions, mozilla::MarkerOptions&& aOptions,
const nsACString& aText) const nsACString& aText)
: mMarkerName(aMarkerName), mOptions(std::move(aOptions)), mText(aText) { : mMarkerName(aMarkerName),
mCategory(aCategory),
mOptions(std::move(aOptions)),
mText(aText) {
MOZ_ASSERT(mOptions.Timing().EndTime().IsNull(), MOZ_ASSERT(mOptions.Timing().EndTime().IsNull(),
"AutoProfilerTextMarker options shouldn't have an end time"); "AutoProfilerTextMarker options shouldn't have an end time");
if (mOptions.Timing().StartTime().IsNull()) { if (mOptions.Timing().StartTime().IsNull()) {
@@ -120,20 +145,23 @@ class MOZ_RAII AutoProfilerTextMarker {
~AutoProfilerTextMarker() { ~AutoProfilerTextMarker() {
mOptions.TimingRef().SetIntervalEnd(); mOptions.TimingRef().SetIntervalEnd();
PROFILER_MARKER_TEXT( AUTO_PROFILER_STATS(AUTO_PROFILER_MARKER_TEXT);
profiler_add_marker<geckoprofiler::markers::Text>(
mozilla::ProfilerString8View::WrapNullTerminatedString(mMarkerName), mozilla::ProfilerString8View::WrapNullTerminatedString(mMarkerName),
MarkerOptions(std::move(mOptions)), mText); mCategory, std::move(mOptions), mText);
} }
protected: protected:
const char* mMarkerName; const char* mMarkerName;
mozilla::MarkerCategory mCategory;
mozilla::MarkerOptions mOptions; mozilla::MarkerOptions mOptions;
nsCString mText; nsCString mText;
}; };
# define AUTO_PROFILER_MARKER_TEXT(markerName, options, text) \ # define AUTO_PROFILER_MARKER_TEXT(markerName, categoryName, options, text) \
AutoProfilerTextMarker PROFILER_RAII( \ AutoProfilerTextMarker PROFILER_RAII( \
markerName, ::mozilla::baseprofiler::category::options, text) markerName, ::mozilla::baseprofiler::category::categoryName, options, \
text)
#endif // nfed MOZ_GECKO_PROFILER else #endif // nfed MOZ_GECKO_PROFILER else

View File

@@ -523,7 +523,7 @@ TEST(GeckoProfiler, Pause)
// Check that we are writing markers while not paused. // Check that we are writing markers while not paused.
info1 = profiler_get_buffer_info(); info1 = profiler_get_buffer_info();
PROFILER_MARKER_UNTYPED("Not paused", OTHER); PROFILER_MARKER_UNTYPED("Not paused", OTHER, {});
info2 = profiler_get_buffer_info(); info2 = profiler_get_buffer_info();
ASSERT_TRUE(info1->mRangeEnd != info2->mRangeEnd); ASSERT_TRUE(info1->mRangeEnd != info2->mRangeEnd);
@@ -540,10 +540,10 @@ TEST(GeckoProfiler, Pause)
// Check that we are now writing markers while paused. // Check that we are now writing markers while paused.
info1 = profiler_get_buffer_info(); info1 = profiler_get_buffer_info();
PROFILER_MARKER_UNTYPED("Paused", OTHER); PROFILER_MARKER_UNTYPED("Paused", OTHER, {});
info2 = profiler_get_buffer_info(); info2 = profiler_get_buffer_info();
ASSERT_TRUE(info1->mRangeEnd == info2->mRangeEnd); ASSERT_TRUE(info1->mRangeEnd == info2->mRangeEnd);
PROFILER_MARKER_UNTYPED("Paused v2", OTHER); PROFILER_MARKER_UNTYPED("Paused v2", OTHER, {});
Maybe<ProfilerBufferInfo> info3 = profiler_get_buffer_info(); Maybe<ProfilerBufferInfo> info3 = profiler_get_buffer_info();
ASSERT_TRUE(info2->mRangeEnd == info3->mRangeEnd); ASSERT_TRUE(info2->mRangeEnd == info3->mRangeEnd);
@@ -650,10 +650,10 @@ TEST(GeckoProfiler, Markers)
{ AUTO_PROFILER_TRACING_MARKER("C", "auto tracing", OTHER); } { AUTO_PROFILER_TRACING_MARKER("C", "auto tracing", OTHER); }
PROFILER_MARKER_UNTYPED("M1", OTHER); PROFILER_MARKER_UNTYPED("M1", OTHER, {});
PROFILER_ADD_MARKER_WITH_PAYLOAD("M2", OTHER, TracingMarkerPayload, PROFILER_ADD_MARKER_WITH_PAYLOAD("M2", OTHER, TracingMarkerPayload,
("C", TRACING_EVENT, ts0)); ("C", TRACING_EVENT, ts0));
PROFILER_MARKER_UNTYPED("M3", OTHER); PROFILER_MARKER_UNTYPED("M3", OTHER, {});
PROFILER_ADD_MARKER_WITH_PAYLOAD( PROFILER_ADD_MARKER_WITH_PAYLOAD(
"M4", OTHER, TracingMarkerPayload, "M4", OTHER, TracingMarkerPayload,
("C", TRACING_EVENT, ts0, mozilla::Nothing(), profiler_get_backtrace())); ("C", TRACING_EVENT, ts0, mozilla::Nothing(), profiler_get_backtrace()));
@@ -704,19 +704,19 @@ TEST(GeckoProfiler, Markers)
// Test basic markers 2.0. // Test basic markers 2.0.
MOZ_RELEASE_ASSERT( MOZ_RELEASE_ASSERT(
profiler_add_marker<>("default-templated markers 2.0 with empty options", profiler_add_marker("default-templated markers 2.0 with empty options",
geckoprofiler::category::OTHER)); geckoprofiler::category::OTHER, {}));
PROFILER_MARKER_UNTYPED("default-templated markers 2.0 with option", PROFILER_MARKER_UNTYPED(
OTHER.WithOptions(MarkerStack::TakeBacktrace( "default-templated markers 2.0 with option", OTHER,
profiler_capture_backtrace()))); MarkerStack::TakeBacktrace(profiler_capture_backtrace()));
PROFILER_MARKER("explicitly-default-templated markers 2.0 with empty options", PROFILER_MARKER("explicitly-default-templated markers 2.0 with empty options",
OTHER, NoPayload); OTHER, {}, NoPayload);
MOZ_RELEASE_ASSERT(profiler_add_marker<::geckoprofiler::markers::NoPayload>( MOZ_RELEASE_ASSERT(profiler_add_marker<::geckoprofiler::markers::NoPayload>(
"explicitly-default-templated markers 2.0 with option", "explicitly-default-templated markers 2.0 with option",
geckoprofiler::category::OTHER)); geckoprofiler::category::OTHER, {}));
// Used in markers below. // Used in markers below.
TimeStamp ts1 = TimeStamp::NowUnfuzzed(); TimeStamp ts1 = TimeStamp::NowUnfuzzed();
@@ -739,20 +739,18 @@ TEST(GeckoProfiler, Markers)
("operation", "source", "filename", ts1, ts2, nullptr)); ("operation", "source", "filename", ts1, ts2, nullptr));
MOZ_RELEASE_ASSERT(profiler_add_marker<geckoprofiler::markers::FileIO>( MOZ_RELEASE_ASSERT(profiler_add_marker<geckoprofiler::markers::FileIO>(
"FileIOMarkerPayload marker 2.0", "FileIOMarkerPayload marker 2.0", geckoprofiler::category::OTHER,
geckoprofiler::category::OTHER.WithOptions( MarkerTiming::Interval(ts1, ts2), "operation", "source", "filename",
MarkerTiming::Interval(ts1, ts2)), MarkerThreadId{}));
"operation", "source", "filename", MarkerThreadId{}));
PROFILER_ADD_MARKER_WITH_PAYLOAD( PROFILER_ADD_MARKER_WITH_PAYLOAD(
"FileIOMarkerPayload marker off-MT", OTHER, FileIOMarkerPayload, "FileIOMarkerPayload marker off-MT", OTHER, FileIOMarkerPayload,
("operation2", "source2", "filename2", ts1, ts2, nullptr, Some(123))); ("operation2", "source2", "filename2", ts1, ts2, nullptr, Some(123)));
MOZ_RELEASE_ASSERT(profiler_add_marker<geckoprofiler::markers::FileIO>( MOZ_RELEASE_ASSERT(profiler_add_marker<geckoprofiler::markers::FileIO>(
"FileIOMarkerPayload marker 2.0 off-MT", "FileIOMarkerPayload marker 2.0 off-MT", geckoprofiler::category::OTHER,
geckoprofiler::category::OTHER.WithOptions( MarkerTiming::Interval(ts1, ts2), "operation2", "source2", "filename2",
MarkerTiming::Interval(ts1, ts2)), MarkerThreadId{123}));
"operation2", "source2", "filename2", MarkerThreadId{123}));
// Other markers in alphabetical order of payload class names. // Other markers in alphabetical order of payload class names.
@@ -859,35 +857,35 @@ TEST(GeckoProfiler, Markers)
mozilla::ipc::MessagePhase::Endpoint, false, ts1)); mozilla::ipc::MessagePhase::Endpoint, false, ts1));
MOZ_RELEASE_ASSERT(profiler_add_marker<geckoprofiler::markers::Tracing>( MOZ_RELEASE_ASSERT(profiler_add_marker<geckoprofiler::markers::Tracing>(
"Tracing", geckoprofiler::category::OTHER, "category")); "Tracing", geckoprofiler::category::OTHER, {}, "category"));
MOZ_RELEASE_ASSERT( MOZ_RELEASE_ASSERT(
profiler_add_marker<geckoprofiler::markers::UserTimingMark>( profiler_add_marker<geckoprofiler::markers::UserTimingMark>(
"UserTimingMark", geckoprofiler::category::OTHER, "mark name")); "UserTimingMark", geckoprofiler::category::OTHER, {}, "mark name"));
MOZ_RELEASE_ASSERT( MOZ_RELEASE_ASSERT(
profiler_add_marker<geckoprofiler::markers::UserTimingMeasure>( profiler_add_marker<geckoprofiler::markers::UserTimingMeasure>(
"UserTimingMeasure", geckoprofiler::category::OTHER, "measure name", "UserTimingMeasure", geckoprofiler::category::OTHER, {},
Some(mozilla::ProfilerString8View("start")), "measure name", Some(mozilla::ProfilerString8View("start")),
Some(mozilla::ProfilerString8View("end")))); Some(mozilla::ProfilerString8View("end"))));
MOZ_RELEASE_ASSERT(profiler_add_marker<geckoprofiler::markers::Hang>( MOZ_RELEASE_ASSERT(profiler_add_marker<geckoprofiler::markers::Hang>(
"Hang", geckoprofiler::category::OTHER)); "Hang", geckoprofiler::category::OTHER, {}));
MOZ_RELEASE_ASSERT(profiler_add_marker<geckoprofiler::markers::LongTask>( MOZ_RELEASE_ASSERT(profiler_add_marker<geckoprofiler::markers::LongTask>(
"LongTask", geckoprofiler::category::OTHER)); "LongTask", geckoprofiler::category::OTHER, {}));
MOZ_RELEASE_ASSERT(profiler_add_marker<geckoprofiler::markers::Text>( MOZ_RELEASE_ASSERT(profiler_add_marker<geckoprofiler::markers::Text>(
"Text", geckoprofiler::category::OTHER, "Text text")); "Text", geckoprofiler::category::OTHER, {}, "Text text"));
MOZ_RELEASE_ASSERT(profiler_add_marker<geckoprofiler::markers::Log>( MOZ_RELEASE_ASSERT(profiler_add_marker<geckoprofiler::markers::Log>(
"Log", geckoprofiler::category::OTHER, "module", "log text")); "Log", geckoprofiler::category::OTHER, {}, "module", "log text"));
MOZ_RELEASE_ASSERT(profiler_add_marker<geckoprofiler::markers::MediaSample>( MOZ_RELEASE_ASSERT(profiler_add_marker<geckoprofiler::markers::MediaSample>(
"MediaSample", geckoprofiler::category::OTHER, 123, 456)); "MediaSample", geckoprofiler::category::OTHER, {}, 123, 456));
MOZ_RELEASE_ASSERT(profiler_add_marker<geckoprofiler::markers::Budget>( MOZ_RELEASE_ASSERT(profiler_add_marker<geckoprofiler::markers::Budget>(
"Budget", geckoprofiler::category::OTHER)); "Budget", geckoprofiler::category::OTHER, {}));
SpliceableChunkedJSONWriter w; SpliceableChunkedJSONWriter w;
w.Start(); w.Start();
@@ -2015,7 +2013,7 @@ TEST(GeckoProfiler, BaseProfilerHandOff)
// Add at least a marker, which should go straight into the buffer. // Add at least a marker, which should go straight into the buffer.
Maybe<baseprofiler::ProfilerBufferInfo> info0 = Maybe<baseprofiler::ProfilerBufferInfo> info0 =
baseprofiler::profiler_get_buffer_info(); baseprofiler::profiler_get_buffer_info();
BASE_PROFILER_MARKER_UNTYPED("Marker from base profiler", OTHER); BASE_PROFILER_MARKER_UNTYPED("Marker from base profiler", OTHER, {});
Maybe<baseprofiler::ProfilerBufferInfo> info1 = Maybe<baseprofiler::ProfilerBufferInfo> info1 =
baseprofiler::profiler_get_buffer_info(); baseprofiler::profiler_get_buffer_info();
ASSERT_GT(info1->mRangeEnd, info0->mRangeEnd); ASSERT_GT(info1->mRangeEnd, info0->mRangeEnd);

View File

@@ -677,9 +677,8 @@ void NS_CreateServicesFromCategory(const char* aCategory, nsISupports* aOrigin,
#ifdef MOZ_GECKO_PROFILER #ifdef MOZ_GECKO_PROFILER
nsPrintfCString profilerStr("%s (%s)", aObserverTopic, nsPrintfCString profilerStr("%s (%s)", aObserverTopic,
entryString.get()); entryString.get());
AUTO_PROFILER_MARKER_TEXT("Category observer notification", AUTO_PROFILER_MARKER_TEXT("Category observer notification", OTHER,
OTHER.WithOptions(MarkerStack::Capture()), MarkerStack::Capture(), profilerStr);
profilerStr);
AUTO_PROFILER_LABEL_DYNAMIC_NSCSTRING_NONSENSITIVE( AUTO_PROFILER_LABEL_DYNAMIC_NSCSTRING_NONSENSITIVE(
"Category observer notification -", OTHER, profilerStr); "Category observer notification -", OTHER, profilerStr);
#endif #endif

View File

@@ -1325,7 +1325,7 @@ nsresult nsComponentManagerImpl::GetServiceLocked(MutexLock& aLock,
{ {
SafeMutexAutoUnlock unlock(mLock); SafeMutexAutoUnlock unlock(mLock);
AUTO_PROFILER_MARKER_TEXT( AUTO_PROFILER_MARKER_TEXT(
"GetService", OTHER.WithOptions(MarkerStack::Capture()), "GetService", OTHER, MarkerStack::Capture(),
nsDependentCString(nsIDToCString(aEntry.CID()).get())); nsDependentCString(nsIDToCString(aEntry.CID()).get()));
rv = aEntry.CreateInstance(nullptr, aIID, getter_AddRefs(service)); rv = aEntry.CreateInstance(nullptr, aIID, getter_AddRefs(service));
} }

View File

@@ -277,8 +277,7 @@ NS_IMETHODIMP nsObserverService::NotifyObservers(nsISupports* aSubject,
mozilla::TimeStamp start = TimeStamp::Now(); mozilla::TimeStamp start = TimeStamp::Now();
AUTO_PROFILER_MARKER_TEXT("NotifyObservers", AUTO_PROFILER_MARKER_TEXT("NotifyObservers", OTHER, MarkerStack::Capture(),
OTHER.WithOptions(MarkerStack::Capture()),
nsDependentCString(aTopic)); nsDependentCString(aTopic));
AUTO_PROFILER_LABEL_DYNAMIC_CSTR_NONSENSITIVE( AUTO_PROFILER_LABEL_DYNAMIC_CSTR_NONSENSITIVE(
"nsObserverService::NotifyObservers", OTHER, aTopic); "nsObserverService::NotifyObservers", OTHER, aTopic);