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

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

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

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

Differential Revision: https://phabricator.services.mozilla.com/D91680
This commit is contained in:
Gerald Squelart 2020-10-01 11:02:23 +00:00
Родитель 8a508eaa66
Коммит ee701f64d7
28 изменённых файлов: 382 добавлений и 362 удалений

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -81,7 +81,7 @@ void SurfacePoolCA::LockedPool::MutateEntryStorage(const char* aMutationType,
#ifdef MOZ_GECKO_PROFILER
if (profiler_thread_is_being_profiled()) {
PROFILER_MARKER_TEXT(
"SurfacePool", GRAPHICS.WithOptions(MarkerTiming::IntervalUntilNowFrom(before)),
"SurfacePool", GRAPHICS, MarkerTiming::IntervalUntilNowFrom(before),
nsPrintfCString("%d -> %d in use | %d -> %d waiting for | %d -> %d "
"available | %s %dx%d | %dMB total memory",
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",
offsetCurrent.ToMilliseconds(),
offsetNext.ToMilliseconds());
PROFILER_MARKER_TEXT("Video frame offsets", GRAPHICS, str);
PROFILER_MARKER_TEXT("Video frame offsets", GRAPHICS, {}, str);
}
#endif
@ -185,7 +185,7 @@ void ImageComposite::SetImages(nsTArray<TimedImage>&& aNewImages) {
") to frameID %" PRId32 " (prod %" PRId32 ")",
len, len == 1 ? "image" : "images", first.mFrameID,
first.mProducerID, last.mFrameID, last.mProducerID);
PROFILER_MARKER_TEXT("ImageComposite::SetImages", GRAPHICS, str);
PROFILER_MARKER_TEXT("ImageComposite::SetImages", GRAPHICS, {}, str);
}
#endif
}
@ -229,7 +229,7 @@ bool ImageComposite::UpdateCompositedFrame(
descr.AppendLiteral(", no change");
}
}
PROFILER_MARKER_TEXT("UpdateCompositedFrame", GRAPHICS, descr);
PROFILER_MARKER_TEXT("UpdateCompositedFrame", GRAPHICS, {}, descr);
#endif
if (mLastFrameID == image.mFrameID && mLastProducerID == image.mProducerID) {
@ -259,7 +259,7 @@ bool ImageComposite::UpdateCompositedFrame(
" (producer %" PRId32 ")",
dropped, frameOrFrames, mLastFrameID, image.mFrameID,
mLastProducerID);
PROFILER_MARKER_TEXT("Video frames dropped", GRAPHICS, text);
PROFILER_MARKER_TEXT("Video frames dropped", GRAPHICS, {}, text);
}
#endif
}
@ -370,7 +370,7 @@ void ImageComposite::DetectTimeStampJitter(const TimedImage* aNewImage) {
}
if (jitter) {
nsPrintfCString text("%.2lfms", jitter->ToMilliseconds());
PROFILER_MARKER_TEXT("VideoFrameTimeStampJitter", GRAPHICS, text);
PROFILER_MARKER_TEXT("VideoFrameTimeStampJitter", GRAPHICS, {}, text);
}
#endif
}

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

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

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

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

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

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

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

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

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

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

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

@ -3652,7 +3652,7 @@ void profiler_add_marker(const char* aMarkerName,
// into the JS engine.
void profiler_add_js_marker(const char* aMarkerName, const char* aMarkerText) {
BASE_PROFILER_MARKER_TEXT(
ProfilerString8View::WrapNullTerminatedString(aMarkerName), JS,
ProfilerString8View::WrapNullTerminatedString(aMarkerName), JS, {},
ProfilerString8View::WrapNullTerminatedString(aMarkerText));
}

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

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

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

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

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

@ -212,47 +212,34 @@ class MOZ_STACK_CLASS ProfilerStringView {
using ProfilerString8View = ProfilerStringView<char>;
using ProfilerString16View = ProfilerStringView<char16_t>;
// The classes below are all embedded in a `MarkerOptions` object.
class MarkerOptions;
// This compulsory marker option contains the required category information.
// This compulsory marker parameter contains the required category information.
class MarkerCategory {
public:
// Constructor from category pair (aka sub-category) and category.
// Constructor from category pair (includes both super- and sub-categories).
constexpr explicit MarkerCategory(
baseprofiler::ProfilingCategoryPair aCategoryPair)
: mCategoryPair(aCategoryPair) {}
// Returns the stored category pair.
constexpr baseprofiler::ProfilingCategoryPair CategoryPair() const {
return mCategoryPair;
}
// Returns the super-category from the stored category pair.
baseprofiler::ProfilingCategory GetCategory() const {
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:
// The default constructor is only used during deserialization of
// MarkerOptions.
friend MarkerOptions;
constexpr MarkerCategory() = default;
friend ProfileBufferEntryReader::Deserializer<MarkerCategory>;
baseprofiler::ProfilingCategoryPair mCategoryPair =
baseprofiler::ProfilingCategoryPair::OTHER;
};
namespace baseprofiler::category {
// Each category-pair (aka subcategory) name constructs a MarkerCategory.
// Each category pair name constructs a MarkerCategory.
// E.g.: mozilla::baseprofiler::category::OTHER_Profiling
// Profiler macros will take the category name alone.
// Profiler macros will take the category name alone without namespace.
// E.g.: `PROFILER_MARKER_UNTYPED("name", OTHER_Profiling)`
# define CATEGORY_ENUM_BEGIN_CATEGORY(name, labelAsString, color)
# define CATEGORY_ENUM_SUBCATEGORY(supercategory, name, labelAsString) \
@ -267,12 +254,15 @@ MOZ_PROFILING_CATEGORY_LIST(CATEGORY_ENUM_BEGIN_CATEGORY,
// Import `MarkerCategory` into this namespace. This will allow using this type
// dynamically in macros that prepend `::mozilla::baseprofiler::category::` to
// the given category, e.g.: E.g.:
// the given category, e.g.:
// `PROFILER_MARKER_UNTYPED("name", MarkerCategory(...))`
using MarkerCategory = ::mozilla::MarkerCategory;
} // namespace baseprofiler::category
// The classes below are all embedded in a `MarkerOptions` object.
class MarkerOptions;
// This marker option captures a given thread id.
// If left unspecified (by default construction) during the add-marker call, the
// current thread id will be used then.
@ -585,22 +575,15 @@ class MarkerInnerWindowId {
uint64_t mInnerWindowId = scNoId;
};
// 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())`
// This class combines each of the possible marker options above.
class MarkerOptions {
public:
// Implicit constructor from category.
constexpr MOZ_IMPLICIT MarkerOptions(const MarkerCategory& aCategory)
: mCategory(aCategory) {}
// Constructor from category and other options.
// Constructor from individual options (including none).
// Implicit to allow `{}` and one option type as-is.
// Options that are not provided here are defaulted. In particular, timing
// defaults to `MarkerTiming::InstantNow()` when the marker is recorded.
template <typename... Options>
explicit MarkerOptions(const MarkerCategory& aCategory, Options&&... aOptions)
: mCategory(aCategory) {
MOZ_IMPLICIT MarkerOptions(Options&&... aOptions) {
(Set(std::forward<Options>(aOptions)), ...);
}
@ -621,7 +604,6 @@ class MarkerOptions {
// `options.Set(MarkerThreadId(123)).Set(MarkerTiming::IntervalEnd())`.
// 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.:
// `PROFILER_MARKER_UNTYPED("...", OTHER.Set(...))`;
// `PROFILER_MARKER_UNTYPED("...", std::move(options).Set(...))`;
//
// Options can be read by their name (without "Marker"), e.g.: `o.ThreadId()`.
@ -641,7 +623,6 @@ class MarkerOptions {
\
Marker##NAME& NAME##Ref() { return m##NAME; }
FUNCTIONS_ON_MEMBER(Category);
FUNCTIONS_ON_MEMBER(ThreadId);
FUNCTIONS_ON_MEMBER(Timing);
FUNCTIONS_ON_MEMBER(Stack);
@ -651,31 +632,12 @@ class MarkerOptions {
private:
friend ProfileBufferEntryReader::Deserializer<MarkerOptions>;
// The default constructor is only used during deserialization.
constexpr MarkerOptions() = default;
MarkerCategory mCategory;
MarkerThreadId mThreadId;
MarkerTiming mTiming;
MarkerStack mStack;
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::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);
if (DEPTH < MAX_MARKER_DEPTH) {
BASE_PROFILER_MARKER_TEXT(
"fib", OTHER.WithOptions(MarkerTiming::IntervalUntilNowFrom(start)),
std::to_string(DEPTH));
BASE_PROFILER_MARKER_TEXT("fib", OTHER,
MarkerTiming::IntervalUntilNowFrom(start),
std::to_string(DEPTH));
}
return f2 + f1;
}
@ -3387,8 +3387,7 @@ void TestProfiler() {
SleepMilli(5);
auto cause = baseprofiler::profiler_capture_backtrace();
AUTO_BASE_PROFILER_MARKER_TEXT(
"fibonacci",
OTHER.WithOptions(MarkerStack::TakeBacktrace(std::move(cause))),
"fibonacci", OTHER, MarkerStack::TakeBacktrace(std::move(cause)),
"First leaf call");
static const unsigned long long fibStart = 37;
printf("Fibonacci(%llu)...\n", fibStart);
@ -3401,7 +3400,7 @@ void TestProfiler() {
std::thread threadCancelFib([]() {
AUTO_BASE_PROFILER_REGISTER_THREAD("fibonacci canceller");
SleepMilli(5);
AUTO_BASE_PROFILER_MARKER_TEXT("fibonacci", OTHER, "Canceller");
AUTO_BASE_PROFILER_MARKER_TEXT("fibonacci", OTHER, {}, "Canceller");
static const int waitMaxSeconds = 10;
for (int i = 0; i < waitMaxSeconds; ++i) {
if (sStopFibonacci) {
@ -3418,14 +3417,14 @@ void TestProfiler() {
});
{
AUTO_BASE_PROFILER_MARKER_TEXT("main thread", OTHER,
AUTO_BASE_PROFILER_MARKER_TEXT("main thread", OTHER, {},
"joining fibonacci thread");
AUTO_BASE_PROFILER_THREAD_SLEEP;
threadFib.join();
}
{
AUTO_BASE_PROFILER_MARKER_TEXT("main thread", OTHER,
AUTO_BASE_PROFILER_MARKER_TEXT("main thread", OTHER, {},
"joining fibonacci-canceller thread");
sStopFibonacci = true;
AUTO_BASE_PROFILER_THREAD_SLEEP;
@ -3451,18 +3450,14 @@ void TestProfiler() {
"operation", "source", "filename", TimeStamp::NowUnfuzzed(),
TimeStamp::NowUnfuzzed(), std::move(cause)));
baseprofiler::AddMarker<mozilla::baseprofiler::markers::FileIO>(
"m2fileio", mozilla::baseprofiler::category::OTHER, "op2", "src2", "f2",
MarkerThreadId{});
"m2fileio", mozilla::baseprofiler::category::OTHER, {}, "op2", "src2",
"f2", MarkerThreadId{});
baseprofiler::AddMarker<mozilla::baseprofiler::markers::FileIO>(
"m2fileio-capture",
mozilla::baseprofiler::category::OTHER.WithOptions(
MarkerStack::Capture()),
"op2", "src2", "f2", MarkerThreadId{});
"m2fileio-capture", mozilla::baseprofiler::category::OTHER,
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())),
"m2fileio-take-backtrace", mozilla::baseprofiler::category::OTHER,
MarkerStack::TakeBacktrace(baseprofiler::profiler_capture_backtrace()),
"op2", "src2", "f2", MarkerThreadId{});
baseprofiler::profiler_add_marker(
@ -3493,66 +3488,107 @@ void TestProfiler() {
baseprofiler::LogMarkerPayload("module", "text",
TimeStamp::NowUnfuzzed()));
MOZ_RELEASE_ASSERT(baseprofiler::AddMarker(
"markers 2.0 without options", mozilla::baseprofiler::category::OTHER));
MOZ_RELEASE_ASSERT(
baseprofiler::AddMarker("markers 2.0 without options (omitted)",
mozilla::baseprofiler::category::OTHER));
MOZ_RELEASE_ASSERT(baseprofiler::AddMarker(
"markers 2.0 with option",
mozilla::baseprofiler::category::OTHER.WithOptions(
MarkerInnerWindowId(123))));
"markers 2.0 without options (implicit brace-init)",
mozilla::baseprofiler::category::OTHER, {}));
MOZ_RELEASE_ASSERT(baseprofiler::AddMarker<>(
"default-templated markers 2.0 without options",
mozilla::baseprofiler::category::OTHER));
MOZ_RELEASE_ASSERT(baseprofiler::AddMarker(
"markers 2.0 without options (explicit init)",
mozilla::baseprofiler::category::OTHER, MarkerOptions()));
MOZ_RELEASE_ASSERT(baseprofiler::AddMarker<>(
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",
mozilla::baseprofiler::category::OTHER.WithOptions(
MarkerInnerWindowId(123))));
mozilla::baseprofiler::category::OTHER, MarkerInnerWindowId(123)));
MOZ_RELEASE_ASSERT(
baseprofiler::AddMarker<::mozilla::baseprofiler::markers::NoPayload>(
"explicitly-default-templated markers 2.0 without options",
mozilla::baseprofiler::category::OTHER));
mozilla::baseprofiler::category::OTHER, {}));
MOZ_RELEASE_ASSERT(
baseprofiler::AddMarker<::mozilla::baseprofiler::markers::NoPayload>(
"explicitly-default-templated markers 2.0 with option",
mozilla::baseprofiler::category::OTHER.WithOptions(
MarkerInnerWindowId(123))));
mozilla::baseprofiler::category::OTHER, MarkerInnerWindowId(123)));
MOZ_RELEASE_ASSERT(
baseprofiler::AddMarker<mozilla::baseprofiler::markers::Tracing>(
"tracing", mozilla::baseprofiler::category::OTHER, "category"));
"tracing", mozilla::baseprofiler::category::OTHER, {}, "category"));
MOZ_RELEASE_ASSERT(
baseprofiler::AddMarker<mozilla::baseprofiler::markers::UserTimingMark>(
"mark", mozilla::baseprofiler::category::OTHER, "mark name"));
"mark", mozilla::baseprofiler::category::OTHER, {}, "mark name"));
MOZ_RELEASE_ASSERT(baseprofiler::AddMarker<
mozilla::baseprofiler::markers::UserTimingMeasure>(
"measure", mozilla::baseprofiler::category::OTHER, "measure name",
"measure", mozilla::baseprofiler::category::OTHER, {}, "measure name",
Some(ProfilerString8View("start")), Some(ProfilerString8View("end"))));
MOZ_RELEASE_ASSERT(
baseprofiler::AddMarker<mozilla::baseprofiler::markers::Hang>(
"hang", mozilla::baseprofiler::category::OTHER));
"hang", mozilla::baseprofiler::category::OTHER, {}));
MOZ_RELEASE_ASSERT(
baseprofiler::AddMarker<mozilla::baseprofiler::markers::LongTask>(
"longtask", mozilla::baseprofiler::category::OTHER));
"longtask", mozilla::baseprofiler::category::OTHER, {}));
MOZ_RELEASE_ASSERT(
baseprofiler::AddMarker<mozilla::baseprofiler::markers::Text>(
"text", mozilla::baseprofiler::category::OTHER, "text text"));
"text", mozilla::baseprofiler::category::OTHER, {}, "text text"));
MOZ_RELEASE_ASSERT(
baseprofiler::AddMarker<mozilla::baseprofiler::markers::Log>(
"log", mozilla::baseprofiler::category::OTHER, "module", "text"));
"log", mozilla::baseprofiler::category::OTHER, {}, "module",
"text"));
MOZ_RELEASE_ASSERT(
baseprofiler::AddMarker<mozilla::baseprofiler::markers::MediaSample>(
"media sample", mozilla::baseprofiler::category::OTHER, 123, 456));
"media sample", mozilla::baseprofiler::category::OTHER, {}, 123,
456));
printf("Sleep 1s...\n");
{
@ -3703,12 +3739,6 @@ void TestMarkerCategory() {
# undef CATEGORY_ENUM_SUBCATEGORY
# 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");
}
@ -3720,22 +3750,22 @@ void TestMarkerNoPayload() {
mozilla::ProfileChunkedBuffer::ThreadSafety::WithoutMutex, chunkManager);
mozilla::ProfileBufferBlockIndex i0 =
mozilla::baseprofiler::AddMarkerToBuffer<>(
mozilla::baseprofiler::AddMarkerToBuffer(
buffer, "literal", mozilla::baseprofiler::category::OTHER_Profiling);
MOZ_RELEASE_ASSERT(i0);
const std::string dynamic = "dynamic";
mozilla::ProfileBufferBlockIndex i1 =
mozilla::baseprofiler::AddMarkerToBuffer<>(
mozilla::baseprofiler::AddMarkerToBuffer(
buffer, dynamic,
mozilla::baseprofiler::category::GRAPHICS_FlushingAsyncPaints);
mozilla::baseprofiler::category::GRAPHICS_FlushingAsyncPaints, {});
MOZ_RELEASE_ASSERT(i1);
MOZ_RELEASE_ASSERT(i1 > i0);
mozilla::ProfileBufferBlockIndex i2 =
mozilla::baseprofiler::AddMarkerToBuffer<>(
mozilla::baseprofiler::AddMarkerToBuffer(
buffer, std::string_view("string_view"),
mozilla::baseprofiler::category::GRAPHICS_FlushingAsyncPaints);
mozilla::baseprofiler::category::GRAPHICS_FlushingAsyncPaints, {});
MOZ_RELEASE_ASSERT(i2);
MOZ_RELEASE_ASSERT(i2 > i1);
@ -3769,69 +3799,59 @@ void TestUserMarker() {
MOZ_RELEASE_ASSERT(
mozilla::baseprofiler::AddMarkerToBuffer<MarkerTypeTestMinimal>(
buffer, "test2", mozilla::baseprofiler::category::OTHER_Profiling,
buffer, "test2", mozilla::baseprofiler::category::OTHER_Profiling, {},
std::string("payload text")));
MOZ_RELEASE_ASSERT(
mozilla::baseprofiler::AddMarkerToBuffer<MarkerTypeTestMinimal>(
buffer, "test2",
mozilla::baseprofiler::category::OTHER_Profiling.WithOptions(
mozilla::MarkerThreadId(123)),
std::string("ThreadId(123)")));
buffer, "test2", mozilla::baseprofiler::category::OTHER_Profiling,
mozilla::MarkerThreadId(123), std::string("ThreadId(123)")));
auto start = mozilla::TimeStamp::NowUnfuzzed();
MOZ_RELEASE_ASSERT(
mozilla::baseprofiler::AddMarkerToBuffer<MarkerTypeTestMinimal>(
buffer, "test2",
mozilla::baseprofiler::category::OTHER_Profiling.WithOptions(
mozilla::MarkerTiming::InstantAt(start)),
buffer, "test2", mozilla::baseprofiler::category::OTHER_Profiling,
mozilla::MarkerTiming::InstantAt(start),
std::string("InstantAt(start)")));
auto then = mozilla::TimeStamp::NowUnfuzzed();
MOZ_RELEASE_ASSERT(
mozilla::baseprofiler::AddMarkerToBuffer<MarkerTypeTestMinimal>(
buffer, "test2",
mozilla::baseprofiler::category::OTHER_Profiling.WithOptions(
mozilla::MarkerTiming::IntervalStart(start)),
buffer, "test2", mozilla::baseprofiler::category::OTHER_Profiling,
mozilla::MarkerTiming::IntervalStart(start),
std::string("IntervalStart(start)")));
MOZ_RELEASE_ASSERT(
mozilla::baseprofiler::AddMarkerToBuffer<MarkerTypeTestMinimal>(
buffer, "test2",
mozilla::baseprofiler::category::OTHER_Profiling.WithOptions(
mozilla::MarkerTiming::IntervalEnd(then)),
buffer, "test2", mozilla::baseprofiler::category::OTHER_Profiling,
mozilla::MarkerTiming::IntervalEnd(then),
std::string("IntervalEnd(then)")));
MOZ_RELEASE_ASSERT(
mozilla::baseprofiler::AddMarkerToBuffer<MarkerTypeTestMinimal>(
buffer, "test2",
mozilla::baseprofiler::category::OTHER_Profiling.WithOptions(
mozilla::MarkerTiming::Interval(start, then)),
buffer, "test2", mozilla::baseprofiler::category::OTHER_Profiling,
mozilla::MarkerTiming::Interval(start, then),
std::string("Interval(start, then)")));
MOZ_RELEASE_ASSERT(
mozilla::baseprofiler::AddMarkerToBuffer<MarkerTypeTestMinimal>(
buffer, "test2",
mozilla::baseprofiler::category::OTHER_Profiling.WithOptions(
mozilla::MarkerTiming::IntervalUntilNowFrom(start)),
buffer, "test2", mozilla::baseprofiler::category::OTHER_Profiling,
mozilla::MarkerTiming::IntervalUntilNowFrom(start),
std::string("IntervalUntilNowFrom(start)")));
MOZ_RELEASE_ASSERT(
mozilla::baseprofiler::AddMarkerToBuffer<MarkerTypeTestMinimal>(
buffer, "test2",
mozilla::baseprofiler::category::OTHER_Profiling.WithOptions(
mozilla::MarkerStack::NoStack()),
std::string("NoStack")));
buffer, "test2", mozilla::baseprofiler::category::OTHER_Profiling,
mozilla::MarkerStack::NoStack(), std::string("NoStack")));
// Note: We cannot test stack-capture here, because the profiler is not
// initialized.
MOZ_RELEASE_ASSERT(
mozilla::baseprofiler::AddMarkerToBuffer<MarkerTypeTestMinimal>(
buffer, "test2",
mozilla::baseprofiler::category::OTHER_Profiling.WithOptions(
mozilla::MarkerInnerWindowId(123)),
buffer, "test2", mozilla::baseprofiler::category::OTHER_Profiling,
mozilla::MarkerInnerWindowId(123),
std::string("InnerWindowId(123)")));
# ifdef DEBUG
@ -3865,44 +3885,44 @@ void TestPredefinedMarkers() {
MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer<
mozilla::baseprofiler::markers::Tracing>(
buffer, std::string_view("tracing"),
mozilla::baseprofiler::category::OTHER, "category"));
mozilla::baseprofiler::category::OTHER, {}, "category"));
MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer<
mozilla::baseprofiler::markers::UserTimingMark>(
buffer, std::string_view("mark"), mozilla::baseprofiler::category::OTHER,
"mark name"));
{}, "mark name"));
MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer<
mozilla::baseprofiler::markers::UserTimingMeasure>(
buffer, std::string_view("measure"),
mozilla::baseprofiler::category::OTHER, "measure name ",
mozilla::baseprofiler::category::OTHER, {}, "measure name ",
mozilla::Some(mozilla::ProfilerString8View(" start ")),
mozilla::Some(mozilla::ProfilerString8View("end"))));
MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer<
mozilla::baseprofiler::markers::Hang>(
buffer, std::string_view("hang"),
mozilla::baseprofiler::category::OTHER));
buffer, std::string_view("hang"), mozilla::baseprofiler::category::OTHER,
{}));
MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer<
mozilla::baseprofiler::markers::LongTask>(
buffer, std::string_view("long task"),
mozilla::baseprofiler::category::OTHER));
mozilla::baseprofiler::category::OTHER, {}));
MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer<
mozilla::baseprofiler::markers::Text>(
buffer, std::string_view("text"), mozilla::baseprofiler::category::OTHER,
"text text"));
{}, "text text"));
MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer<
mozilla::baseprofiler::markers::Log>(
buffer, std::string_view("log"), mozilla::baseprofiler::category::OTHER,
"module", "text"));
{}, "module", "text"));
MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer<
mozilla::baseprofiler::markers::MediaSample>(
buffer, std::string_view("media"), mozilla::baseprofiler::category::OTHER,
123, 456));
{}, 123, 456));
# ifdef DEBUG
buffer.Dump();
@ -3944,7 +3964,7 @@ void TestProfiler() {
# ifndef AUTO_BASE_PROFILER_MARKER_TEXT
# error AUTO_BASE_PROFILER_MARKER_TEXT not #defined
# endif // AUTO_BASE_PROFILER_MARKER_TEXT
AUTO_BASE_PROFILER_MARKER_TEXT(catch, catch, catch);
AUTO_BASE_PROFILER_MARKER_TEXT(catch, catch, catch, catch);
# ifndef AUTO_BASE_PROFILER_LABEL
# error AUTO_BASE_PROFILER_LABEL not #defined
@ -3960,17 +3980,18 @@ void TestProfiler() {
# error BASE_PROFILER_MARKER_UNTYPED not #defined
# endif // BASE_PROFILER_MARKER_UNTYPED
BASE_PROFILER_MARKER_UNTYPED(catch, catch);
BASE_PROFILER_MARKER_UNTYPED(catch, catch, catch);
# ifndef BASE_PROFILER_MARKER
# error BASE_PROFILER_MARKER not #defined
# endif // BASE_PROFILER_MARKER
BASE_PROFILER_MARKER(catch, catch, catch);
BASE_PROFILER_MARKER(catch, catch, catch, catch);
BASE_PROFILER_MARKER(catch, catch, catch, catch, catch);
# ifndef BASE_PROFILER_MARKER_TEXT
# error BASE_PROFILER_MARKER_TEXT not #defined
# endif // BASE_PROFILER_MARKER_TEXT
BASE_PROFILER_MARKER_TEXT(catch, catch, catch);
BASE_PROFILER_MARKER_TEXT(catch, catch, catch, catch);
MOZ_RELEASE_ASSERT(!mozilla::baseprofiler::profiler_get_backtrace(),
"profiler_get_backtrace should return nullptr");

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

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

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

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

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

@ -5428,7 +5428,7 @@ void profiler_add_marker(const char* aMarkerName,
// into the JS engine.
void profiler_add_js_marker(const char* aMarkerName, const char* aMarkerText) {
PROFILER_MARKER_TEXT(
ProfilerString8View::WrapNullTerminatedString(aMarkerName), JS,
ProfilerString8View::WrapNullTerminatedString(aMarkerName), JS, {},
ProfilerString8View::WrapNullTerminatedString(aMarkerText));
}

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

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

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

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

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

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

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

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

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

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