Backed out 2 changesets (bug 1667915) for platform related bustage CLOSED TREE
Backed out changeset e7a0788a1741 (bug 1667915) Backed out changeset d34505b2d81b (bug 1667915)
This commit is contained in:
@@ -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();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
MarkerOptions options{::geckoprofiler::category::JS};
|
||||||
|
|
||||||
if (aStartTime.WasPassed()) {
|
if (aStartTime.WasPassed()) {
|
||||||
RefPtr<Performance> performance;
|
RefPtr<Performance> performance;
|
||||||
@@ -231,9 +231,10 @@ void ChromeUtils::AddProfilerMarker(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (aText.WasPassed()) {
|
if (aText.WasPassed()) {
|
||||||
PROFILER_MARKER_TEXT(aName, JS, std::move(options), aText.Value());
|
PROFILER_MARKER_TEXT(aName, MarkerOptions(std::move(options)),
|
||||||
|
aText.Value());
|
||||||
} else {
|
} else {
|
||||||
PROFILER_MARKER_UNTYPED(aName, JS, std::move(options));
|
PROFILER_MARKER_UNTYPED(aName, MarkerOptions(std::move(options)));
|
||||||
}
|
}
|
||||||
#endif // MOZ_GECKO_PROFILER
|
#endif // MOZ_GECKO_PROFILER
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6072,11 +6072,12 @@ bool nsGlobalWindowInner::RunTimeoutHandler(Timeout* aTimeout,
|
|||||||
timeout->mScriptHandler->GetDescription(handlerDescription);
|
timeout->mScriptHandler->GetDescription(handlerDescription);
|
||||||
str.Append(handlerDescription);
|
str.Append(handlerDescription);
|
||||||
}
|
}
|
||||||
AUTO_PROFILER_MARKER_TEXT("setTimeout callback", JS,
|
AUTO_PROFILER_MARKER_TEXT(
|
||||||
MarkerOptions(MarkerStack::TakeBacktrace(
|
"setTimeout callback",
|
||||||
timeout->TakeProfilerBacktrace()),
|
JS.WithOptions(
|
||||||
MarkerInnerWindowId(mWindowID)),
|
MarkerStack::TakeBacktrace(timeout->TakeProfilerBacktrace()),
|
||||||
str);
|
MarkerInnerWindowId(mWindowID)),
|
||||||
|
str);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool abortIntervalHandler;
|
bool abortIntervalHandler;
|
||||||
|
|||||||
@@ -1063,18 +1063,21 @@ nsresult EventDispatcher::Dispatch(nsISupports* aTarget,
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
profiler_add_marker("DOMEvent", geckoprofiler::category::DOM,
|
profiler_add_marker<DOMEventMarker>(
|
||||||
{MarkerTiming::IntervalStart(),
|
"DOMEvent",
|
||||||
MarkerInnerWindowId(innerWindowId)},
|
geckoprofiler::category::DOM.WithOptions(
|
||||||
DOMEventMarker{}, typeStr, aEvent->mTimeStamp);
|
MarkerTiming::IntervalStart(),
|
||||||
|
MarkerInnerWindowId(innerWindowId)),
|
||||||
|
typeStr, aEvent->mTimeStamp);
|
||||||
|
|
||||||
EventTargetChainItem::HandleEventTargetChain(chain, postVisitor,
|
EventTargetChainItem::HandleEventTargetChain(chain, postVisitor,
|
||||||
aCallback, cd);
|
aCallback, cd);
|
||||||
|
|
||||||
profiler_add_marker(
|
profiler_add_marker<DOMEventMarker>(
|
||||||
"DOMEvent", geckoprofiler::category::DOM,
|
"DOMEvent",
|
||||||
{MarkerTiming::IntervalEnd(), std::move(innerWindowId)},
|
geckoprofiler::category::DOM.WithOptions(
|
||||||
DOMEventMarker{}, typeStr, aEvent->mTimeStamp);
|
MarkerTiming::IntervalEnd(), std::move(innerWindowId)),
|
||||||
|
typeStr, aEvent->mTimeStamp);
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -286,9 +286,10 @@ 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("Process", DOM,
|
PROFILER_MARKER_TEXT(
|
||||||
MarkerTiming::IntervalUntilNowFrom(mBlockingStartTime),
|
"Process",
|
||||||
"Blocked preallocation");
|
DOM.WithOptions(MarkerTiming::IntervalUntilNowFrom(mBlockingStartTime)),
|
||||||
|
"Blocked preallocation");
|
||||||
if (IsEmpty()) {
|
if (IsEmpty()) {
|
||||||
AllocateAfterDelay();
|
AllocateAfterDelay();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2863,9 +2863,10 @@ 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("ModuleEvaluation", JS,
|
AUTO_PROFILER_MARKER_TEXT(
|
||||||
MarkerInnerWindowIdFromDocShell(docShell),
|
"ModuleEvaluation",
|
||||||
profilerLabelString);
|
JS.WithOptions(MarkerInnerWindowIdFromDocShell(docShell)),
|
||||||
|
profilerLabelString);
|
||||||
|
|
||||||
// currentScript is set to null for modules.
|
// currentScript is set to null for modules.
|
||||||
AutoCurrentScriptUpdater scriptUpdater(this, nullptr);
|
AutoCurrentScriptUpdater scriptUpdater(this, nullptr);
|
||||||
@@ -2938,18 +2939,20 @@ 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("BytecodeDecodeMainThread", JS,
|
AUTO_PROFILER_MARKER_TEXT(
|
||||||
MarkerInnerWindowIdFromDocShell(docShell),
|
"BytecodeDecodeMainThread",
|
||||||
profilerLabelString);
|
JS.WithOptions(MarkerInnerWindowIdFromDocShell(docShell)),
|
||||||
|
profilerLabelString);
|
||||||
|
|
||||||
rv = exec.Decode(options, aRequest->mScriptBytecode,
|
rv = exec.Decode(options, aRequest->mScriptBytecode,
|
||||||
aRequest->mBytecodeOffset);
|
aRequest->mBytecodeOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rv == NS_OK) {
|
if (rv == NS_OK) {
|
||||||
AUTO_PROFILER_MARKER_TEXT("ScriptExecution", JS,
|
AUTO_PROFILER_MARKER_TEXT(
|
||||||
MarkerInnerWindowIdFromDocShell(docShell),
|
"ScriptExecution",
|
||||||
profilerLabelString);
|
JS.WithOptions(MarkerInnerWindowIdFromDocShell(docShell)),
|
||||||
|
profilerLabelString);
|
||||||
rv = ExecuteCompiledScript(cx, aRequest, exec, classicScript);
|
rv = ExecuteCompiledScript(cx, aRequest, exec, classicScript);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2983,8 +2986,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", JS,
|
"BinASTDecodeMainThread",
|
||||||
MarkerInnerWindowIdFromDocShell(docShell),
|
JS.WithOptions(MarkerInnerWindowIdFromDocShell(docShell)),
|
||||||
profilerLabelString);
|
profilerLabelString);
|
||||||
|
|
||||||
rv = exec.DecodeBinAST(options,
|
rv = exec.DecodeBinAST(options,
|
||||||
@@ -2996,8 +2999,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", JS,
|
"ScriptCompileMainThread",
|
||||||
MarkerInnerWindowIdFromDocShell(docShell),
|
JS.WithOptions(MarkerInnerWindowIdFromDocShell(docShell)),
|
||||||
profilerLabelString);
|
profilerLabelString);
|
||||||
|
|
||||||
rv = maybeSource.constructed<SourceText<char16_t>>()
|
rv = maybeSource.constructed<SourceText<char16_t>>()
|
||||||
@@ -3014,8 +3017,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", JS,
|
"ScriptExecution",
|
||||||
MarkerInnerWindowIdFromDocShell(docShell),
|
JS.WithOptions(MarkerInnerWindowIdFromDocShell(docShell)),
|
||||||
profilerLabelString);
|
profilerLabelString);
|
||||||
rv = ExecuteCompiledScript(cx, aRequest, exec, classicScript);
|
rv = ExecuteCompiledScript(cx, aRequest, exec, classicScript);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -361,8 +361,8 @@ void WorkerGlobalScope::ImportScripts(JSContext* aCx,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AUTO_PROFILER_MARKER_TEXT("ImportScripts", JS, MarkerStack::Capture(),
|
AUTO_PROFILER_MARKER_TEXT("ImportScripts",
|
||||||
urls);
|
JS.WithOptions(MarkerStack::Capture()), urls);
|
||||||
#endif
|
#endif
|
||||||
workerinternals::Load(mWorkerPrivate, std::move(stack), aScriptURLs,
|
workerinternals::Load(mWorkerPrivate, std::move(stack), aScriptURLs,
|
||||||
WorkerScript, aRv);
|
WorkerScript, aRv);
|
||||||
|
|||||||
@@ -2365,9 +2365,10 @@ 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(
|
PROFILER_MARKER_TEXT(name,
|
||||||
name, GRAPHICS,
|
GRAPHICS.WithOptions(MarkerTiming::Interval(
|
||||||
MarkerTiming::Interval(payload.mTimeStamp, presented), text);
|
payload.mTimeStamp, presented)),
|
||||||
|
text);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -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, MarkerTiming::IntervalUntilNowFrom(before),
|
"SurfacePool", GRAPHICS.WithOptions(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),
|
||||||
|
|||||||
@@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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), GRAPHICS,
|
mozilla::ProfilerString8View::WrapNullTerminatedString(name),
|
||||||
mozilla::MarkerTiming::Interval(start, now),
|
GRAPHICS.WithOptions(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", GRAPHICS,
|
PROFILER_MARKER_TEXT("SkippedComposite",
|
||||||
MarkerTiming::InstantAt(now),
|
GRAPHICS.WithOptions(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", GRAPHICS,
|
PROFILER_MARKER_TEXT("SkippedComposite",
|
||||||
MarkerTiming::InstantAt(start),
|
GRAPHICS.WithOptions(MarkerTiming::InstantAt(start)),
|
||||||
"No reason to generate frame");
|
"No reason to generate frame");
|
||||||
ResetPreviousSampleTime();
|
ResetPreviousSampleTime();
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -254,8 +254,9 @@ 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", GRAPHICS,
|
"WR OS Compositor frame",
|
||||||
MarkerTiming::IntervalUntilNowFrom(mBeginFrameTimeStamp),
|
GRAPHICS.WithOptions(
|
||||||
|
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),
|
||||||
|
|||||||
@@ -377,7 +377,8 @@ const mozilla::Module* mozJSComponentLoader::LoadModule(FileLocation& aFile) {
|
|||||||
|
|
||||||
mInitialized = true;
|
mInitialized = true;
|
||||||
|
|
||||||
AUTO_PROFILER_MARKER_TEXT("JS XPCOM", JS, MarkerStack::Capture(), spec);
|
AUTO_PROFILER_MARKER_TEXT("JS XPCOM", JS.WithOptions(MarkerStack::Capture()),
|
||||||
|
spec);
|
||||||
AUTO_PROFILER_LABEL_DYNAMIC_NSCSTRING("mozJSComponentLoader::LoadModule",
|
AUTO_PROFILER_LABEL_DYNAMIC_NSCSTRING("mozJSComponentLoader::LoadModule",
|
||||||
OTHER, spec);
|
OTHER, spec);
|
||||||
|
|
||||||
@@ -1180,8 +1181,8 @@ nsresult mozJSComponentLoader::Import(JSContext* aCx,
|
|||||||
bool aIgnoreExports) {
|
bool aIgnoreExports) {
|
||||||
mInitialized = true;
|
mInitialized = true;
|
||||||
|
|
||||||
AUTO_PROFILER_MARKER_TEXT("ChromeUtils.import", JS, MarkerStack::Capture(),
|
AUTO_PROFILER_MARKER_TEXT("ChromeUtils.import",
|
||||||
aLocation);
|
JS.WithOptions(MarkerStack::Capture()), aLocation);
|
||||||
|
|
||||||
ComponentLoaderInfo info(aLocation);
|
ComponentLoaderInfo info(aLocation);
|
||||||
|
|
||||||
|
|||||||
@@ -416,7 +416,8 @@ nsresult mozJSSubScriptLoader::DoLoadSubScriptWithOptions(
|
|||||||
}
|
}
|
||||||
|
|
||||||
NS_LossyConvertUTF16toASCII asciiUrl(url);
|
NS_LossyConvertUTF16toASCII asciiUrl(url);
|
||||||
AUTO_PROFILER_MARKER_TEXT("SubScript", JS, MarkerStack::Capture(), asciiUrl);
|
AUTO_PROFILER_MARKER_TEXT("SubScript", JS.WithOptions(MarkerStack::Capture()),
|
||||||
|
asciiUrl);
|
||||||
AUTO_PROFILER_LABEL_DYNAMIC_NSCSTRING_NONSENSITIVE(
|
AUTO_PROFILER_LABEL_DYNAMIC_NSCSTRING_NONSENSITIVE(
|
||||||
"mozJSSubScriptLoader::DoLoadSubScriptWithOptions", OTHER, asciiUrl);
|
"mozJSSubScriptLoader::DoLoadSubScriptWithOptions", OTHER, asciiUrl);
|
||||||
|
|
||||||
|
|||||||
@@ -1283,10 +1283,11 @@ 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", GRAPHICS,
|
"RefreshObserver",
|
||||||
MarkerOptions(MarkerStack::TakeBacktrace(std::move(data.mCause)),
|
GRAPHICS.WithOptions(
|
||||||
MarkerTiming::IntervalUntilNowFrom(data.mRegisterTime),
|
MarkerStack::TakeBacktrace(std::move(data.mCause)),
|
||||||
MarkerInnerWindowId(data.mInnerWindowId)),
|
MarkerTiming::IntervalUntilNowFrom(data.mRegisterTime),
|
||||||
|
MarkerInnerWindowId(data.mInnerWindowId)),
|
||||||
str);
|
str);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -2069,8 +2070,8 @@ void nsRefreshDriver::Tick(VsyncId aId, TimeStamp aNowTime) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
AUTO_PROFILER_MARKER_TEXT(
|
AUTO_PROFILER_MARKER_TEXT(
|
||||||
"RefreshDriverTick", GRAPHICS,
|
"RefreshDriverTick",
|
||||||
MarkerOptions(
|
GRAPHICS.WithOptions(
|
||||||
MarkerStack::TakeBacktrace(std::move(mRefreshTimerStartedCause)),
|
MarkerStack::TakeBacktrace(std::move(mRefreshTimerStartedCause)),
|
||||||
MarkerInnerWindowIdFromDocShell(GetDocShell(mPresContext))),
|
MarkerInnerWindowIdFromDocShell(GetDocShell(mPresContext))),
|
||||||
profilerStr);
|
profilerStr);
|
||||||
@@ -2332,10 +2333,10 @@ void nsRefreshDriver::Tick(VsyncId aId, TimeStamp aNowTime) {
|
|||||||
transactionId.AppendInt((uint64_t)mNextTransactionId);
|
transactionId.AppendInt((uint64_t)mNextTransactionId);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
AUTO_PROFILER_MARKER_TEXT(
|
AUTO_PROFILER_MARKER_TEXT("ViewManagerFlush",
|
||||||
"ViewManagerFlush", GRAPHICS,
|
GRAPHICS.WithOptions(MarkerStack::TakeBacktrace(
|
||||||
MarkerStack::TakeBacktrace(std::move(mViewManagerFlushCause)),
|
std::move(mViewManagerFlushCause))),
|
||||||
transactionId);
|
transactionId);
|
||||||
|
|
||||||
RefPtr<TimelineConsumers> timelines = TimelineConsumers::Get();
|
RefPtr<TimelineConsumers> timelines = TimelineConsumers::Get();
|
||||||
|
|
||||||
|
|||||||
@@ -21,11 +21,11 @@
|
|||||||
// supporting types.
|
// supporting types.
|
||||||
//
|
//
|
||||||
// To then record markers:
|
// To then record markers:
|
||||||
// - Use `baseprofiler::AddMarker(...)` from mozglue or other libraries that
|
// - Use `baseprofiler::AddMarker<ChosenMarkerType>(...)` from
|
||||||
// are outside of xul, especially if they may happen outside of xpcom's
|
// mozglue or other libraries that are outside of xul, especially if they may
|
||||||
// lifetime (typically startup, shutdown, or tests).
|
// happen outside of xpcom's lifetime (typically startup, shutdown, or tests).
|
||||||
// - Otherwise #include "ProfilerMarkers.h" instead, and use
|
// - Otherwise #include "ProfilerMarkers.h" instead, and use
|
||||||
// `profiler_add_marker(...)`.
|
// `profiler_add_marker<ChosenMarkerType>(...)`.
|
||||||
// See these functions for more details.
|
// See these functions for more details.
|
||||||
|
|
||||||
#ifndef BaseProfilerMarkers_h
|
#ifndef BaseProfilerMarkers_h
|
||||||
@@ -38,18 +38,15 @@
|
|||||||
|
|
||||||
#ifndef MOZ_GECKO_PROFILER
|
#ifndef MOZ_GECKO_PROFILER
|
||||||
|
|
||||||
# define BASE_PROFILER_MARKER_UNTYPED(markerName, categoryName, ...)
|
# define BASE_PROFILER_MARKER_UNTYPED(markerName, options)
|
||||||
# define BASE_PROFILER_MARKER(markerName, categoryName, options, MarkerType, \
|
# define BASE_PROFILER_MARKER(markerName, options, MarkerType, ...)
|
||||||
...)
|
# define BASE_PROFILER_MARKER_TEXT(markerName, options, text)
|
||||||
# define BASE_PROFILER_MARKER_TEXT(markerName, categoryName, options, text)
|
# define AUTO_BASE_PROFILER_MARKER_TEXT(markerName, options, text)
|
||||||
# define AUTO_BASE_PROFILER_MARKER_TEXT(markerName, categoryName, options, \
|
|
||||||
text)
|
|
||||||
|
|
||||||
#else // ndef MOZ_GECKO_PROFILER
|
#else // ndef MOZ_GECKO_PROFILER
|
||||||
|
|
||||||
# include "mozilla/ProfileChunkedBuffer.h"
|
# include "mozilla/ProfileChunkedBuffer.h"
|
||||||
# include "mozilla/TimeStamp.h"
|
# include "mozilla/TimeStamp.h"
|
||||||
# include "mozilla/Unused.h"
|
|
||||||
|
|
||||||
# include <functional>
|
# include <functional>
|
||||||
# include <string>
|
# include <string>
|
||||||
@@ -57,56 +54,27 @@
|
|||||||
|
|
||||||
namespace mozilla::baseprofiler {
|
namespace mozilla::baseprofiler {
|
||||||
|
|
||||||
// Add a marker to a given buffer. `AddMarker()` and related macros should be
|
template <typename MarkerType = ::mozilla::baseprofiler::markers::NoPayload,
|
||||||
// used in most cases, see below for more information about them and the
|
typename... Ts>
|
||||||
// parameters; This function may be useful when markers need to be recorded in a
|
ProfileBufferBlockIndex AddMarkerToBuffer(ProfileChunkedBuffer& aBuffer,
|
||||||
// local buffer outside of the main profiler buffer.
|
const ProfilerString8View& aName,
|
||||||
template <typename MarkerType, typename... PayloadArguments>
|
MarkerOptions&& aOptions,
|
||||||
ProfileBufferBlockIndex AddMarkerToBuffer(
|
const Ts&... aTs) {
|
||||||
ProfileChunkedBuffer& aBuffer, const ProfilerString8View& aName,
|
|
||||||
const MarkerCategory& aCategory, MarkerOptions&& aOptions,
|
|
||||||
MarkerType aMarkerType, const PayloadArguments&... aPayloadArguments) {
|
|
||||||
Unused << aMarkerType; // Only the empty object type is useful.
|
|
||||||
return base_profiler_markers_detail::AddMarkerToBuffer<MarkerType>(
|
return base_profiler_markers_detail::AddMarkerToBuffer<MarkerType>(
|
||||||
aBuffer, aName, aCategory, std::move(aOptions),
|
aBuffer, aName, std::move(aOptions),
|
||||||
::mozilla::baseprofiler::profiler_capture_backtrace_into,
|
::mozilla::baseprofiler::profiler_capture_backtrace_into, aTs...);
|
||||||
aPayloadArguments...);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add a marker (without payload) to a given buffer.
|
template <typename MarkerType = ::mozilla::baseprofiler::markers::NoPayload,
|
||||||
inline ProfileBufferBlockIndex AddMarkerToBuffer(
|
typename... Ts>
|
||||||
ProfileChunkedBuffer& aBuffer, const ProfilerString8View& aName,
|
ProfileBufferBlockIndex AddMarker(const ProfilerString8View& aName,
|
||||||
const MarkerCategory& aCategory, MarkerOptions&& aOptions = {}) {
|
MarkerOptions&& aOptions, const Ts&... aTs) {
|
||||||
return AddMarkerToBuffer(aBuffer, aName, aCategory, std::move(aOptions),
|
|
||||||
markers::NoPayload{});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add a marker to the Base Profiler buffer.
|
|
||||||
// - aName: Main name of this marker.
|
|
||||||
// - aCategory: Category for this marker.
|
|
||||||
// - aOptions: Optional settings (such as timing, inner window id,
|
|
||||||
// backtrace...), see `MarkerOptions` for details.
|
|
||||||
// - aMarkerType: Empty object that specifies the type of marker.
|
|
||||||
// - aPayloadArguments: Arguments expected by this marker type's
|
|
||||||
// ` StreamJSONMarkerData` function.
|
|
||||||
template <typename MarkerType, typename... PayloadArguments>
|
|
||||||
ProfileBufferBlockIndex AddMarker(
|
|
||||||
const ProfilerString8View& aName, const MarkerCategory& aCategory,
|
|
||||||
MarkerOptions&& aOptions, MarkerType aMarkerType,
|
|
||||||
const PayloadArguments&... aPayloadArguments) {
|
|
||||||
if (!baseprofiler::profiler_can_accept_markers()) {
|
if (!baseprofiler::profiler_can_accept_markers()) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
return ::mozilla::baseprofiler::AddMarkerToBuffer(
|
return ::mozilla::baseprofiler::AddMarkerToBuffer<MarkerType>(
|
||||||
base_profiler_markers_detail::CachedBaseCoreBuffer(), aName, aCategory,
|
base_profiler_markers_detail::CachedBaseCoreBuffer(), aName,
|
||||||
std::move(aOptions), aMarkerType, aPayloadArguments...);
|
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(aName, aCategory, std::move(aOptions), markers::NoPayload{});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Marker types' StreamJSONMarkerData functions should use this to correctly
|
// Marker types' StreamJSONMarkerData functions should use this to correctly
|
||||||
@@ -122,26 +90,20 @@ inline void WritePropertyTime(JSONWriter& aWriter,
|
|||||||
|
|
||||||
} // namespace mozilla::baseprofiler
|
} // namespace mozilla::baseprofiler
|
||||||
|
|
||||||
// Same as `AddMarker()` (without payload). This macro is safe to use even if
|
# define BASE_PROFILER_MARKER_UNTYPED(markerName, options) \
|
||||||
// MOZ_GECKO_PROFILER is not #defined.
|
do { \
|
||||||
# define BASE_PROFILER_MARKER_UNTYPED(markerName, categoryName, ...) \
|
AUTO_PROFILER_STATS(BASE_PROFILER_MARKER_UNTYPED); \
|
||||||
do { \
|
::mozilla::baseprofiler::AddMarker<>( \
|
||||||
AUTO_PROFILER_STATS(BASE_PROFILER_MARKER_UNTYPED); \
|
markerName, ::mozilla::baseprofiler::category::options); \
|
||||||
::mozilla::baseprofiler::AddMarker( \
|
|
||||||
markerName, ::mozilla::baseprofiler::category::categoryName, \
|
|
||||||
##__VA_ARGS__); \
|
|
||||||
} while (false)
|
} while (false)
|
||||||
|
|
||||||
// Same as `AddMarker()` (with payload). This macro is safe to use even if
|
# define BASE_PROFILER_MARKER(markerName, options, MarkerType, ...) \
|
||||||
// MOZ_GECKO_PROFILER is not #defined.
|
do { \
|
||||||
# define BASE_PROFILER_MARKER(markerName, categoryName, options, MarkerType, \
|
AUTO_PROFILER_STATS(BASE_PROFILER_MARKER_with_##MarkerType); \
|
||||||
...) \
|
::mozilla::baseprofiler::AddMarker< \
|
||||||
do { \
|
::mozilla::baseprofiler::markers::MarkerType>( \
|
||||||
AUTO_PROFILER_STATS(BASE_PROFILER_MARKER_with_##MarkerType); \
|
markerName, ::mozilla::baseprofiler::category::options, \
|
||||||
::mozilla::baseprofiler::AddMarker( \
|
##__VA_ARGS__); \
|
||||||
markerName, ::mozilla::baseprofiler::category::categoryName, \
|
|
||||||
options, ::mozilla::baseprofiler::markers::MarkerType{}, \
|
|
||||||
##__VA_ARGS__); \
|
|
||||||
} while (false)
|
} while (false)
|
||||||
|
|
||||||
namespace mozilla::baseprofiler::markers {
|
namespace mozilla::baseprofiler::markers {
|
||||||
@@ -157,14 +119,12 @@ struct Text {
|
|||||||
};
|
};
|
||||||
} // namespace mozilla::baseprofiler::markers
|
} // namespace mozilla::baseprofiler::markers
|
||||||
|
|
||||||
// Add a text marker. This macro is safe to use even if MOZ_GECKO_PROFILER is
|
# define BASE_PROFILER_MARKER_TEXT(markerName, options, text) \
|
||||||
// not #defined.
|
do { \
|
||||||
# define BASE_PROFILER_MARKER_TEXT(markerName, categoryName, options, text) \
|
AUTO_PROFILER_STATS(BASE_PROFILER_MARKER_TEXT); \
|
||||||
do { \
|
::mozilla::baseprofiler::AddMarker< \
|
||||||
AUTO_PROFILER_STATS(BASE_PROFILER_MARKER_TEXT); \
|
::mozilla::baseprofiler::markers::Text>( \
|
||||||
::mozilla::baseprofiler::AddMarker( \
|
markerName, ::mozilla::baseprofiler::category::options, text); \
|
||||||
markerName, ::mozilla::baseprofiler::category::categoryName, \
|
|
||||||
options, ::mozilla::baseprofiler::markers::Text{}, text); \
|
|
||||||
} while (false)
|
} while (false)
|
||||||
|
|
||||||
namespace mozilla::baseprofiler {
|
namespace mozilla::baseprofiler {
|
||||||
@@ -174,13 +134,9 @@ 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,
|
AutoProfilerTextMarker(const char* aMarkerName, MarkerOptions&& aOptions,
|
||||||
const MarkerCategory& aCategory,
|
const std::string& aText)
|
||||||
MarkerOptions&& aOptions, const std::string& 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()) {
|
||||||
@@ -190,27 +146,22 @@ class MOZ_RAII AutoProfilerTextMarker {
|
|||||||
|
|
||||||
~AutoProfilerTextMarker() {
|
~AutoProfilerTextMarker() {
|
||||||
mOptions.TimingRef().SetIntervalEnd();
|
mOptions.TimingRef().SetIntervalEnd();
|
||||||
AUTO_PROFILER_STATS(AUTO_BASE_PROFILER_MARKER_TEXT);
|
BASE_PROFILER_MARKER_TEXT(
|
||||||
AddMarker(ProfilerString8View::WrapNullTerminatedString(mMarkerName),
|
ProfilerString8View::WrapNullTerminatedString(mMarkerName),
|
||||||
mCategory, std::move(mOptions), markers::Text{}, mText);
|
MarkerOptions(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
|
||||||
|
|
||||||
// Creates an AutoProfilerTextMarker RAII object. This macro is safe to use
|
# define AUTO_BASE_PROFILER_MARKER_TEXT(markerName, options, text) \
|
||||||
// even if MOZ_GECKO_PROFILER is not #defined.
|
::mozilla::baseprofiler::AutoProfilerTextMarker BASE_PROFILER_RAII( \
|
||||||
# define AUTO_BASE_PROFILER_MARKER_TEXT(markerName, categoryName, options, \
|
markerName, ::mozilla::baseprofiler::category::options, text)
|
||||||
text) \
|
|
||||||
::mozilla::baseprofiler::AutoProfilerTextMarker BASE_PROFILER_RAII( \
|
|
||||||
markerName, ::mozilla::baseprofiler::category::categoryName, options, \
|
|
||||||
text)
|
|
||||||
|
|
||||||
#endif // nfed MOZ_GECKO_PROFILER else
|
#endif // nfed MOZ_GECKO_PROFILER else
|
||||||
|
|
||||||
|
|||||||
@@ -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,
|
||||||
const MarkerCategory& aCategory, MarkerOptions&& aOptions,
|
MarkerOptions&& aOptions, Streaming::DeserializerTag aDeserializerTag,
|
||||||
Streaming::DeserializerTag aDeserializerTag, const As&... aAs) {
|
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,
|
||||||
aCategory, aDeserializerTag, aAs...);
|
aDeserializerTag, aAs...);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -111,7 +111,6 @@ 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,
|
||||||
@@ -127,8 +126,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, aCategory,
|
return StreamFunctionType::Serialize(aBuffer, aName, std::move(aOptions),
|
||||||
std::move(aOptions), tag, aTs...);
|
tag, aTs...);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -176,8 +175,7 @@ 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,
|
||||||
const MarkerCategory& aCategory, MarkerOptions&& aOptions,
|
MarkerOptions&& aOptions, const Ts&... aTs) {
|
||||||
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,
|
||||||
@@ -185,11 +183,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, aCategory,
|
ProfileBufferEntryKind::Marker, std::move(aOptions), aName,
|
||||||
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, aCategory, std::move(aOptions), aTs...);
|
aBuffer, aName, std::move(aOptions), aTs...);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,7 +201,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,
|
||||||
const MarkerCategory& aCategory, MarkerOptions&& aOptions,
|
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.
|
||||||
@@ -228,11 +226,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, aCategory, std::move(aOptions), aTs...);
|
aBuffer, aName, std::move(aOptions), aTs...);
|
||||||
}
|
}
|
||||||
|
|
||||||
return AddMarkerWithOptionalStackToBuffer<MarkerType>(
|
return AddMarkerWithOptionalStackToBuffer<MarkerType>(
|
||||||
aBuffer, aName, aCategory, std::move(aOptions), aTs...);
|
aBuffer, aName, std::move(aOptions), aTs...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename NameCallback, typename StackCallback>
|
template <typename NameCallback, typename StackCallback>
|
||||||
@@ -256,7 +254,7 @@ template <typename NameCallback, typename StackCallback>
|
|||||||
aWriter.StartArrayElement();
|
aWriter.StartArrayElement();
|
||||||
{
|
{
|
||||||
std::forward<NameCallback>(aNameCallback)(
|
std::forward<NameCallback>(aNameCallback)(
|
||||||
aEntryReader.ReadObject<ProfilerString8View>());
|
aEntryReader.ReadObject<mozilla::ProfilerString8View>());
|
||||||
|
|
||||||
const double startTime = options.Timing().GetStartTime();
|
const double startTime = options.Timing().GetStartTime();
|
||||||
aWriter.DoubleElement(startTime);
|
aWriter.DoubleElement(startTime);
|
||||||
@@ -266,8 +264,7 @@ template <typename NameCallback, typename StackCallback>
|
|||||||
|
|
||||||
aWriter.IntElement(static_cast<int64_t>(options.Timing().MarkerPhase()));
|
aWriter.IntElement(static_cast<int64_t>(options.Timing().MarkerPhase()));
|
||||||
|
|
||||||
MarkerCategory category = aEntryReader.ReadObject<MarkerCategory>();
|
aWriter.IntElement(static_cast<int64_t>(options.Category().GetCategory()));
|
||||||
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::
|
||||||
@@ -425,7 +422,8 @@ template <>
|
|||||||
struct ProfileBufferEntryReader::Deserializer<MarkerCategory> {
|
struct ProfileBufferEntryReader::Deserializer<MarkerCategory> {
|
||||||
static void ReadInto(ProfileBufferEntryReader& aER,
|
static void ReadInto(ProfileBufferEntryReader& aER,
|
||||||
MarkerCategory& aCategory) {
|
MarkerCategory& aCategory) {
|
||||||
aCategory = Read(aER);
|
aCategory.mCategoryPair = static_cast<baseprofiler::ProfilingCategoryPair>(
|
||||||
|
aER.ReadULEB128<uint32_t>());
|
||||||
}
|
}
|
||||||
|
|
||||||
static MarkerCategory Read(ProfileBufferEntryReader& aER) {
|
static MarkerCategory Read(ProfileBufferEntryReader& aER) {
|
||||||
@@ -586,13 +584,14 @@ 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.ThreadId(), aOptions.Timing(), aOptions.Stack(),
|
return SumBytes(aOptions.Category(), aOptions.ThreadId(), aOptions.Timing(),
|
||||||
aOptions.InnerWindowId());
|
aOptions.Stack(), aOptions.InnerWindowId());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Write(ProfileBufferEntryWriter& aEW,
|
static void Write(ProfileBufferEntryWriter& aEW,
|
||||||
const MarkerOptions& aOptions) {
|
const MarkerOptions& aOptions) {
|
||||||
aEW.WriteObjects(aOptions.ThreadId(), aOptions.Timing(), aOptions.Stack(),
|
aEW.WriteObjects(aOptions.Category(), aOptions.ThreadId(),
|
||||||
|
aOptions.Timing(), aOptions.Stack(),
|
||||||
aOptions.InnerWindowId());
|
aOptions.InnerWindowId());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -600,7 +599,8 @@ 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.mThreadId, aOptions.mTiming, aOptions.mStack,
|
aER.ReadIntoObjects(aOptions.mCategory, aOptions.mThreadId,
|
||||||
|
aOptions.mTiming, aOptions.mStack,
|
||||||
aOptions.mInnerWindowId);
|
aOptions.mInnerWindowId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -212,34 +212,47 @@ class MOZ_STACK_CLASS ProfilerStringView {
|
|||||||
using ProfilerString8View = ProfilerStringView<char>;
|
using ProfilerString8View = ProfilerStringView<char>;
|
||||||
using ProfilerString16View = ProfilerStringView<char16_t>;
|
using ProfilerString16View = ProfilerStringView<char16_t>;
|
||||||
|
|
||||||
// This compulsory marker parameter contains the required category information.
|
// The classes below are all embedded in a `MarkerOptions` object.
|
||||||
|
class MarkerOptions;
|
||||||
|
|
||||||
|
// This compulsory marker option contains the required category information.
|
||||||
class MarkerCategory {
|
class MarkerCategory {
|
||||||
public:
|
public:
|
||||||
// Constructor from category pair (includes both super- and sub-categories).
|
// Constructor from category pair (aka sub-category) and category.
|
||||||
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 name constructs a MarkerCategory.
|
// Each category-pair (aka subcategory) 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 without namespace.
|
// Profiler macros will take the category name alone.
|
||||||
// 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) \
|
||||||
@@ -254,15 +267,12 @@ 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.:
|
// the given category, e.g.: 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.
|
||||||
@@ -575,15 +585,22 @@ class MarkerInnerWindowId {
|
|||||||
uint64_t mInnerWindowId = scNoId;
|
uint64_t mInnerWindowId = scNoId;
|
||||||
};
|
};
|
||||||
|
|
||||||
// This class combines each of the possible marker options above.
|
// This class combines a compulsory category with the above marker options.
|
||||||
|
// 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:
|
||||||
// Constructor from individual options (including none).
|
// Implicit constructor from category.
|
||||||
// Implicit to allow `{}` and one option type as-is.
|
constexpr MOZ_IMPLICIT MarkerOptions(const MarkerCategory& aCategory)
|
||||||
// Options that are not provided here are defaulted. In particular, timing
|
: mCategory(aCategory) {}
|
||||||
// defaults to `MarkerTiming::InstantNow()` when the marker is recorded.
|
|
||||||
|
// Constructor from category and other options.
|
||||||
template <typename... Options>
|
template <typename... Options>
|
||||||
MOZ_IMPLICIT MarkerOptions(Options&&... aOptions) {
|
explicit MarkerOptions(const MarkerCategory& aCategory, Options&&... aOptions)
|
||||||
|
: mCategory(aCategory) {
|
||||||
(Set(std::forward<Options>(aOptions)), ...);
|
(Set(std::forward<Options>(aOptions)), ...);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -604,6 +621,7 @@ 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()`.
|
||||||
@@ -623,6 +641,7 @@ 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);
|
||||||
@@ -632,12 +651,31 @@ 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 {
|
||||||
|
|||||||
@@ -3340,9 +3340,9 @@ 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("fib", OTHER,
|
BASE_PROFILER_MARKER_TEXT(
|
||||||
MarkerTiming::IntervalUntilNowFrom(start),
|
"fib", OTHER.WithOptions(MarkerTiming::IntervalUntilNowFrom(start)),
|
||||||
std::to_string(DEPTH));
|
std::to_string(DEPTH));
|
||||||
}
|
}
|
||||||
return f2 + f1;
|
return f2 + f1;
|
||||||
}
|
}
|
||||||
@@ -3387,7 +3387,8 @@ 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", OTHER, MarkerStack::TakeBacktrace(std::move(cause)),
|
"fibonacci",
|
||||||
|
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);
|
||||||
@@ -3400,7 +3401,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) {
|
||||||
@@ -3417,14 +3418,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;
|
||||||
@@ -3449,18 +3450,20 @@ void TestProfiler() {
|
|||||||
baseprofiler::FileIOMarkerPayload(
|
baseprofiler::FileIOMarkerPayload(
|
||||||
"operation", "source", "filename", TimeStamp::NowUnfuzzed(),
|
"operation", "source", "filename", TimeStamp::NowUnfuzzed(),
|
||||||
TimeStamp::NowUnfuzzed(), std::move(cause)));
|
TimeStamp::NowUnfuzzed(), std::move(cause)));
|
||||||
baseprofiler::AddMarker("m2fileio", mozilla::baseprofiler::category::OTHER,
|
baseprofiler::AddMarker<mozilla::baseprofiler::markers::FileIO>(
|
||||||
{}, mozilla::baseprofiler::markers::FileIO{}, "op2",
|
"m2fileio", mozilla::baseprofiler::category::OTHER, "op2", "src2", "f2",
|
||||||
"src2", "f2", MarkerThreadId{});
|
|
||||||
baseprofiler::AddMarker(
|
|
||||||
"m2fileio-capture", mozilla::baseprofiler::category::OTHER,
|
|
||||||
MarkerStack::Capture(), mozilla::baseprofiler::markers::FileIO{}, "op2",
|
|
||||||
"src2", "f2", MarkerThreadId{});
|
|
||||||
baseprofiler::AddMarker(
|
|
||||||
"m2fileio-take-backtrace", mozilla::baseprofiler::category::OTHER,
|
|
||||||
MarkerStack::TakeBacktrace(baseprofiler::profiler_capture_backtrace()),
|
|
||||||
mozilla::baseprofiler::markers::FileIO{}, "op2", "src2", "f2",
|
|
||||||
MarkerThreadId{});
|
MarkerThreadId{});
|
||||||
|
baseprofiler::AddMarker<mozilla::baseprofiler::markers::FileIO>(
|
||||||
|
"m2fileio-capture",
|
||||||
|
mozilla::baseprofiler::category::OTHER.WithOptions(
|
||||||
|
MarkerStack::Capture()),
|
||||||
|
"op2", "src2", "f2", MarkerThreadId{});
|
||||||
|
baseprofiler::AddMarker<mozilla::baseprofiler::markers::FileIO>(
|
||||||
|
"m2fileio-take-backtrace",
|
||||||
|
mozilla::baseprofiler::category::OTHER.WithOptions(
|
||||||
|
MarkerStack::TakeBacktrace(
|
||||||
|
baseprofiler::profiler_capture_backtrace())),
|
||||||
|
"op2", "src2", "f2", MarkerThreadId{});
|
||||||
|
|
||||||
baseprofiler::profiler_add_marker(
|
baseprofiler::profiler_add_marker(
|
||||||
"UserTimingMarkerPayload", baseprofiler::ProfilingCategoryPair::OTHER,
|
"UserTimingMarkerPayload", baseprofiler::ProfilingCategoryPair::OTHER,
|
||||||
@@ -3490,105 +3493,66 @@ void TestProfiler() {
|
|||||||
baseprofiler::LogMarkerPayload("module", "text",
|
baseprofiler::LogMarkerPayload("module", "text",
|
||||||
TimeStamp::NowUnfuzzed()));
|
TimeStamp::NowUnfuzzed()));
|
||||||
|
|
||||||
MOZ_RELEASE_ASSERT(
|
MOZ_RELEASE_ASSERT(baseprofiler::AddMarker(
|
||||||
baseprofiler::AddMarker("markers 2.0 without options (omitted)",
|
"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)",
|
"markers 2.0 with option",
|
||||||
mozilla::baseprofiler::category::OTHER, {}));
|
mozilla::baseprofiler::category::OTHER.WithOptions(
|
||||||
|
MarkerInnerWindowId(123))));
|
||||||
|
|
||||||
MOZ_RELEASE_ASSERT(baseprofiler::AddMarker(
|
MOZ_RELEASE_ASSERT(baseprofiler::AddMarker<>(
|
||||||
"markers 2.0 without options (explicit init)",
|
"default-templated markers 2.0 without options",
|
||||||
mozilla::baseprofiler::category::OTHER, MarkerOptions()));
|
mozilla::baseprofiler::category::OTHER));
|
||||||
|
|
||||||
MOZ_RELEASE_ASSERT(baseprofiler::AddMarker(
|
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, MarkerInnerWindowId(123)));
|
mozilla::baseprofiler::category::OTHER.WithOptions(
|
||||||
|
MarkerInnerWindowId(123))));
|
||||||
|
|
||||||
MOZ_RELEASE_ASSERT(baseprofiler::AddMarker(
|
MOZ_RELEASE_ASSERT(
|
||||||
"explicitly-default-templated markers 2.0 without options",
|
baseprofiler::AddMarker<::mozilla::baseprofiler::markers::NoPayload>(
|
||||||
mozilla::baseprofiler::category::OTHER, {},
|
"explicitly-default-templated markers 2.0 without options",
|
||||||
::mozilla::baseprofiler::markers::NoPayload{}));
|
mozilla::baseprofiler::category::OTHER));
|
||||||
|
|
||||||
MOZ_RELEASE_ASSERT(baseprofiler::AddMarker(
|
MOZ_RELEASE_ASSERT(
|
||||||
"explicitly-default-templated markers 2.0 with option",
|
baseprofiler::AddMarker<::mozilla::baseprofiler::markers::NoPayload>(
|
||||||
mozilla::baseprofiler::category::OTHER, MarkerInnerWindowId(123),
|
"explicitly-default-templated markers 2.0 with option",
|
||||||
::mozilla::baseprofiler::markers::NoPayload{}));
|
mozilla::baseprofiler::category::OTHER.WithOptions(
|
||||||
|
MarkerInnerWindowId(123))));
|
||||||
|
|
||||||
MOZ_RELEASE_ASSERT(baseprofiler::AddMarker(
|
MOZ_RELEASE_ASSERT(
|
||||||
"tracing", mozilla::baseprofiler::category::OTHER, {},
|
baseprofiler::AddMarker<mozilla::baseprofiler::markers::Tracing>(
|
||||||
mozilla::baseprofiler::markers::Tracing{}, "category"));
|
"tracing", mozilla::baseprofiler::category::OTHER, "category"));
|
||||||
|
|
||||||
MOZ_RELEASE_ASSERT(baseprofiler::AddMarker(
|
MOZ_RELEASE_ASSERT(
|
||||||
"mark", mozilla::baseprofiler::category::OTHER, {},
|
baseprofiler::AddMarker<mozilla::baseprofiler::markers::UserTimingMark>(
|
||||||
mozilla::baseprofiler::markers::UserTimingMark{}, "mark name"));
|
"mark", mozilla::baseprofiler::category::OTHER, "mark name"));
|
||||||
|
|
||||||
MOZ_RELEASE_ASSERT(baseprofiler::AddMarker(
|
MOZ_RELEASE_ASSERT(baseprofiler::AddMarker<
|
||||||
"measure", mozilla::baseprofiler::category::OTHER, {},
|
mozilla::baseprofiler::markers::UserTimingMeasure>(
|
||||||
mozilla::baseprofiler::markers::UserTimingMeasure{}, "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("hang", mozilla::baseprofiler::category::OTHER,
|
baseprofiler::AddMarker<mozilla::baseprofiler::markers::Hang>(
|
||||||
{}, mozilla::baseprofiler::markers::Hang{}));
|
"hang", mozilla::baseprofiler::category::OTHER));
|
||||||
|
|
||||||
MOZ_RELEASE_ASSERT(baseprofiler::AddMarker(
|
MOZ_RELEASE_ASSERT(
|
||||||
"longtask", mozilla::baseprofiler::category::OTHER, {},
|
baseprofiler::AddMarker<mozilla::baseprofiler::markers::LongTask>(
|
||||||
mozilla::baseprofiler::markers::LongTask{}));
|
"longtask", mozilla::baseprofiler::category::OTHER));
|
||||||
|
|
||||||
MOZ_RELEASE_ASSERT(baseprofiler::AddMarker(
|
MOZ_RELEASE_ASSERT(
|
||||||
"text", mozilla::baseprofiler::category::OTHER, {},
|
baseprofiler::AddMarker<mozilla::baseprofiler::markers::Text>(
|
||||||
mozilla::baseprofiler::markers::Text{}, "text text"));
|
"text", mozilla::baseprofiler::category::OTHER, "text text"));
|
||||||
|
|
||||||
MOZ_RELEASE_ASSERT(baseprofiler::AddMarker(
|
MOZ_RELEASE_ASSERT(
|
||||||
"log", mozilla::baseprofiler::category::OTHER, {},
|
baseprofiler::AddMarker<mozilla::baseprofiler::markers::Log>(
|
||||||
mozilla::baseprofiler::markers::Log{}, "module", "text"));
|
"log", mozilla::baseprofiler::category::OTHER, "module", "text"));
|
||||||
|
|
||||||
MOZ_RELEASE_ASSERT(baseprofiler::AddMarker(
|
MOZ_RELEASE_ASSERT(
|
||||||
"media sample", mozilla::baseprofiler::category::OTHER, {},
|
baseprofiler::AddMarker<mozilla::baseprofiler::markers::MediaSample>(
|
||||||
mozilla::baseprofiler::markers::MediaSample{}, 123, 456));
|
"media sample", mozilla::baseprofiler::category::OTHER, 123, 456));
|
||||||
|
|
||||||
printf("Sleep 1s...\n");
|
printf("Sleep 1s...\n");
|
||||||
{
|
{
|
||||||
@@ -3739,6 +3703,12 @@ 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");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3750,22 +3720,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);
|
||||||
|
|
||||||
@@ -3797,55 +3767,72 @@ void TestUserMarker() {
|
|||||||
mozilla::ProfileChunkedBuffer buffer(
|
mozilla::ProfileChunkedBuffer buffer(
|
||||||
mozilla::ProfileChunkedBuffer::ThreadSafety::WithoutMutex, chunkManager);
|
mozilla::ProfileChunkedBuffer::ThreadSafety::WithoutMutex, chunkManager);
|
||||||
|
|
||||||
MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer(
|
MOZ_RELEASE_ASSERT(
|
||||||
buffer, "test2", mozilla::baseprofiler::category::OTHER_Profiling, {},
|
mozilla::baseprofiler::AddMarkerToBuffer<MarkerTypeTestMinimal>(
|
||||||
MarkerTypeTestMinimal{}, std::string("payload text")));
|
buffer, "test2", mozilla::baseprofiler::category::OTHER_Profiling,
|
||||||
|
std::string("payload text")));
|
||||||
|
|
||||||
MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer(
|
MOZ_RELEASE_ASSERT(
|
||||||
buffer, "test2", mozilla::baseprofiler::category::OTHER_Profiling,
|
mozilla::baseprofiler::AddMarkerToBuffer<MarkerTypeTestMinimal>(
|
||||||
mozilla::MarkerThreadId(123), MarkerTypeTestMinimal{},
|
buffer, "test2",
|
||||||
std::string("ThreadId(123)")));
|
mozilla::baseprofiler::category::OTHER_Profiling.WithOptions(
|
||||||
|
mozilla::MarkerThreadId(123)),
|
||||||
|
std::string("ThreadId(123)")));
|
||||||
|
|
||||||
auto start = mozilla::TimeStamp::NowUnfuzzed();
|
auto start = mozilla::TimeStamp::NowUnfuzzed();
|
||||||
|
|
||||||
MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer(
|
MOZ_RELEASE_ASSERT(
|
||||||
buffer, "test2", mozilla::baseprofiler::category::OTHER_Profiling,
|
mozilla::baseprofiler::AddMarkerToBuffer<MarkerTypeTestMinimal>(
|
||||||
mozilla::MarkerTiming::InstantAt(start), MarkerTypeTestMinimal{},
|
buffer, "test2",
|
||||||
std::string("InstantAt(start)")));
|
mozilla::baseprofiler::category::OTHER_Profiling.WithOptions(
|
||||||
|
mozilla::MarkerTiming::InstantAt(start)),
|
||||||
|
std::string("InstantAt(start)")));
|
||||||
|
|
||||||
auto then = mozilla::TimeStamp::NowUnfuzzed();
|
auto then = mozilla::TimeStamp::NowUnfuzzed();
|
||||||
|
|
||||||
MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer(
|
MOZ_RELEASE_ASSERT(
|
||||||
buffer, "test2", mozilla::baseprofiler::category::OTHER_Profiling,
|
mozilla::baseprofiler::AddMarkerToBuffer<MarkerTypeTestMinimal>(
|
||||||
mozilla::MarkerTiming::IntervalStart(start), MarkerTypeTestMinimal{},
|
buffer, "test2",
|
||||||
std::string("IntervalStart(start)")));
|
mozilla::baseprofiler::category::OTHER_Profiling.WithOptions(
|
||||||
|
mozilla::MarkerTiming::IntervalStart(start)),
|
||||||
|
std::string("IntervalStart(start)")));
|
||||||
|
|
||||||
MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer(
|
MOZ_RELEASE_ASSERT(
|
||||||
buffer, "test2", mozilla::baseprofiler::category::OTHER_Profiling,
|
mozilla::baseprofiler::AddMarkerToBuffer<MarkerTypeTestMinimal>(
|
||||||
mozilla::MarkerTiming::IntervalEnd(then), MarkerTypeTestMinimal{},
|
buffer, "test2",
|
||||||
std::string("IntervalEnd(then)")));
|
mozilla::baseprofiler::category::OTHER_Profiling.WithOptions(
|
||||||
|
mozilla::MarkerTiming::IntervalEnd(then)),
|
||||||
|
std::string("IntervalEnd(then)")));
|
||||||
|
|
||||||
MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer(
|
MOZ_RELEASE_ASSERT(
|
||||||
buffer, "test2", mozilla::baseprofiler::category::OTHER_Profiling,
|
mozilla::baseprofiler::AddMarkerToBuffer<MarkerTypeTestMinimal>(
|
||||||
mozilla::MarkerTiming::Interval(start, then), MarkerTypeTestMinimal{},
|
buffer, "test2",
|
||||||
std::string("Interval(start, then)")));
|
mozilla::baseprofiler::category::OTHER_Profiling.WithOptions(
|
||||||
|
mozilla::MarkerTiming::Interval(start, then)),
|
||||||
|
std::string("Interval(start, then)")));
|
||||||
|
|
||||||
MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer(
|
MOZ_RELEASE_ASSERT(
|
||||||
buffer, "test2", mozilla::baseprofiler::category::OTHER_Profiling,
|
mozilla::baseprofiler::AddMarkerToBuffer<MarkerTypeTestMinimal>(
|
||||||
mozilla::MarkerTiming::IntervalUntilNowFrom(start),
|
buffer, "test2",
|
||||||
MarkerTypeTestMinimal{}, std::string("IntervalUntilNowFrom(start)")));
|
mozilla::baseprofiler::category::OTHER_Profiling.WithOptions(
|
||||||
|
mozilla::MarkerTiming::IntervalUntilNowFrom(start)),
|
||||||
|
std::string("IntervalUntilNowFrom(start)")));
|
||||||
|
|
||||||
MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer(
|
MOZ_RELEASE_ASSERT(
|
||||||
buffer, "test2", mozilla::baseprofiler::category::OTHER_Profiling,
|
mozilla::baseprofiler::AddMarkerToBuffer<MarkerTypeTestMinimal>(
|
||||||
mozilla::MarkerStack::NoStack(), MarkerTypeTestMinimal{},
|
buffer, "test2",
|
||||||
std::string("NoStack")));
|
mozilla::baseprofiler::category::OTHER_Profiling.WithOptions(
|
||||||
|
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(mozilla::baseprofiler::AddMarkerToBuffer(
|
MOZ_RELEASE_ASSERT(
|
||||||
buffer, "test2", mozilla::baseprofiler::category::OTHER_Profiling,
|
mozilla::baseprofiler::AddMarkerToBuffer<MarkerTypeTestMinimal>(
|
||||||
mozilla::MarkerInnerWindowId(123), MarkerTypeTestMinimal{},
|
buffer, "test2",
|
||||||
std::string("InnerWindowId(123)")));
|
mozilla::baseprofiler::category::OTHER_Profiling.WithOptions(
|
||||||
|
mozilla::MarkerInnerWindowId(123)),
|
||||||
|
std::string("InnerWindowId(123)")));
|
||||||
|
|
||||||
# ifdef DEBUG
|
# ifdef DEBUG
|
||||||
buffer.Dump();
|
buffer.Dump();
|
||||||
@@ -3875,42 +3862,47 @@ void TestPredefinedMarkers() {
|
|||||||
mozilla::ProfileChunkedBuffer buffer(
|
mozilla::ProfileChunkedBuffer buffer(
|
||||||
mozilla::ProfileChunkedBuffer::ThreadSafety::WithoutMutex, chunkManager);
|
mozilla::ProfileChunkedBuffer::ThreadSafety::WithoutMutex, chunkManager);
|
||||||
|
|
||||||
MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer(
|
MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer<
|
||||||
|
mozilla::baseprofiler::markers::Tracing>(
|
||||||
buffer, std::string_view("tracing"),
|
buffer, std::string_view("tracing"),
|
||||||
mozilla::baseprofiler::category::OTHER, {},
|
mozilla::baseprofiler::category::OTHER, "category"));
|
||||||
mozilla::baseprofiler::markers::Tracing{}, "category"));
|
|
||||||
|
|
||||||
MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer(
|
MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer<
|
||||||
|
mozilla::baseprofiler::markers::UserTimingMark>(
|
||||||
buffer, std::string_view("mark"), mozilla::baseprofiler::category::OTHER,
|
buffer, std::string_view("mark"), mozilla::baseprofiler::category::OTHER,
|
||||||
{}, mozilla::baseprofiler::markers::UserTimingMark{}, "mark name"));
|
"mark name"));
|
||||||
|
|
||||||
MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer(
|
MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer<
|
||||||
|
mozilla::baseprofiler::markers::UserTimingMeasure>(
|
||||||
buffer, std::string_view("measure"),
|
buffer, std::string_view("measure"),
|
||||||
mozilla::baseprofiler::category::OTHER, {},
|
mozilla::baseprofiler::category::OTHER, "measure name ",
|
||||||
mozilla::baseprofiler::markers::UserTimingMeasure{}, "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<
|
||||||
buffer, std::string_view("hang"), mozilla::baseprofiler::category::OTHER,
|
mozilla::baseprofiler::markers::Hang>(
|
||||||
{}, mozilla::baseprofiler::markers::Hang{}));
|
buffer, std::string_view("hang"),
|
||||||
|
mozilla::baseprofiler::category::OTHER));
|
||||||
|
|
||||||
MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer(
|
MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer<
|
||||||
|
mozilla::baseprofiler::markers::LongTask>(
|
||||||
buffer, std::string_view("long task"),
|
buffer, std::string_view("long task"),
|
||||||
mozilla::baseprofiler::category::OTHER, {},
|
mozilla::baseprofiler::category::OTHER));
|
||||||
mozilla::baseprofiler::markers::LongTask{}));
|
|
||||||
|
|
||||||
MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer(
|
MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer<
|
||||||
|
mozilla::baseprofiler::markers::Text>(
|
||||||
buffer, std::string_view("text"), mozilla::baseprofiler::category::OTHER,
|
buffer, std::string_view("text"), mozilla::baseprofiler::category::OTHER,
|
||||||
{}, mozilla::baseprofiler::markers::Text{}, "text text"));
|
"text text"));
|
||||||
|
|
||||||
MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer(
|
MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer<
|
||||||
|
mozilla::baseprofiler::markers::Log>(
|
||||||
buffer, std::string_view("log"), mozilla::baseprofiler::category::OTHER,
|
buffer, std::string_view("log"), mozilla::baseprofiler::category::OTHER,
|
||||||
{}, mozilla::baseprofiler::markers::Log{}, "module", "text"));
|
"module", "text"));
|
||||||
|
|
||||||
MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer(
|
MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer<
|
||||||
|
mozilla::baseprofiler::markers::MediaSample>(
|
||||||
buffer, std::string_view("media"), mozilla::baseprofiler::category::OTHER,
|
buffer, std::string_view("media"), mozilla::baseprofiler::category::OTHER,
|
||||||
{}, mozilla::baseprofiler::markers::MediaSample{}, 123, 456));
|
123, 456));
|
||||||
|
|
||||||
# ifdef DEBUG
|
# ifdef DEBUG
|
||||||
buffer.Dump();
|
buffer.Dump();
|
||||||
@@ -3952,7 +3944,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, catch);
|
AUTO_BASE_PROFILER_MARKER_TEXT(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
|
||||||
@@ -3968,18 +3960,17 @@ 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, catch);
|
BASE_PROFILER_MARKER_TEXT(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");
|
||||||
|
|||||||
@@ -265,9 +265,10 @@ 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("Extension Suspend", NETWORK,
|
PROFILER_MARKER_TEXT(
|
||||||
MarkerTiming::IntervalUntilNowFrom(mSuspendTime),
|
"Extension Suspend",
|
||||||
aText);
|
NETWORK.WithOptions(MarkerTiming::IntervalUntilNowFrom(mSuspendTime)),
|
||||||
|
aText);
|
||||||
}
|
}
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
aRv.Throw(rv);
|
aRv.Throw(rv);
|
||||||
|
|||||||
@@ -341,9 +341,10 @@ 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("TelemetryStopwatch", OTHER,
|
PROFILER_MARKER_TEXT(
|
||||||
MarkerTiming::IntervalUntilNowFrom(timer->StartTime()),
|
"TelemetryStopwatch",
|
||||||
markerText);
|
OTHER.WithOptions(MarkerTiming::IntervalUntilNowFrom(timer->StartTime())),
|
||||||
|
markerText);
|
||||||
#endif
|
#endif
|
||||||
if (NS_FAILED(rv) && rv != NS_ERROR_NOT_AVAILABLE && !mSuppressErrors) {
|
if (NS_FAILED(rv) && rv != NS_ERROR_NOT_AVAILABLE && !mSuppressErrors) {
|
||||||
LogError(aCx, nsPrintfCString(
|
LogError(aCx, nsPrintfCString(
|
||||||
|
|||||||
@@ -22,11 +22,11 @@
|
|||||||
// types.
|
// types.
|
||||||
//
|
//
|
||||||
// To then record markers:
|
// To then record markers:
|
||||||
// - Use `baseprofiler::AddMarker(...)` from mozglue or other libraries that are
|
// - Use `baseprofiler::AddMarker<ChosenMarkerType>(...)` from
|
||||||
// outside of xul, especially if they may happen outside of xpcom's lifetime
|
// mozglue or other libraries that are outside of xul, especially if they may
|
||||||
// (typically startup, shutdown, or tests).
|
// happen outside of xpcom's lifetime (typically startup, shutdown, or tests).
|
||||||
// - Otherwise #include "ProfilerMarkers.h" instead, and use
|
// - Otherwise #include "ProfilerMarkers.h" instead, and use
|
||||||
// `profiler_add_marker(...)`.
|
// `profiler_add_marker<ChosenMarkerType>(...)`.
|
||||||
// See these functions for more details.
|
// See these functions for more details.
|
||||||
|
|
||||||
#ifndef ProfilerMarkers_h
|
#ifndef ProfilerMarkers_h
|
||||||
@@ -40,10 +40,10 @@
|
|||||||
|
|
||||||
#ifndef MOZ_GECKO_PROFILER
|
#ifndef MOZ_GECKO_PROFILER
|
||||||
|
|
||||||
# define PROFILER_MARKER_UNTYPED(markerName, categoryName, ...)
|
# define PROFILER_MARKER_UNTYPED(markerName, options)
|
||||||
# define PROFILER_MARKER(markerName, categoryName, options, MarkerType, ...)
|
# define PROFILER_MARKER(markerName, options, MarkerType, ...)
|
||||||
# define PROFILER_MARKER_TEXT(markerName, categoryName, options, text)
|
# define PROFILER_MARKER_TEXT(markerName, options, text)
|
||||||
# define AUTO_PROFILER_MARKER_TEXT(markerName, categoryName, options, text)
|
# define AUTO_PROFILER_MARKER_TEXT(markerName, options, text)
|
||||||
|
|
||||||
#else // ndef MOZ_GECKO_PROFILER
|
#else // ndef MOZ_GECKO_PROFILER
|
||||||
|
|
||||||
@@ -53,79 +53,41 @@ namespace geckoprofiler::category {
|
|||||||
using namespace ::mozilla::baseprofiler::category;
|
using namespace ::mozilla::baseprofiler::category;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add a marker to a given buffer. `AddMarker()` and related macros should be
|
template <typename MarkerType = ::mozilla::baseprofiler::markers::NoPayload,
|
||||||
// used in most cases, see below for more information about them and the
|
typename... Ts>
|
||||||
// paramters; This function may be useful when markers need to be recorded in a
|
|
||||||
// local buffer outside of the main profiler buffer.
|
|
||||||
template <typename MarkerType, typename... PayloadArguments>
|
|
||||||
mozilla::ProfileBufferBlockIndex AddMarkerToBuffer(
|
mozilla::ProfileBufferBlockIndex AddMarkerToBuffer(
|
||||||
mozilla::ProfileChunkedBuffer& aBuffer,
|
mozilla::ProfileChunkedBuffer& aBuffer,
|
||||||
const mozilla::ProfilerString8View& aName,
|
const mozilla::ProfilerString8View& aName,
|
||||||
const mozilla::MarkerCategory& aCategory, mozilla::MarkerOptions&& aOptions,
|
mozilla::MarkerOptions&& aOptions, const Ts&... aTs) {
|
||||||
MarkerType aMarkerType, const PayloadArguments&... aPayloadArguments) {
|
|
||||||
mozilla::Unused << aMarkerType; // Only the empty object type is useful.
|
|
||||||
return mozilla::base_profiler_markers_detail::AddMarkerToBuffer<MarkerType>(
|
return mozilla::base_profiler_markers_detail::AddMarkerToBuffer<MarkerType>(
|
||||||
aBuffer, aName, aCategory, std::move(aOptions),
|
aBuffer, aName, std::move(aOptions), ::profiler_capture_backtrace_into,
|
||||||
::profiler_capture_backtrace_into, aPayloadArguments...);
|
aTs...);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add a marker (without payload) to a given buffer.
|
template <typename MarkerType = ::mozilla::baseprofiler::markers::NoPayload,
|
||||||
inline mozilla::ProfileBufferBlockIndex AddMarkerToBuffer(
|
typename... Ts>
|
||||||
mozilla::ProfileChunkedBuffer& aBuffer,
|
|
||||||
const mozilla::ProfilerString8View& aName,
|
|
||||||
const mozilla::MarkerCategory& aCategory,
|
|
||||||
mozilla::MarkerOptions&& aOptions = {}) {
|
|
||||||
return AddMarkerToBuffer(aBuffer, aName, aCategory, std::move(aOptions),
|
|
||||||
mozilla::baseprofiler::markers::NoPayload{});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add a marker to the Gecko Profiler buffer.
|
|
||||||
// - aName: Main name of this marker.
|
|
||||||
// - aCategory: Category for this marker.
|
|
||||||
// - aOptions: Optional settings (such as timing, inner window id,
|
|
||||||
// backtrace...), see `MarkerOptions` for details.
|
|
||||||
// - aMarkerType: Empty object that specifies the type of marker.
|
|
||||||
// - aPayloadArguments: Arguments expected by this marker type's
|
|
||||||
// ` StreamJSONMarkerData` function.
|
|
||||||
template <typename MarkerType, typename... PayloadArguments>
|
|
||||||
mozilla::ProfileBufferBlockIndex profiler_add_marker(
|
mozilla::ProfileBufferBlockIndex profiler_add_marker(
|
||||||
const mozilla::ProfilerString8View& aName,
|
const mozilla::ProfilerString8View& aName,
|
||||||
const mozilla::MarkerCategory& aCategory, mozilla::MarkerOptions&& aOptions,
|
mozilla::MarkerOptions&& aOptions, const Ts&... aTs) {
|
||||||
MarkerType aMarkerType, const PayloadArguments&... aPayloadArguments) {
|
|
||||||
if (!profiler_can_accept_markers()) {
|
if (!profiler_can_accept_markers()) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
return ::AddMarkerToBuffer(profiler_markers_detail::CachedCoreBuffer(), aName,
|
return ::AddMarkerToBuffer<MarkerType>(
|
||||||
aCategory, std::move(aOptions), aMarkerType,
|
profiler_markers_detail::CachedCoreBuffer(), aName, std::move(aOptions),
|
||||||
aPayloadArguments...);
|
aTs...);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add a marker (without payload) to the Gecko Profiler buffer.
|
# define PROFILER_MARKER_UNTYPED(markerName, options) \
|
||||||
inline mozilla::ProfileBufferBlockIndex profiler_add_marker(
|
|
||||||
const mozilla::ProfilerString8View& aName,
|
|
||||||
const mozilla::MarkerCategory& aCategory,
|
|
||||||
mozilla::MarkerOptions&& aOptions = {}) {
|
|
||||||
return profiler_add_marker(aName, aCategory, std::move(aOptions),
|
|
||||||
mozilla::baseprofiler::markers::NoPayload{});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Same as `profiler_add_marker()` (without payload). This macro is safe to use
|
|
||||||
// even if MOZ_GECKO_PROFILER is not #defined.
|
|
||||||
# define PROFILER_MARKER_UNTYPED(markerName, categoryName, ...) \
|
|
||||||
do { \
|
do { \
|
||||||
AUTO_PROFILER_STATS(PROFILER_MARKER_UNTYPED); \
|
AUTO_PROFILER_STATS(PROFILER_MARKER_UNTYPED); \
|
||||||
::profiler_add_marker( \
|
::profiler_add_marker<>(markerName, ::geckoprofiler::category::options); \
|
||||||
markerName, ::geckoprofiler::category::categoryName, ##__VA_ARGS__); \
|
|
||||||
} while (false)
|
} while (false)
|
||||||
|
|
||||||
// Same as `profiler_add_marker()` (with payload). This macro is safe to use
|
# define PROFILER_MARKER(markerName, options, MarkerType, ...) \
|
||||||
// even if MOZ_GECKO_PROFILER is not #defined.
|
do { \
|
||||||
# define PROFILER_MARKER(markerName, categoryName, options, MarkerType, ...) \
|
AUTO_PROFILER_STATS(PROFILER_MARKER_with_##MarkerType); \
|
||||||
do { \
|
::profiler_add_marker<::geckoprofiler::markers::MarkerType>( \
|
||||||
AUTO_PROFILER_STATS(PROFILER_MARKER_with_##MarkerType); \
|
markerName, ::geckoprofiler::category::options, ##__VA_ARGS__); \
|
||||||
::profiler_add_marker( \
|
|
||||||
markerName, ::geckoprofiler::category::categoryName, options, \
|
|
||||||
::geckoprofiler::markers::MarkerType{}, ##__VA_ARGS__); \
|
|
||||||
} while (false)
|
} while (false)
|
||||||
|
|
||||||
namespace geckoprofiler::markers {
|
namespace geckoprofiler::markers {
|
||||||
@@ -133,14 +95,11 @@ namespace geckoprofiler::markers {
|
|||||||
using Text = ::mozilla::baseprofiler::markers::Text;
|
using Text = ::mozilla::baseprofiler::markers::Text;
|
||||||
} // namespace geckoprofiler::markers
|
} // namespace geckoprofiler::markers
|
||||||
|
|
||||||
// Add a text marker. This macro is safe to use even if MOZ_GECKO_PROFILER is
|
# define PROFILER_MARKER_TEXT(markerName, options, text) \
|
||||||
// not #defined.
|
do { \
|
||||||
# define PROFILER_MARKER_TEXT(markerName, categoryName, options, text) \
|
AUTO_PROFILER_STATS(PROFILER_MARKER_TEXT); \
|
||||||
do { \
|
::profiler_add_marker<::geckoprofiler::markers::Text>( \
|
||||||
AUTO_PROFILER_STATS(PROFILER_MARKER_TEXT); \
|
markerName, ::geckoprofiler::category::options, text); \
|
||||||
::profiler_add_marker(markerName, \
|
|
||||||
::geckoprofiler::category::categoryName, options, \
|
|
||||||
::geckoprofiler::markers::Text{}, 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
|
||||||
@@ -149,13 +108,9 @@ 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),
|
: mMarkerName(aMarkerName), mOptions(std::move(aOptions)), mText(aText) {
|
||||||
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()) {
|
||||||
@@ -165,25 +120,20 @@ class MOZ_RAII AutoProfilerTextMarker {
|
|||||||
|
|
||||||
~AutoProfilerTextMarker() {
|
~AutoProfilerTextMarker() {
|
||||||
mOptions.TimingRef().SetIntervalEnd();
|
mOptions.TimingRef().SetIntervalEnd();
|
||||||
AUTO_PROFILER_STATS(AUTO_PROFILER_MARKER_TEXT);
|
PROFILER_MARKER_TEXT(
|
||||||
profiler_add_marker(
|
|
||||||
mozilla::ProfilerString8View::WrapNullTerminatedString(mMarkerName),
|
mozilla::ProfilerString8View::WrapNullTerminatedString(mMarkerName),
|
||||||
mCategory, std::move(mOptions), geckoprofiler::markers::Text{}, mText);
|
MarkerOptions(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;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Creates an AutoProfilerTextMarker RAII object. This macro is safe to use
|
# define AUTO_PROFILER_MARKER_TEXT(markerName, options, text) \
|
||||||
// even if MOZ_GECKO_PROFILER is not #defined.
|
AutoProfilerTextMarker PROFILER_RAII( \
|
||||||
# define AUTO_PROFILER_MARKER_TEXT(markerName, categoryName, options, text) \
|
markerName, ::mozilla::baseprofiler::category::options, text)
|
||||||
AutoProfilerTextMarker PROFILER_RAII( \
|
|
||||||
markerName, ::mozilla::baseprofiler::category::categoryName, options, \
|
|
||||||
text)
|
|
||||||
|
|
||||||
#endif // nfed MOZ_GECKO_PROFILER else
|
#endif // nfed MOZ_GECKO_PROFILER else
|
||||||
|
|
||||||
|
|||||||
@@ -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,20 +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(
|
PROFILER_MARKER_UNTYPED("default-templated markers 2.0 with option",
|
||||||
"default-templated markers 2.0 with option", OTHER,
|
OTHER.WithOptions(MarkerStack::TakeBacktrace(
|
||||||
MarkerStack::TakeBacktrace(profiler_capture_backtrace()));
|
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(
|
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));
|
||||||
::geckoprofiler::markers::NoPayload{}));
|
|
||||||
|
|
||||||
// Used in markers below.
|
// Used in markers below.
|
||||||
TimeStamp ts1 = TimeStamp::NowUnfuzzed();
|
TimeStamp ts1 = TimeStamp::NowUnfuzzed();
|
||||||
@@ -739,18 +738,20 @@ TEST(GeckoProfiler, Markers)
|
|||||||
"FileIOMarkerPayload marker", OTHER, FileIOMarkerPayload,
|
"FileIOMarkerPayload marker", OTHER, FileIOMarkerPayload,
|
||||||
("operation", "source", "filename", ts1, ts2, nullptr));
|
("operation", "source", "filename", ts1, ts2, nullptr));
|
||||||
|
|
||||||
MOZ_RELEASE_ASSERT(profiler_add_marker(
|
MOZ_RELEASE_ASSERT(profiler_add_marker<geckoprofiler::markers::FileIO>(
|
||||||
"FileIOMarkerPayload marker 2.0", geckoprofiler::category::OTHER,
|
"FileIOMarkerPayload marker 2.0",
|
||||||
MarkerTiming::Interval(ts1, ts2), geckoprofiler::markers::FileIO{},
|
geckoprofiler::category::OTHER.WithOptions(
|
||||||
|
MarkerTiming::Interval(ts1, ts2)),
|
||||||
"operation", "source", "filename", 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(
|
MOZ_RELEASE_ASSERT(profiler_add_marker<geckoprofiler::markers::FileIO>(
|
||||||
"FileIOMarkerPayload marker 2.0 off-MT", geckoprofiler::category::OTHER,
|
"FileIOMarkerPayload marker 2.0 off-MT",
|
||||||
MarkerTiming::Interval(ts1, ts2), geckoprofiler::markers::FileIO{},
|
geckoprofiler::category::OTHER.WithOptions(
|
||||||
|
MarkerTiming::Interval(ts1, ts2)),
|
||||||
"operation2", "source2", "filename2", 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.
|
||||||
@@ -857,42 +858,36 @@ TEST(GeckoProfiler, Markers)
|
|||||||
mozilla::ipc::MessageDirection::eSending,
|
mozilla::ipc::MessageDirection::eSending,
|
||||||
mozilla::ipc::MessagePhase::Endpoint, false, ts1));
|
mozilla::ipc::MessagePhase::Endpoint, false, ts1));
|
||||||
|
|
||||||
MOZ_RELEASE_ASSERT(
|
MOZ_RELEASE_ASSERT(profiler_add_marker<geckoprofiler::markers::Tracing>(
|
||||||
profiler_add_marker("Tracing", geckoprofiler::category::OTHER, {},
|
"Tracing", geckoprofiler::category::OTHER, "category"));
|
||||||
geckoprofiler::markers::Tracing{}, "category"));
|
|
||||||
|
|
||||||
MOZ_RELEASE_ASSERT(profiler_add_marker(
|
|
||||||
"UserTimingMark", geckoprofiler::category::OTHER, {},
|
|
||||||
geckoprofiler::markers::UserTimingMark{}, "mark name"));
|
|
||||||
|
|
||||||
MOZ_RELEASE_ASSERT(profiler_add_marker(
|
|
||||||
"UserTimingMeasure", geckoprofiler::category::OTHER, {},
|
|
||||||
geckoprofiler::markers::UserTimingMeasure{}, "measure name",
|
|
||||||
Some(mozilla::ProfilerString8View("start")),
|
|
||||||
Some(mozilla::ProfilerString8View("end"))));
|
|
||||||
|
|
||||||
MOZ_RELEASE_ASSERT(profiler_add_marker("Hang", geckoprofiler::category::OTHER,
|
|
||||||
{}, geckoprofiler::markers::Hang{}));
|
|
||||||
|
|
||||||
MOZ_RELEASE_ASSERT(profiler_add_marker("LongTask",
|
|
||||||
geckoprofiler::category::OTHER, {},
|
|
||||||
geckoprofiler::markers::LongTask{}));
|
|
||||||
|
|
||||||
MOZ_RELEASE_ASSERT(profiler_add_marker("Text", geckoprofiler::category::OTHER,
|
|
||||||
{}, geckoprofiler::markers::Text{},
|
|
||||||
"Text text"));
|
|
||||||
|
|
||||||
MOZ_RELEASE_ASSERT(profiler_add_marker("Log", geckoprofiler::category::OTHER,
|
|
||||||
{}, geckoprofiler::markers::Log{},
|
|
||||||
"module", "log text"));
|
|
||||||
|
|
||||||
MOZ_RELEASE_ASSERT(
|
MOZ_RELEASE_ASSERT(
|
||||||
profiler_add_marker("MediaSample", geckoprofiler::category::OTHER, {},
|
profiler_add_marker<geckoprofiler::markers::UserTimingMark>(
|
||||||
geckoprofiler::markers::MediaSample{}, 123, 456));
|
"UserTimingMark", geckoprofiler::category::OTHER, "mark name"));
|
||||||
|
|
||||||
MOZ_RELEASE_ASSERT(profiler_add_marker("Budget",
|
MOZ_RELEASE_ASSERT(
|
||||||
geckoprofiler::category::OTHER, {},
|
profiler_add_marker<geckoprofiler::markers::UserTimingMeasure>(
|
||||||
geckoprofiler::markers::Budget{}));
|
"UserTimingMeasure", geckoprofiler::category::OTHER, "measure name",
|
||||||
|
Some(mozilla::ProfilerString8View("start")),
|
||||||
|
Some(mozilla::ProfilerString8View("end"))));
|
||||||
|
|
||||||
|
MOZ_RELEASE_ASSERT(profiler_add_marker<geckoprofiler::markers::Hang>(
|
||||||
|
"Hang", geckoprofiler::category::OTHER));
|
||||||
|
|
||||||
|
MOZ_RELEASE_ASSERT(profiler_add_marker<geckoprofiler::markers::LongTask>(
|
||||||
|
"LongTask", geckoprofiler::category::OTHER));
|
||||||
|
|
||||||
|
MOZ_RELEASE_ASSERT(profiler_add_marker<geckoprofiler::markers::Text>(
|
||||||
|
"Text", geckoprofiler::category::OTHER, "Text text"));
|
||||||
|
|
||||||
|
MOZ_RELEASE_ASSERT(profiler_add_marker<geckoprofiler::markers::Log>(
|
||||||
|
"Log", geckoprofiler::category::OTHER, "module", "log text"));
|
||||||
|
|
||||||
|
MOZ_RELEASE_ASSERT(profiler_add_marker<geckoprofiler::markers::MediaSample>(
|
||||||
|
"MediaSample", geckoprofiler::category::OTHER, 123, 456));
|
||||||
|
|
||||||
|
MOZ_RELEASE_ASSERT(profiler_add_marker<geckoprofiler::markers::Budget>(
|
||||||
|
"Budget", geckoprofiler::category::OTHER));
|
||||||
|
|
||||||
SpliceableChunkedJSONWriter w;
|
SpliceableChunkedJSONWriter w;
|
||||||
w.Start();
|
w.Start();
|
||||||
@@ -2020,7 +2015,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);
|
||||||
|
|||||||
@@ -677,8 +677,9 @@ 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", OTHER,
|
AUTO_PROFILER_MARKER_TEXT("Category observer notification",
|
||||||
MarkerStack::Capture(), profilerStr);
|
OTHER.WithOptions(MarkerStack::Capture()),
|
||||||
|
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
|
||||||
|
|||||||
@@ -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, MarkerStack::Capture(),
|
"GetService", OTHER.WithOptions(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));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -277,7 +277,8 @@ NS_IMETHODIMP nsObserverService::NotifyObservers(nsISupports* aSubject,
|
|||||||
|
|
||||||
mozilla::TimeStamp start = TimeStamp::Now();
|
mozilla::TimeStamp start = TimeStamp::Now();
|
||||||
|
|
||||||
AUTO_PROFILER_MARKER_TEXT("NotifyObservers", OTHER, MarkerStack::Capture(),
|
AUTO_PROFILER_MARKER_TEXT("NotifyObservers",
|
||||||
|
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);
|
||||||
|
|||||||
Reference in New Issue
Block a user