Bug 1675409 - Migrated TextMarkerPayload to Markers 2.0 API - r=gregtatum

Differential Revision: https://phabricator.services.mozilla.com/D96052
This commit is contained in:
Gerald Squelart
2020-11-17 11:38:06 +00:00
parent d8a7039d7c
commit 003bd0368c
12 changed files with 97 additions and 176 deletions

View File

@@ -154,10 +154,13 @@ void TimeoutManager::MoveIdleToActive() {
int(elapsed.ToMilliseconds()), int(target.ToMilliseconds()), int(elapsed.ToMilliseconds()), int(target.ToMilliseconds()),
int(delta.ToMilliseconds())); int(delta.ToMilliseconds()));
// don't have end before start... // don't have end before start...
PROFILER_ADD_MARKER_WITH_PAYLOAD( PROFILER_MARKER_TEXT(
"setTimeout deferred release", DOM, TextMarkerPayload, "setTimeout deferred release", DOM,
(marker, delta.ToMilliseconds() >= 0 ? timeout->When() : now, now, MarkerOptions(
Some(mWindow.WindowID()))); MarkerTiming::Interval(
delta.ToMilliseconds() >= 0 ? timeout->When() : now, now),
MarkerInnerWindowId(mWindow.WindowID())),
marker);
} }
#endif #endif
num++; num++;
@@ -905,10 +908,13 @@ void TimeoutManager::RunTimeout(const TimeStamp& aNow,
int(elapsed.ToMilliseconds()), int(target.ToMilliseconds()), int(elapsed.ToMilliseconds()), int(target.ToMilliseconds()),
int(delta.ToMilliseconds()), int(runtime.ToMilliseconds())); int(delta.ToMilliseconds()), int(runtime.ToMilliseconds()));
// don't have end before start... // don't have end before start...
PROFILER_ADD_MARKER_WITH_PAYLOAD( PROFILER_MARKER_TEXT(
"setTimeout", DOM, TextMarkerPayload, "setTimeout", DOM,
(marker, delta.ToMilliseconds() >= 0 ? timeout->When() : now, now, MarkerOptions(
Some(mWindow.WindowID()))); MarkerTiming::Interval(
delta.ToMilliseconds() >= 0 ? timeout->When() : now, now),
MarkerInnerWindowId(mWindow.WindowID())),
marker);
} }
#endif #endif

View File

@@ -179,10 +179,13 @@ void nsDOMNavigationTiming::NotifyLoadEventEnd() {
"Document %s loaded after %dms, load event duration %dms", spec.get(), "Document %s loaded after %dms, load event duration %dms", spec.get(),
int(elapsed.ToMilliseconds()), int(duration.ToMilliseconds())); int(elapsed.ToMilliseconds()), int(duration.ToMilliseconds()));
PAGELOAD_LOG(("%s", marker.get())); PAGELOAD_LOG(("%s", marker.get()));
PROFILER_ADD_MARKER_WITH_PAYLOAD( PROFILER_MARKER_TEXT(
"DocumentLoad", DOM, TextMarkerPayload, "DocumentLoad", DOM,
(marker, mNavigationStart, mLoadEventEnd, MarkerOptions(
profiler_get_inner_window_id_from_docshell(mDocShell))); MarkerTiming::Interval(mNavigationStart, mLoadEventEnd),
MarkerInnerWindowId(
profiler_get_inner_window_id_from_docshell(mDocShell))),
marker);
} }
#endif #endif
TimeStamp loadEventEnd = TimeStamp::Now(); TimeStamp loadEventEnd = TimeStamp::Now();
@@ -377,10 +380,13 @@ void nsDOMNavigationTiming::TTITimeout(nsITimer* aTimer) {
int(elapsed.ToMilliseconds()), int(elapsed.ToMilliseconds()),
int(elapsedLongTask.ToMilliseconds()), spec.get()); int(elapsedLongTask.ToMilliseconds()), spec.get());
PROFILER_ADD_MARKER_WITH_PAYLOAD( PROFILER_MARKER_TEXT(
"TimeToFirstInteractive (TTFI)", DOM, TextMarkerPayload, "TimeToFirstInteractive (TTFI)", DOM,
(marker, mNavigationStart, mTTFI, MarkerOptions(
profiler_get_inner_window_id_from_docshell(mDocShell))); MarkerTiming::Interval(mNavigationStart, mTTFI),
MarkerInnerWindowId(
profiler_get_inner_window_id_from_docshell(mDocShell))),
marker);
} }
#endif #endif
} }
@@ -410,10 +416,13 @@ void nsDOMNavigationTiming::NotifyNonBlankPaintForRootContentDocument() {
: "this tab was inactive some of the time between navigation start " : "this tab was inactive some of the time between navigation start "
"and first non-blank paint"); "and first non-blank paint");
PAGELOAD_LOG(("%s", marker.get())); PAGELOAD_LOG(("%s", marker.get()));
PROFILER_ADD_MARKER_WITH_PAYLOAD( PROFILER_MARKER_TEXT(
"FirstNonBlankPaint", DOM, TextMarkerPayload, "FirstNonBlankPaint", DOM,
(marker, mNavigationStart, mNonBlankPaint, MarkerOptions(
profiler_get_inner_window_id_from_docshell(mDocShell))); MarkerTiming::Interval(mNavigationStart, mNonBlankPaint),
MarkerInnerWindowId(
profiler_get_inner_window_id_from_docshell(mDocShell))),
marker);
} }
#endif #endif
@@ -459,10 +468,13 @@ void nsDOMNavigationTiming::NotifyContentfulPaintForRootContentDocument(
: "this tab was inactive some of the time between navigation start " : "this tab was inactive some of the time between navigation start "
"and first non-blank paint"); "and first non-blank paint");
PAGELOAD_LOG(("%s", marker.get())); PAGELOAD_LOG(("%s", marker.get()));
PROFILER_ADD_MARKER_WITH_PAYLOAD( PROFILER_MARKER_TEXT(
"FirstContentfulPaint", DOM, TextMarkerPayload, "FirstContentfulPaint", DOM,
(marker, mNavigationStart, mContentfulPaint, MarkerOptions(
profiler_get_inner_window_id_from_docshell(mDocShell))); MarkerTiming::Interval(mNavigationStart, mContentfulPaint),
MarkerInnerWindowId(
profiler_get_inner_window_id_from_docshell(mDocShell))),
marker);
} }
#endif #endif
@@ -508,10 +520,13 @@ void nsDOMNavigationTiming::NotifyDOMContentFlushedForRootContentDocument() {
: "this tab was inactive some of the time between navigation start " : "this tab was inactive some of the time between navigation start "
"and DOMContentFlushed"); "and DOMContentFlushed");
PAGELOAD_LOG(("%s", marker.get())); PAGELOAD_LOG(("%s", marker.get()));
PROFILER_ADD_MARKER_WITH_PAYLOAD( PROFILER_MARKER_TEXT(
"DOMContentFlushed", DOM, TextMarkerPayload, "DOMContentFlushed", DOM,
(marker, mNavigationStart, mDOMContentFlushed, MarkerOptions(
profiler_get_inner_window_id_from_docshell(mDocShell))); MarkerTiming::Interval(mNavigationStart, mDOMContentFlushed),
MarkerInnerWindowId(
profiler_get_inner_window_id_from_docshell(mDocShell))),
marker);
} }
#endif #endif
} }

View File

@@ -918,9 +918,7 @@ already_AddRefed<ContentParent> ContentParent::GetUsedBrowserProcess(
if (profiler_thread_is_being_profiled()) { if (profiler_thread_is_being_profiled()) {
nsPrintfCString marker("Reused process %u", nsPrintfCString marker("Reused process %u",
(unsigned int)retval->ChildID()); (unsigned int)retval->ChildID());
TimeStamp now = TimeStamp::Now(); PROFILER_MARKER_TEXT("Process", DOM, {}, marker);
PROFILER_ADD_MARKER_WITH_PAYLOAD("Process", DOM, TextMarkerPayload,
(marker, now, now));
} }
#endif #endif
MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug, MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug,
@@ -959,9 +957,7 @@ already_AddRefed<ContentParent> ContentParent::GetUsedBrowserProcess(
if (profiler_thread_is_being_profiled()) { if (profiler_thread_is_being_profiled()) {
nsPrintfCString marker("Recycled process %u (%p)", nsPrintfCString marker("Recycled process %u (%p)",
(unsigned int)recycled->ChildID(), recycled.get()); (unsigned int)recycled->ChildID(), recycled.get());
TimeStamp now = TimeStamp::Now(); PROFILER_MARKER_TEXT("Process", DOM, {}, marker);
PROFILER_ADD_MARKER_WITH_PAYLOAD("Process", DOM, TextMarkerPayload,
(marker, now, now));
} }
#endif #endif
MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug, MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug,
@@ -984,9 +980,7 @@ already_AddRefed<ContentParent> ContentParent::GetUsedBrowserProcess(
if (profiler_thread_is_being_profiled()) { if (profiler_thread_is_being_profiled()) {
nsPrintfCString marker("Assigned preallocated process %u", nsPrintfCString marker("Assigned preallocated process %u",
(unsigned int)preallocated->ChildID()); (unsigned int)preallocated->ChildID());
TimeStamp now = TimeStamp::Now(); PROFILER_MARKER_TEXT("Process", DOM, {}, marker);
PROFILER_ADD_MARKER_WITH_PAYLOAD("Process", DOM, TextMarkerPayload,
(marker, now, now));
} }
#endif #endif
MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug, MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug,
@@ -2423,9 +2417,10 @@ bool ContentParent::LaunchSubprocessResolve(bool aIsSync,
nsPrintfCString marker("Process start%s for %u", nsPrintfCString marker("Process start%s for %u",
mIsAPreallocBlocker ? " (immediate)" : "", mIsAPreallocBlocker ? " (immediate)" : "",
(unsigned int)ChildID()); (unsigned int)ChildID());
PROFILER_ADD_MARKER_WITH_PAYLOAD( PROFILER_MARKER_TEXT(
mIsAPreallocBlocker ? "Process Immediate Launch" : "Process Launch", mIsAPreallocBlocker ? ProfilerString8View("Process Immediate Launch")
DOM, TextMarkerPayload, (marker, mLaunchTS, launchResumeTS)); : ProfilerString8View("Process Launch"),
DOM, MarkerTiming::Interval(mLaunchTS, launchResumeTS), marker);
} }
#endif #endif

View File

@@ -15,7 +15,6 @@
#include "mozilla/Logging.h" #include "mozilla/Logging.h"
#include "mozilla/MathAlgorithms.h" #include "mozilla/MathAlgorithms.h"
#include "mozilla/NotNull.h" #include "mozilla/NotNull.h"
#include "mozilla/ProfilerMarkerTypes.h"
#include "mozilla/SharedThreadPool.h" #include "mozilla/SharedThreadPool.h"
#include "mozilla/Sprintf.h" #include "mozilla/Sprintf.h"
#include "mozilla/StaticPrefs_media.h" #include "mozilla/StaticPrefs_media.h"
@@ -28,6 +27,7 @@
#include "AudioSegment.h" #include "AudioSegment.h"
#include "DOMMediaStream.h" #include "DOMMediaStream.h"
#include "ImageContainer.h" #include "ImageContainer.h"
#include "GeckoProfiler.h"
#include "MediaDecoder.h" #include "MediaDecoder.h"
#include "MediaDecoderStateMachine.h" #include "MediaDecoderStateMachine.h"
#include "MediaShutdownManager.h" #include "MediaShutdownManager.h"
@@ -39,13 +39,8 @@
#include "VideoUtils.h" #include "VideoUtils.h"
#ifdef MOZ_GECKO_PROFILER #ifdef MOZ_GECKO_PROFILER
# include "ProfilerMarkerPayload.h" # include "mozilla/ProfilerMarkerTypes.h"
# define MDSM_ERROR_MARKER(tag, error, markerTime) \ #endif // MOZ_GECKO_PROFILER
PROFILER_ADD_MARKER_WITH_PAYLOAD(tag, MEDIA_PLAYBACK, TextMarkerPayload, \
(error, markerTime))
#else
# define MDSM_ERROR_MARKER(tag, error, markerTime)
#endif
namespace mozilla { namespace mozilla {
@@ -3468,8 +3463,8 @@ bool MediaDecoderStateMachine::HasLowBufferedData(const TimeUnit& aThreshold) {
void MediaDecoderStateMachine::DecodeError(const MediaResult& aError) { void MediaDecoderStateMachine::DecodeError(const MediaResult& aError) {
MOZ_ASSERT(OnTaskQueue()); MOZ_ASSERT(OnTaskQueue());
LOGE("Decode error: %s", aError.Description().get()); LOGE("Decode error: %s", aError.Description().get());
MDSM_ERROR_MARKER("MDSM::DecodeError", aError.Description(), PROFILER_MARKER_TEXT("MDSM::DecodeError", MEDIA_PLAYBACK, {},
TimeStamp::NowUnfuzzed()); aError.Description());
// Notify the decode error and MediaDecoder will shut down MDSM. // Notify the decode error and MediaDecoder will shut down MDSM.
mOnPlaybackErrorEvent.Notify(aError); mOnPlaybackErrorEvent.Notify(aError);
} }

View File

@@ -42,15 +42,6 @@ mozilla::LazyLogModule gMediaDemuxerLog("MediaDemuxer");
DDMOZ_LOG(sFormatDecoderLog, mozilla::LogLevel::Verbose, "::%s: " arg, \ DDMOZ_LOG(sFormatDecoderLog, mozilla::LogLevel::Verbose, "::%s: " arg, \
__func__, ##__VA_ARGS__) __func__, ##__VA_ARGS__)
#ifdef MOZ_GECKO_PROFILER
# include "ProfilerMarkerPayload.h"
# define MEDIA_FORMAT_READER_STATUS_MARKER(tag, text, markerTime) \
PROFILER_ADD_MARKER_WITH_PAYLOAD(tag, MEDIA_PLAYBACK, TextMarkerPayload, \
(text, markerTime))
#else
# define MEDIA_FORMAT_READER_STATUS_MARKER(tag, text, markerTime)
#endif
#define NS_DispatchToMainThread(...) CompileError_UseAbstractMainThreadInstead #define NS_DispatchToMainThread(...) CompileError_UseAbstractMainThreadInstead
namespace mozilla { namespace mozilla {
@@ -1933,8 +1924,7 @@ void MediaFormatReader::HandleDemuxedSamples(
nsPrintfCString markerString( nsPrintfCString markerString(
"%s stream id changed from:%" PRIu32 " to:%" PRIu32, "%s stream id changed from:%" PRIu32 " to:%" PRIu32,
TrackTypeToStr(aTrack), decoder.mLastStreamSourceID, info->GetID()); TrackTypeToStr(aTrack), decoder.mLastStreamSourceID, info->GetID());
MEDIA_FORMAT_READER_STATUS_MARKER("StreamID Change", markerString, PROFILER_MARKER_TEXT("StreamID Change", MEDIA_PLAYBACK, {}, markerString);
TimeStamp::NowUnfuzzed());
LOG("%s", markerString.get()); LOG("%s", markerString.get());
if (aTrack == TrackInfo::kVideoTrack) { if (aTrack == TrackInfo::kVideoTrack) {
@@ -3152,6 +3142,5 @@ void MediaFormatReader::OnFirstDemuxFailed(TrackInfo::TrackType aType,
} // namespace mozilla } // namespace mozilla
#undef NS_DispatchToMainThread #undef NS_DispatchToMainThread
#undef MEDIA_FORMAT_READER_STATUS_MARKER
#undef LOGV #undef LOGV
#undef LOG #undef LOG

View File

@@ -27,6 +27,7 @@
#include "mozilla/WindowsVersion.h" #include "mozilla/WindowsVersion.h"
#include "mozilla/gfx/gfxVars.h" #include "mozilla/gfx/gfxVars.h"
#include "mozilla/mscom/EnsureMTA.h" #include "mozilla/mscom/EnsureMTA.h"
#include "mozilla/ProfilerMarkers.h"
#include "nsComponentManagerUtils.h" #include "nsComponentManagerUtils.h"
#include "nsIXULRuntime.h" #include "nsIXULRuntime.h"
#include "nsIXULRuntime.h" // for BrowserTabsRemoteAutostart #include "nsIXULRuntime.h" // for BrowserTabsRemoteAutostart
@@ -36,28 +37,19 @@
#define LOG(...) MOZ_LOG(sPDMLog, mozilla::LogLevel::Debug, (__VA_ARGS__)) #define LOG(...) MOZ_LOG(sPDMLog, mozilla::LogLevel::Debug, (__VA_ARGS__))
#ifdef MOZ_GECKO_PROFILER
# include "ProfilerMarkerPayload.h"
# define WFM_DECODER_MODULE_STATUS_MARKER(tag, text, markerTime) \
PROFILER_ADD_MARKER_WITH_PAYLOAD(tag, MEDIA_PLAYBACK, TextMarkerPayload, \
(text, markerTime))
#else
# define WFM_DECODER_MODULE_STATUS_MARKER(tag, text, markerTime)
#endif
extern const GUID CLSID_WebmMfVpxDec; extern const GUID CLSID_WebmMfVpxDec;
namespace mozilla { namespace mozilla {
// Helper function to add a profile marker and log at the same time. // Helper function to add a profile marker and log at the same time.
static void MOZ_FORMAT_PRINTF(2, 3) static void MOZ_FORMAT_PRINTF(2, 3)
WmfDeocderModuleMarkerAndLog(const char* aTag, const char* aFormat, ...) { WmfDeocderModuleMarkerAndLog(const ProfilerString8View& aMarkerTag,
const char* aFormat, ...) {
va_list ap; va_list ap;
va_start(ap, aFormat); va_start(ap, aFormat);
const nsVprintfCString markerString(aFormat, ap); const nsVprintfCString markerString(aFormat, ap);
va_end(ap); va_end(ap);
WFM_DECODER_MODULE_STATUS_MARKER(aTag, markerString, PROFILER_MARKER_TEXT(aMarkerTag, MEDIA_PLAYBACK, {}, markerString);
TimeStamp::NowUnfuzzed());
LOG("%s", markerString.get()); LOG("%s", markerString.get());
} }

View File

@@ -9,6 +9,7 @@
#include "VideoUtils.h" #include "VideoUtils.h"
#include "WMFUtils.h" #include "WMFUtils.h"
#include "mozilla/Logging.h" #include "mozilla/Logging.h"
#include "mozilla/ProfilerMarkers.h"
#include "mozilla/SyncRunnable.h" #include "mozilla/SyncRunnable.h"
#include "mozilla/TaskQueue.h" #include "mozilla/TaskQueue.h"
#include "mozilla/Telemetry.h" #include "mozilla/Telemetry.h"
@@ -16,15 +17,6 @@
#define LOG(...) MOZ_LOG(sPDMLog, mozilla::LogLevel::Debug, (__VA_ARGS__)) #define LOG(...) MOZ_LOG(sPDMLog, mozilla::LogLevel::Debug, (__VA_ARGS__))
#ifdef MOZ_GECKO_PROFILER
# include "ProfilerMarkerPayload.h"
# define WFM_MEDIA_DATA_DECODER_STATUS_MARKER(tag, text, markerTime) \
PROFILER_ADD_MARKER_WITH_PAYLOAD(tag, MEDIA_PLAYBACK, TextMarkerPayload, \
(text, markerTime))
#else
# define WFM_MEDIA_DATA_DECODER_STATUS_MARKER(tag, text, markerTime)
#endif
namespace mozilla { namespace mozilla {
WMFMediaDataDecoder::WMFMediaDataDecoder(MFTManager* aMFTManager) WMFMediaDataDecoder::WMFMediaDataDecoder(MFTManager* aMFTManager)
@@ -102,8 +94,7 @@ RefPtr<MediaDataDecoder::DecodePromise> WMFMediaDataDecoder::ProcessError(
"reason: %s", "reason: %s",
GetDescriptionName().get(), aReason); GetDescriptionName().get(), aReason);
LOG(markerString.get()); LOG(markerString.get());
WFM_MEDIA_DATA_DECODER_STATUS_MARKER("WMFDecoder Error", markerString, PROFILER_MARKER_TEXT("WMFDecoder Error", MEDIA_PLAYBACK, {}, markerString);
TimeStamp::NowUnfuzzed());
// TODO: For the error DXGI_ERROR_DEVICE_RESET, we could return // TODO: For the error DXGI_ERROR_DEVICE_RESET, we could return
// NS_ERROR_DOM_MEDIA_NEED_NEW_DECODER to get the latest device. Maybe retry // NS_ERROR_DOM_MEDIA_NEED_NEW_DECODER to get the latest device. Maybe retry

View File

@@ -13,18 +13,10 @@
#include "MediaInfo.h" #include "MediaInfo.h"
#include "PDMFactory.h" #include "PDMFactory.h"
#include "VPXDecoder.h" #include "VPXDecoder.h"
#include "mozilla/ProfilerMarkers.h"
#include "mozilla/StaticPrefs_media.h" #include "mozilla/StaticPrefs_media.h"
#include "mozilla/TaskQueue.h" #include "mozilla/TaskQueue.h"
#ifdef MOZ_GECKO_PROFILER
# include "ProfilerMarkerPayload.h"
# define MEDIA_CHANGE_MONITOR_STATUS_MARKER(tag, text, markerTime) \
PROFILER_ADD_MARKER_WITH_PAYLOAD(tag, MEDIA_PLAYBACK, TextMarkerPayload, \
(text, markerTime))
#else
# define MEDIA_CHANGE_MONITOR_STATUS_MARKER(tag, text, markerTime)
#endif
namespace mozilla { namespace mozilla {
// H264ChangeMonitor is used to ensure that only AVCC or AnnexB is fed to the // H264ChangeMonitor is used to ensure that only AVCC or AnnexB is fed to the
@@ -98,11 +90,9 @@ class H264ChangeMonitor : public MediaChangeMonitor::CodecChangeMonitor {
mPreviousExtraData = aSample->mExtraData; mPreviousExtraData = aSample->mExtraData;
UpdateConfigFromExtraData(extra_data); UpdateConfigFromExtraData(extra_data);
MEDIA_CHANGE_MONITOR_STATUS_MARKER( PROFILER_MARKER_TEXT("H264 Stream Change", MEDIA_PLAYBACK, {},
"H264 Stream Change", "H264ChangeMonitor::CheckForChange has detected a "
"H264ChangeMonitor::CheckForChange has detected a change in the " "change in the stream and will request a new decoder");
"stream and will request a new decoder"_ns,
TimeStamp::NowUnfuzzed());
return NS_ERROR_DOM_MEDIA_NEED_NEW_DECODER; return NS_ERROR_DOM_MEDIA_NEED_NEW_DECODER;
} }
@@ -204,11 +194,10 @@ class VPXChangeMonitor : public MediaChangeMonitor::CodecChangeMonitor {
mCurrentConfig.SetImageRect( mCurrentConfig.SetImageRect(
gfx::IntRect(0, 0, info.mImage.width, info.mImage.height)); gfx::IntRect(0, 0, info.mImage.width, info.mImage.height));
MEDIA_CHANGE_MONITOR_STATUS_MARKER( PROFILER_MARKER_TEXT(
"VPX Stream Change", "VPX Stream Change", MEDIA_PLAYBACK, {},
"VPXChangeMonitor::CheckForChange has detected a change in the " "VPXChangeMonitor::CheckForChange has detected a change in the "
"stream and will request a new decoder"_ns, "stream and will request a new decoder");
TimeStamp::NowUnfuzzed());
rv = NS_ERROR_DOM_MEDIA_NEED_NEW_DECODER; rv = NS_ERROR_DOM_MEDIA_NEED_NEW_DECODER;
} }
mInfo = Some(info); mInfo = Some(info);
@@ -755,5 +744,3 @@ void MediaChangeMonitor::FlushThenShutdownDecoder(
} }
} // namespace mozilla } // namespace mozilla
#undef MEDIA_CHANGE_MONITOR_STATUS_MARKER

View File

@@ -24,6 +24,7 @@
#include "js/SourceText.h" #include "js/SourceText.h"
#include "js/Utility.h" #include "js/Utility.h"
#include "xpcpublic.h" #include "xpcpublic.h"
#include "GeckoProfiler.h"
#include "nsCycleCollectionParticipant.h" #include "nsCycleCollectionParticipant.h"
#include "nsIContent.h" #include "nsIContent.h"
#include "nsJSUtils.h" #include "nsJSUtils.h"
@@ -83,10 +84,6 @@
#include "nsIScriptError.h" #include "nsIScriptError.h"
#include "nsIAsyncOutputStream.h" #include "nsIAsyncOutputStream.h"
#ifdef MOZ_GECKO_PROFILER
# include "ProfilerMarkerPayload.h"
#endif
using JS::SourceText; using JS::SourceText;
using mozilla::Telemetry::LABELS_DOM_SCRIPT_PRELOAD_RESULT; using mozilla::Telemetry::LABELS_DOM_SCRIPT_PRELOAD_RESULT;
@@ -2180,7 +2177,7 @@ NotifyOffThreadScriptLoadCompletedRunnable::Run() {
#ifdef MOZ_GECKO_PROFILER #ifdef MOZ_GECKO_PROFILER
if (profiler_is_active()) { if (profiler_is_active()) {
const char* scriptSourceString; ProfilerString8View scriptSourceString;
if (request->IsTextSource()) { if (request->IsTextSource()) {
scriptSourceString = "ScriptCompileOffThread"; scriptSourceString = "ScriptCompileOffThread";
} else if (request->IsBinASTSource()) { } else if (request->IsBinASTSource()) {
@@ -2192,10 +2189,11 @@ NotifyOffThreadScriptLoadCompletedRunnable::Run() {
nsAutoCString profilerLabelString; nsAutoCString profilerLabelString;
GetProfilerLabelForRequest(request, profilerLabelString); GetProfilerLabelForRequest(request, profilerLabelString);
PROFILER_ADD_MARKER_WITH_PAYLOAD( PROFILER_MARKER_TEXT(
scriptSourceString, JS, TextMarkerPayload, scriptSourceString, JS,
(profilerLabelString, request->mOffThreadParseStartTime, MarkerTiming::Interval(request->mOffThreadParseStartTime,
request->mOffThreadParseStopTime)); request->mOffThreadParseStopTime),
profilerLabelString);
} }
#endif #endif

View File

@@ -63,9 +63,6 @@
#include "nsIXULRuntime.h" #include "nsIXULRuntime.h"
#include "nsJSPrincipals.h" #include "nsJSPrincipals.h"
#include "ExpandedPrincipal.h" #include "ExpandedPrincipal.h"
#ifdef MOZ_GECKO_PROFILER
# include "ProfilerMarkerPayload.h"
#endif
#if defined(XP_LINUX) && !defined(ANDROID) #if defined(XP_LINUX) && !defined(ANDROID)
// For getrlimit and min/max. // For getrlimit and min/max.
@@ -591,9 +588,7 @@ bool XPCJSContext::InterruptCallback(JSContext* cx) {
if (const char* file = scriptFilename.get()) { if (const char* file = scriptFilename.get()) {
filename.Assign(file, strlen(file)); filename.Assign(file, strlen(file));
} }
PROFILER_ADD_MARKER_WITH_PAYLOAD("JS::InterruptCallback", JS, PROFILER_MARKER_TEXT("JS::InterruptCallback", JS, {}, filename);
TextMarkerPayload,
(filename, TimeStamp::Now()));
} }
#endif #endif

View File

@@ -2783,19 +2783,15 @@ static void CollectJavaThreadProfileData(ProfileBuffer& aProfileBuffer) {
if (!text) { if (!text) {
// This marker doesn't have a text. // This marker doesn't have a text.
StoreMarker(aProfileBuffer.UnderlyingChunkedBuffer(), threadId, AddMarkerToBuffer(aProfileBuffer.UnderlyingChunkedBuffer(), markerName,
markerName.get(), timing, geckoprofiler::category::JAVA_ANDROID,
JS::ProfilingCategoryPair::JAVA_ANDROID, nullptr); {MarkerThreadId(threadId), std::move(timing)});
} else { } else {
// This marker has a text. // This marker has a text.
nsCString textString = text->ToCString(); AddMarkerToBuffer(aProfileBuffer.UnderlyingChunkedBuffer(), markerName,
const TextMarkerPayload payload(textString, startTime, endTime, Nothing(), geckoprofiler::category::JAVA_ANDROID,
nullptr); {MarkerThreadId(threadId), std::move(timing)},
geckoprofiler::markers::Text{}, text->ToCString());
// Put the marker inside the buffer.
StoreMarker(aProfileBuffer.UnderlyingChunkedBuffer(), threadId,
markerName.get(), timing,
JS::ProfilingCategoryPair::JAVA_ANDROID, &payload);
} }
} }
} }
@@ -5109,10 +5105,8 @@ ProfilingStack* profiler_register_thread(const char* aName,
text.AppendLiteral("\" attempted to re-register as \""); text.AppendLiteral("\" attempted to re-register as \"");
text.AppendASCII(aName); text.AppendASCII(aName);
text.AppendLiteral("\""); text.AppendLiteral("\"");
maybelocked_profiler_add_marker_for_thread( PROFILER_MARKER_TEXT("profiler_register_thread again", OTHER_Profiling,
profiler_main_thread_id(), JS::ProfilingCategoryPair::OTHER_Profiling, MarkerThreadId::MainThread(), text);
"profiler_register_thread again",
TextMarkerPayload(text, TimeStamp::NowUnfuzzed()), &lock);
return &thread->RacyRegisteredThread().ProfilingStack(); return &thread->RacyRegisteredThread().ProfilingStack();
} }
@@ -5192,10 +5186,8 @@ void profiler_unregister_thread() {
tid != profiler_main_thread_id()) { tid != profiler_main_thread_id()) {
nsCString threadIdString; nsCString threadIdString;
threadIdString.AppendInt(tid); threadIdString.AppendInt(tid);
maybelocked_profiler_add_marker_for_thread( PROFILER_MARKER_TEXT("profiler_unregister_thread again", OTHER_Profiling,
profiler_main_thread_id(), JS::ProfilingCategoryPair::OTHER_Profiling, MarkerThreadId::MainThread(), threadIdString);
"profiler_unregister_thread again",
TextMarkerPayload(threadIdString, TimeStamp::NowUnfuzzed()), &lock);
} }
} }
} }
@@ -5804,18 +5796,6 @@ void profiler_tracing_marker(const char* aCategoryString,
aInnerWindowID, std::move(aCause))); aInnerWindowID, std::move(aCause)));
} }
void profiler_add_text_marker(const char* aMarkerName, const nsACString& aText,
JS::ProfilingCategoryPair aCategoryPair,
const mozilla::TimeStamp& aStartTime,
const mozilla::TimeStamp& aEndTime,
const mozilla::Maybe<uint64_t>& aInnerWindowID,
UniqueProfilerBacktrace aCause) {
AUTO_PROFILER_STATS(add_marker_with_TextMarkerPayload);
profiler_add_marker(aMarkerName, aCategoryPair,
TextMarkerPayload(aText, aStartTime, aEndTime,
aInnerWindowID, std::move(aCause)));
}
void profiler_set_js_context(JSContext* aCx) { void profiler_set_js_context(JSContext* aCx) {
MOZ_ASSERT(aCx); MOZ_ASSERT(aCx);

View File

@@ -829,15 +829,10 @@ TEST(GeckoProfiler, Markers)
/* const mozilla::Maybe<nsDependentCString>& aContentType = /* const mozilla::Maybe<nsDependentCString>& aContentType =
mozilla::Nothing() */); mozilla::Nothing() */);
PROFILER_ADD_MARKER_WITH_PAYLOAD("TextMarkerPayload marker 1", OTHER,
TextMarkerPayload, ("text"_ns, ts1));
PROFILER_ADD_MARKER_WITH_PAYLOAD("TextMarkerPayload marker 2", OTHER,
TextMarkerPayload, ("text"_ns, ts1, ts2));
MOZ_RELEASE_ASSERT(profiler_add_marker( MOZ_RELEASE_ASSERT(profiler_add_marker(
"Text in main thread with stack", geckoprofiler::category::OTHER, "Text in main thread with stack", geckoprofiler::category::OTHER,
MarkerStack::Capture(), geckoprofiler::markers::Text{}, "")); {MarkerStack::Capture(), MarkerTiming::Interval(ts1, ts2)},
geckoprofiler::markers::Text{}, ""));
MOZ_RELEASE_ASSERT(profiler_add_marker( MOZ_RELEASE_ASSERT(profiler_add_marker(
"Text from main thread with stack", geckoprofiler::category::OTHER, "Text from main thread with stack", geckoprofiler::category::OTHER,
MarkerOptions(MarkerThreadId::MainThread(), MarkerStack::Capture()), MarkerOptions(MarkerThreadId::MainThread(), MarkerStack::Capture()),
@@ -932,8 +927,6 @@ TEST(GeckoProfiler, Markers)
S_NetworkMarkerPayload_start, S_NetworkMarkerPayload_start,
S_NetworkMarkerPayload_stop, S_NetworkMarkerPayload_stop,
S_NetworkMarkerPayload_redirect, S_NetworkMarkerPayload_redirect,
S_TextMarkerPayload1,
S_TextMarkerPayload2,
S_TextWithStack, S_TextWithStack,
S_TextToMTWithStack, S_TextToMTWithStack,
S_RegThread_TextToMTWithStack, S_RegThread_TextToMTWithStack,
@@ -1319,27 +1312,12 @@ TEST(GeckoProfiler, Markers)
"http://example.com/"); "http://example.com/");
EXPECT_TRUE(payload["contentType"].isNull()); EXPECT_TRUE(payload["contentType"].isNull());
} else if (nameString == "TextMarkerPayload marker 1") {
EXPECT_EQ(state, S_TextMarkerPayload1);
state = State(S_TextMarkerPayload1 + 1);
EXPECT_EQ(typeString, "Text");
EXPECT_TIMING_INSTANT_AT(ts1Double);
EXPECT_TRUE(payload["stack"].isNull());
EXPECT_EQ_JSON(payload["name"], String, "text");
} else if (nameString == "TextMarkerPayload marker 2") {
EXPECT_EQ(state, S_TextMarkerPayload2);
state = State(S_TextMarkerPayload2 + 1);
EXPECT_EQ(typeString, "Text");
EXPECT_TIMING_INTERVAL_AT(ts1Double, ts2Double);
EXPECT_TRUE(payload["stack"].isNull());
EXPECT_EQ_JSON(payload["name"], String, "text");
} else if (nameString == "Text in main thread with stack") { } else if (nameString == "Text in main thread with stack") {
EXPECT_EQ(state, S_TextWithStack); EXPECT_EQ(state, S_TextWithStack);
state = State(S_TextWithStack + 1); state = State(S_TextWithStack + 1);
EXPECT_EQ(typeString, "Text"); EXPECT_EQ(typeString, "Text");
EXPECT_FALSE(payload["stack"].isNull()); EXPECT_FALSE(payload["stack"].isNull());
EXPECT_TIMING_INTERVAL_AT(ts1Double, ts2Double);
EXPECT_EQ_JSON(payload["name"], String, ""); EXPECT_EQ_JSON(payload["name"], String, "");
} else if (nameString == "Text from main thread with stack") { } else if (nameString == "Text from main thread with stack") {