diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:14:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:14:29 +0000 |
commit | fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8 (patch) | |
tree | 4c1ccaf5486d4f2009f9a338a98a83e886e29c97 /tools/profiler | |
parent | Releasing progress-linux version 124.0.1-1~progress7.99u1. (diff) | |
download | firefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.tar.xz firefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.zip |
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tools/profiler')
28 files changed, 251 insertions, 282 deletions
diff --git a/tools/profiler/core/ETWTools.cpp b/tools/profiler/core/ETWTools.cpp index b8fab9b316..50b5588392 100644 --- a/tools/profiler/core/ETWTools.cpp +++ b/tools/profiler/core/ETWTools.cpp @@ -11,13 +11,24 @@ namespace ETW { std::atomic<ULONGLONG> gETWCollectionMask = 0; -// Define a handle to a TraceLogging provider +// Define a handle to a TraceLogging provider. +// +// > All ETW providers are identified by both provider name and provider ID. +// > [...] +// > Microsoft recommends generating the provider ID from the provider name +// > using the ETW name-hashing algorithm described below. This provides +// > several benefits: it's easier to remember just the name; the ID and the +// > name are automatically linked; tools such as tracelog, traceview, +// > EventSource, and WPR have special support for providers that use IDs +// > generated using this algorithm. +// +// https://learn.microsoft.com/en-us/windows/win32/api/traceloggingprovider/nf-traceloggingprovider-tracelogging_define_provider +// +// The GUID generated for "Mozilla.FirefoxTraceLogger" is: +// {c923f508-96e4-5515-e32c-7539d1b10504} TRACELOGGING_DEFINE_PROVIDER(kFirefoxTraceLoggingProvider, "Mozilla.FirefoxTraceLogger", - // This GUID is a hash generated based on the - // above string. - // {c923f508-96e4-5515-e32c-7539d1b10504} - (0xc923f508, 0x96e4, 0x5515, 0xe3, 0x3c, 0x75, + (0xc923f508, 0x96e4, 0x5515, 0xe3, 0x2c, 0x75, 0x39, 0xd1, 0xb1, 0x05, 0x04)); static void NTAPI ETWEnableCallback(LPCGUID aSourceId, ULONG aIsEnabled, diff --git a/tools/profiler/core/ProfileBuffer.cpp b/tools/profiler/core/ProfileBuffer.cpp index bc6314fa32..d785cf7956 100644 --- a/tools/profiler/core/ProfileBuffer.cpp +++ b/tools/profiler/core/ProfileBuffer.cpp @@ -193,9 +193,10 @@ void ProfileBufferCollector::CollectJitReturnAddr(void* aAddr) { mBuf.AddEntry(ProfileBufferEntry::JitReturnAddr(aAddr)); } -void ProfileBufferCollector::CollectWasmFrame(const char* aLabel) { +void ProfileBufferCollector::CollectWasmFrame( + JS::ProfilingCategoryPair aCategory, const char* aLabel) { mBuf.CollectCodeLocation("", aLabel, 0, 0, Nothing(), Nothing(), - Some(JS::ProfilingCategoryPair::JS_Wasm)); + Some(aCategory)); } void ProfileBufferCollector::CollectProfilingStackFrame( diff --git a/tools/profiler/core/ProfileBuffer.h b/tools/profiler/core/ProfileBuffer.h index 5da34909cc..383c7b16d6 100644 --- a/tools/profiler/core/ProfileBuffer.h +++ b/tools/profiler/core/ProfileBuffer.h @@ -247,7 +247,8 @@ class ProfileBufferCollector final : public ProfilerStackCollector { virtual void CollectNativeLeafAddr(void* aAddr) override; virtual void CollectJitReturnAddr(void* aAddr) override; - virtual void CollectWasmFrame(const char* aLabel) override; + virtual void CollectWasmFrame(JS::ProfilingCategoryPair aCategory, + const char* aLabel) override; virtual void CollectProfilingStackFrame( const js::ProfilingStackFrame& aFrame) override; diff --git a/tools/profiler/core/platform-macos.cpp b/tools/profiler/core/platform-macos.cpp index 356d9f803e..78f000c470 100644 --- a/tools/profiler/core/platform-macos.cpp +++ b/tools/profiler/core/platform-macos.cpp @@ -15,7 +15,6 @@ #include <semaphore.h> #include <signal.h> #include <libkern/OSAtomic.h> -#include <libproc.h> #include <mach/mach.h> #include <mach/semaphore.h> #include <mach/task.h> @@ -83,13 +82,12 @@ static RunningTimes GetProcessRunningTimesDiff( { AUTO_PROFILER_STATS(GetProcessRunningTimes_task_info); - static const auto pid = getpid(); - struct proc_taskinfo pti; - if ((unsigned long)proc_pidinfo(pid, PROC_PIDTASKINFO, 0, &pti, - PROC_PIDTASKINFO_SIZE) >= - PROC_PIDTASKINFO_SIZE) { - newRunningTimes.SetThreadCPUDelta(pti.pti_total_user + - pti.pti_total_system); + task_power_info_data_t task_power_info; + mach_msg_type_number_t count = TASK_POWER_INFO_COUNT; + if (task_info(mach_task_self(), TASK_POWER_INFO, + (task_info_t)&task_power_info, &count) == KERN_SUCCESS) { + newRunningTimes.SetThreadCPUDelta(task_power_info.total_user + + task_power_info.total_system); } newRunningTimes.SetPostMeasurementTimeStamp(TimeStamp::Now()); }; diff --git a/tools/profiler/core/platform.cpp b/tools/profiler/core/platform.cpp index e4af84ed4c..8ce029402b 100644 --- a/tools/profiler/core/platform.cpp +++ b/tools/profiler/core/platform.cpp @@ -114,7 +114,7 @@ # include "mozilla/jni/Refs.h" #endif -#if defined(GP_OS_darwin) +#if defined(XP_MACOSX) # include "nsCocoaFeatures.h" #endif @@ -275,7 +275,7 @@ class GeckoJavaSampler featureStringArray.length()); // 128 * 1024 * 1024 is the entries preset that is given in - // devtools/client/performance-new/shared/background.jsm.js + // devtools/client/performance-new/shared/background.sys.mjs profiler_start(PowerOfTwo32(128 * 1024 * 1024), 5.0, features, filtersTemp.begin(), filtersTemp.length(), 0, Nothing()); } @@ -2055,8 +2055,10 @@ static void MergeStacks( // the buffer, nsRefreshDriver would now be holding on to a backtrace // with stale JIT code return addresses. if (aIsSynchronous || - jsFrame.kind == JS::ProfilingFrameIterator::Frame_Wasm) { - aCollector.CollectWasmFrame(jsFrame.label); + jsFrame.kind == JS::ProfilingFrameIterator::Frame_WasmIon || + jsFrame.kind == JS::ProfilingFrameIterator::Frame_WasmBaseline || + jsFrame.kind == JS::ProfilingFrameIterator::Frame_WasmOther) { + aCollector.CollectWasmFrame(jsFrame.profilingCategory(), jsFrame.label); } else if (jsFrame.kind == JS::ProfilingFrameIterator::Frame_BaselineInterpreter) { // Materialize a ProfilingStackFrame similar to the C++ Interpreter. We @@ -2803,7 +2805,7 @@ static PreRecordedMetaInformation PreRecordMetaInformation( !NS_FAILED(res) && http) { Unused << http->GetPlatform(info.mHttpPlatform); -#if defined(GP_OS_darwin) +#if defined(XP_MACOSX) // On Mac, the http "oscpu" is capped at 10.15, so we need to get the real // OS version directly. int major = 0; diff --git a/tools/profiler/docs/markers-guide.rst b/tools/profiler/docs/markers-guide.rst index 86744c523c..ed18b35867 100644 --- a/tools/profiler/docs/markers-guide.rst +++ b/tools/profiler/docs/markers-guide.rst @@ -319,7 +319,7 @@ A marker type must have a unique name, it is used to keep track of the type of markers in the profiler storage, and to identify them uniquely on profiler.firefox.com. (It does not need to be the same as the ``struct``'s name.) -This name is defined in a special static data member ``Name``: +This type name is defined in a special static data member ``Name``: .. code-block:: cpp @@ -333,6 +333,14 @@ In addition you must add a description of your marker in a special static data m // … static constexpr const char* Description = "This is my marker!"; +If you expect users to be passing unique names for individual instances of the marker, +you may want to add the following to ensure those names get stored when using ETW: + +.. code-block:: cpp + + // … + static constexpr bool StoreName = true; + Marker Type Data ^^^^^^^^^^^^^^^^ diff --git a/tools/profiler/gecko/ChildProfilerController.cpp b/tools/profiler/gecko/ChildProfilerController.cpp index f51cb9437d..864e45f683 100644 --- a/tools/profiler/gecko/ChildProfilerController.cpp +++ b/tools/profiler/gecko/ChildProfilerController.cpp @@ -77,9 +77,9 @@ void ChildProfilerController::ShutdownAndMaybeGrabShutdownProfileFirst( } if (profilerChildThread) { if (profiler_is_active()) { - CrashReporter::AnnotateCrashReport( + CrashReporter::RecordAnnotationCString( CrashReporter::Annotation::ProfilerChildShutdownPhase, - "Profiling - Dispatching ShutdownProfilerChild"_ns); + "Profiling - Dispatching ShutdownProfilerChild"); profilerChildThread->Dispatch( NewRunnableMethod<ProfileAndAdditionalInformation*>( "ChildProfilerController::ShutdownProfilerChild", this, @@ -90,9 +90,9 @@ void ChildProfilerController::ShutdownAndMaybeGrabShutdownProfileFirst( // (including the ShutdownProfilerChild runnable) have been processed. profilerChildThread->Shutdown(); } else { - CrashReporter::AnnotateCrashReport( + CrashReporter::RecordAnnotationCString( CrashReporter::Annotation::ProfilerChildShutdownPhase, - "Not profiling - Running ShutdownProfilerChild"_ns); + "Not profiling - Running ShutdownProfilerChild"); // If we're not profiling, this operation will be very quick, so it can be // done synchronously. This avoids having to manually shutdown the thread, // which runs a risky inner event loop, see bug 1613798. @@ -148,23 +148,24 @@ void ChildProfilerController::ShutdownProfilerChild( ProfileAndAdditionalInformation* aOutShutdownProfileInformation) { const bool isProfiling = profiler_is_active(); if (aOutShutdownProfileInformation) { - CrashReporter::AnnotateCrashReport( + CrashReporter::RecordAnnotationCString( CrashReporter::Annotation::ProfilerChildShutdownPhase, - isProfiling ? "Profiling - GrabShutdownProfile"_ns - : "Not profiling - GrabShutdownProfile"_ns); + isProfiling ? "Profiling - GrabShutdownProfile" + : "Not profiling - GrabShutdownProfile"); *aOutShutdownProfileInformation = mProfilerChild->GrabShutdownProfile(); } - CrashReporter::AnnotateCrashReport( + CrashReporter::RecordAnnotationCString( CrashReporter::Annotation::ProfilerChildShutdownPhase, - isProfiling ? "Profiling - Destroying ProfilerChild"_ns - : "Not profiling - Destroying ProfilerChild"_ns); + isProfiling ? "Profiling - Destroying ProfilerChild" + : "Not profiling - Destroying ProfilerChild"); mProfilerChild->Destroy(); mProfilerChild = nullptr; - CrashReporter::AnnotateCrashReport( + CrashReporter::RecordAnnotationCString( CrashReporter::Annotation::ProfilerChildShutdownPhase, - isProfiling - ? "Profiling - ShutdownProfilerChild complete, waiting for thread shutdown"_ns - : "Not Profiling - ShutdownProfilerChild complete, waiting for thread shutdown"_ns); + isProfiling ? "Profiling - ShutdownProfilerChild complete, waiting for " + "thread shutdown" + : "Not Profiling - ShutdownProfilerChild complete, waiting " + "for thread shutdown"); } } // namespace mozilla diff --git a/tools/profiler/public/ETWTools.h b/tools/profiler/public/ETWTools.h index a1d986a6fd..cbd73004ba 100644 --- a/tools/profiler/public/ETWTools.h +++ b/tools/profiler/public/ETWTools.h @@ -22,6 +22,8 @@ namespace ETW { extern std::atomic<ULONGLONG> gETWCollectionMask; +constexpr const char* kNameKey = "MarkerName"; + // Forward-declare the g_hMyComponentProvider variable that you will use for // tracing in this component TRACELOGGING_DECLARE_PROVIDER(kFirefoxTraceLoggingProvider); @@ -29,32 +31,46 @@ TRACELOGGING_DECLARE_PROVIDER(kFirefoxTraceLoggingProvider); void Init(); void Shutdown(); +template <typename T, typename = void> +struct MarkerHasPayload : std::false_type {}; +template <typename T> +struct MarkerHasPayload<T, std::void_t<decltype(T::PayloadFields)>> + : std::true_type {}; + // This describes the base fields for all markers (information extracted from // MarkerOptions. struct BaseMarkerDescription { + static constexpr bool StoreName = false; using MS = mozilla::MarkerSchema; static constexpr MS::PayloadField PayloadFields[] = { {"StartTime", MS::InputType::TimeStamp, "Start Time"}, {"EndTime", MS::InputType::TimeStamp, "End Time"}, + {"Phase", MS::InputType::Uint8, "Phase"}, {"InnerWindowId", MS::InputType::Uint64, "Inner Window ID"}, {"CategoryPair", MS::InputType::Uint32, "Category Pair"}}; }; // This is the MarkerType object for markers with no statically declared type, // their name is written dynamically. -struct SimpleMarkerType { +struct SimpleMarkerType : public mozilla::BaseMarkerType<SimpleMarkerType> { using MS = mozilla::MarkerSchema; + static constexpr const char* Name = "SimpleMarker"; - static constexpr MS::PayloadField PayloadFields[] = { - {"MarkerName", MS::InputType::CString, "Simple Marker Name"}}; + static constexpr bool StoreName = true; }; // This gets the space required in the Tlg static struct to pack the fields. template <typename T> constexpr std::size_t GetPackingSpace() { size_t length = 0; - for (size_t i = 0; i < std::size(T::PayloadFields); i++) { - length += std::string_view{T::PayloadFields[i].Key}.size() + 1; + if constexpr (MarkerHasPayload<T>::value) { + for (size_t i = 0; i < std::size(T::PayloadFields); i++) { + length += std::string_view{T::PayloadFields[i].Key}.size() + 1; + length += sizeof(uint8_t); + } + } + if (T::StoreName) { + length += std::string_view{kNameKey}.size() + 1; length += sizeof(uint8_t); } return length; @@ -65,6 +81,7 @@ constexpr uint8_t GetTlgInputType(mozilla::MarkerSchema::InputType aInput) { using InputType = mozilla::MarkerSchema::InputType; switch (aInput) { case InputType::Boolean: + case InputType::Uint8: return TlgInUINT8; case InputType::Uint32: return TlgInUINT32; @@ -121,12 +138,20 @@ struct StaticMetaData { fieldStorage[pos++] = GetTlgInputType(BaseMarkerDescription::PayloadFields[i].InputTy); } - for (uint32_t i = 0; i < std::size(T::PayloadFields); i++) { - for (size_t c = 0; - c < std::string_view{T::PayloadFields[i].Key}.size() + 1; c++) { - fieldStorage[pos++] = T::PayloadFields[i].Key[c]; + if (T::StoreName) { + for (size_t c = 0; c < std::string_view{kNameKey}.size() + 1; c++) { + fieldStorage[pos++] = kNameKey[c]; + } + fieldStorage[pos++] = TlgInANSISTRING; + } + if constexpr (MarkerHasPayload<T>::value) { + for (uint32_t i = 0; i < std::size(T::PayloadFields); i++) { + for (size_t c = 0; + c < std::string_view{T::PayloadFields[i].Key}.size() + 1; c++) { + fieldStorage[pos++] = T::PayloadFields[i].Key[c]; + } + fieldStorage[pos++] = GetTlgInputType(T::PayloadFields[i].InputTy); } - fieldStorage[pos++] = GetTlgInputType(T::PayloadFields[i].InputTy); } } }; @@ -146,10 +171,11 @@ struct PayloadBuffer { // Theoretically we could probably avoid these assignments when passed a POD // variable we know is going to be alive but that would require some more // template magic. + template <typename T> -static void CreateDataDescForPayload(PayloadBuffer& aBuffer, - EVENT_DATA_DESCRIPTOR& aDescriptor, - const T& aPayload) { +void CreateDataDescForPayloadPOD(PayloadBuffer& aBuffer, + EVENT_DATA_DESCRIPTOR& aDescriptor, + const T& aPayload) { static_assert(std::is_pod<T>::value, "Writing a non-POD payload requires template specialization."); @@ -164,16 +190,22 @@ static void CreateDataDescForPayload(PayloadBuffer& aBuffer, EventDataDescCreate(&aDescriptor, storedValue, sizeof(T)); } -template <> -inline void CreateDataDescForPayload<mozilla::ProfilerString8View>( +static inline void CreateDataDescForPayloadNonPOD( PayloadBuffer& aBuffer, EVENT_DATA_DESCRIPTOR& aDescriptor, const mozilla::ProfilerString8View& aPayload) { EventDataDescCreate(&aDescriptor, aPayload.StringView().data(), aPayload.StringView().size() + 1); } -template <> -inline void CreateDataDescForPayload<mozilla::TimeStamp>( +template <typename T> +static inline void CreateDataDescForPayloadNonPOD( + PayloadBuffer& aBuffer, EVENT_DATA_DESCRIPTOR& aDescriptor, + const mozilla::detail::nsTStringRepr<T>& aPayload) { + EventDataDescCreate(&aDescriptor, aPayload.BeginReading(), + (aPayload.Length() + 1) * sizeof(T)); +} + +static inline void CreateDataDescForPayloadNonPOD( PayloadBuffer& aBuffer, EVENT_DATA_DESCRIPTOR& aDescriptor, const mozilla::TimeStamp& aPayload) { if (aPayload.RawQueryPerformanceCounterValue().isNothing()) { @@ -182,32 +214,25 @@ inline void CreateDataDescForPayload<mozilla::TimeStamp>( return; } - CreateDataDescForPayload(aBuffer, aDescriptor, - aPayload.RawQueryPerformanceCounterValue().value()); + CreateDataDescForPayloadPOD( + aBuffer, aDescriptor, aPayload.RawQueryPerformanceCounterValue().value()); } -template <> -inline void CreateDataDescForPayload<mozilla::TimeDuration>( +static inline void CreateDataDescForPayloadNonPOD( PayloadBuffer& aBuffer, EVENT_DATA_DESCRIPTOR& aDescriptor, const mozilla::TimeDuration& aPayload) { - CreateDataDescForPayload(aBuffer, aDescriptor, aPayload.ToMilliseconds()); + CreateDataDescForPayloadPOD(aBuffer, aDescriptor, aPayload.ToMilliseconds()); } -// For reasons that are beyond me if this isn't marked inline it generates an -// unused function warning despite being a template specialization. -template <typename T> -inline void CreateDataDescForPayload(PayloadBuffer& aBuffer, - EVENT_DATA_DESCRIPTOR& aDescriptor, - const nsTString<T>& aPayload) { - EventDataDescCreate(&aDescriptor, aPayload.BeginReading(), - (aPayload.Length() + 1) * sizeof(T)); -} template <typename T> -inline void CreateDataDescForPayload(PayloadBuffer& aBuffer, - EVENT_DATA_DESCRIPTOR& aDescriptor, - const nsTSubstring<T>& aPayload) { - EventDataDescCreate(&aDescriptor, aPayload.BeginReading(), - (aPayload.Length() + 1) * sizeof(T)); +static inline void CreateDataDescForPayload(PayloadBuffer& aBuffer, + EVENT_DATA_DESCRIPTOR& aDescriptor, + const T& aPayload) { + if constexpr (std::is_pod<T>::value) { + CreateDataDescForPayloadPOD(aBuffer, aDescriptor, aPayload); + } else { + CreateDataDescForPayloadNonPOD(aBuffer, aDescriptor, aPayload); + } } // Template specialization that writes out empty data descriptors for an empty @@ -223,11 +248,17 @@ void CreateDataDescForPayload(PayloadBuffer& aBuffer, } } +template <size_t N> +void CreateDataDescForPayload(PayloadBuffer& aBuffer, + EVENT_DATA_DESCRIPTOR& aDescriptor, + const char (&aPayload)[N]) { + EventDataDescCreate(&aDescriptor, aPayload, N + 1); +} + template <typename T, typename = void> struct MarkerSupportsETW : std::false_type {}; template <typename T> -struct MarkerSupportsETW<T, std::void_t<decltype(T::PayloadFields)>> - : std::true_type {}; +struct MarkerSupportsETW<T, std::void_t<decltype(T::Name)>> : std::true_type {}; template <typename T, typename = void> struct MarkerHasTranslator : std::false_type {}; @@ -239,6 +270,7 @@ struct MarkerHasTranslator< struct BaseEventStorage { uint64_t mStartTime; uint64_t mEndTime; + uint8_t mPhase; uint64_t mWindowID; uint32_t mCategoryPair; }; @@ -247,11 +279,16 @@ static inline void StoreBaseEventDataDesc( BaseEventStorage& aStorage, EVENT_DATA_DESCRIPTOR* aDescriptors, const mozilla::MarkerCategory& aCategory, const mozilla::MarkerOptions& aOptions) { - if (!aOptions.IsTimingUnspecified()) { + if (aOptions.IsTimingUnspecified()) { + aStorage.mStartTime = + mozilla::TimeStamp::Now().RawQueryPerformanceCounterValue().value(); + aStorage.mPhase = 0; + } else { aStorage.mStartTime = aOptions.Timing().StartTime().RawQueryPerformanceCounterValue().value(); aStorage.mEndTime = aOptions.Timing().EndTime().RawQueryPerformanceCounterValue().value(); + aStorage.mPhase = uint8_t(aOptions.Timing().MarkerPhase()); } if (!aOptions.InnerWindowId().IsUnspecified()) { aStorage.mWindowID = aOptions.InnerWindowId().Id(); @@ -259,37 +296,22 @@ static inline void StoreBaseEventDataDesc( aStorage.mCategoryPair = uint32_t(aCategory.CategoryPair()); EventDataDescCreate(&aDescriptors[2], &aStorage.mStartTime, sizeof(uint64_t)); EventDataDescCreate(&aDescriptors[3], &aStorage.mEndTime, sizeof(uint64_t)); - EventDataDescCreate(&aDescriptors[4], &aStorage.mWindowID, sizeof(uint64_t)); - EventDataDescCreate(&aDescriptors[5], &aStorage.mCategoryPair, + EventDataDescCreate(&aDescriptors[4], &aStorage.mPhase, sizeof(uint8_t)); + EventDataDescCreate(&aDescriptors[5], &aStorage.mWindowID, sizeof(uint64_t)); + EventDataDescCreate(&aDescriptors[6], &aStorage.mCategoryPair, sizeof(uint32_t)); } -// This is used for markers with no explicit type or markers which have not -// been converted to the updated schema yet. -static inline void EmitETWMarker(const mozilla::ProfilerString8View& aName, - const mozilla::MarkerCategory& aCategory, - const mozilla::MarkerOptions& aOptions = {}) { - if (!(gETWCollectionMask & - uint64_t(mozilla::MarkerSchema::ETWMarkerGroup::Generic))) { - return; +template <typename MarkerType> +constexpr size_t GetETWDescriptorCount() { + size_t count = 2 + std::size(BaseMarkerDescription::PayloadFields); + if (MarkerType::StoreName) { + count++; } - - static const __declspec(allocate(_tlgSegMetadataEvents)) __declspec( - align(1)) constexpr StaticMetaData<SimpleMarkerType> - staticData; - - std::array<EVENT_DATA_DESCRIPTOR, 7> descriptors = {}; - - // This is storage space allocated on the stack for POD values. - BaseEventStorage dataStorage = {}; - - StoreBaseEventDataDesc(dataStorage, descriptors.data(), aCategory, - std::move(aOptions)); - - EventDataDescCreate(&descriptors[6], aName.StringView().data(), - aName.StringView().size() + 1); - _tlgWriteTransfer(kFirefoxTraceLoggingProvider, &staticData.metaData.Channel, - NULL, NULL, descriptors.size(), descriptors.data()); + if constexpr (MarkerHasPayload<MarkerType>::value) { + count += std::size(MarkerType::PayloadFields); + } + return count; } template <typename MarkerType, typename... PayloadArguments> @@ -301,7 +323,7 @@ static inline void EmitETWMarker(const mozilla::ProfilerString8View& aName, // If our MarkerType has not been made to support ETW, emit only the base // event. Avoid attempting to compile the rest of the function. if constexpr (!MarkerSupportsETW<MarkerType>::value) { - return EmitETWMarker(aName, aCategory, aOptions); + return EmitETWMarker(aName, aCategory, aOptions, SimpleMarkerType{}); } else { if (!(gETWCollectionMask & uint64_t(MarkerType::Group))) { return; @@ -312,9 +334,7 @@ static inline void EmitETWMarker(const mozilla::ProfilerString8View& aName, staticData; // Allocate the exact amount of descriptors required by this event. - std::array<EVENT_DATA_DESCRIPTOR, - 2 + std::size(MarkerType::PayloadFields) + - std::size(BaseMarkerDescription::PayloadFields)> + std::array<EVENT_DATA_DESCRIPTOR, GetETWDescriptorCount<MarkerType>()> descriptors = {}; // Memory allocated on the stack for storing intermediate values. @@ -324,23 +344,33 @@ static inline void EmitETWMarker(const mozilla::ProfilerString8View& aName, StoreBaseEventDataDesc(dataStorage, descriptors.data(), aCategory, aOptions); - if constexpr (MarkerHasTranslator<MarkerType>::value) { - // When this function is implemented the arguments are passed back to the - // MarkerType object which is expected to call OutputMarkerSchema with - // the correct argument format. - buffer.mDescriptors = descriptors.data() + 2 + - std::size(BaseMarkerDescription::PayloadFields); - MarkerType::TranslateMarkerInputToSchema(&buffer, aPayloadArguments...); - } else { - const size_t argCount = sizeof...(PayloadArguments); - static_assert( - argCount == std::size(MarkerType::PayloadFields), - "Number and type of fields must be equal to number and type of " - "payload arguments. If this is not the case a " - "TranslateMarkerInputToSchema function must be defined."); - size_t i = 2 + std::size(BaseMarkerDescription::PayloadFields); - (CreateDataDescForPayload(buffer, descriptors[i++], aPayloadArguments), - ...); + if constexpr (MarkerType::StoreName) { + EventDataDescCreate(&descriptors[7], aName.StringView().data(), + aName.StringView().size() + 1); + } + + if constexpr (MarkerHasPayload<MarkerType>::value) { + if constexpr (MarkerHasTranslator<MarkerType>::value) { + // When this function is implemented the arguments are passed back to + // the MarkerType object which is expected to call OutputMarkerSchema + // with the correct argument format. + buffer.mDescriptors = descriptors.data() + 2 + + std::size(BaseMarkerDescription::PayloadFields) + + (MarkerType::StoreName ? 1 : 0); + + MarkerType::TranslateMarkerInputToSchema(&buffer, aPayloadArguments...); + } else { + const size_t argCount = sizeof...(PayloadArguments); + static_assert( + argCount == std::size(MarkerType::PayloadFields), + "Number and type of fields must be equal to number and type of " + "payload arguments. If this is not the case a " + "TranslateMarkerInputToSchema function must be defined."); + size_t i = 2 + std::size(BaseMarkerDescription::PayloadFields) + + (MarkerType::StoreName ? 1 : 0); + (CreateDataDescForPayload(buffer, descriptors[i++], aPayloadArguments), + ...); + } } _tlgWriteTransfer(kFirefoxTraceLoggingProvider, @@ -372,9 +402,6 @@ void OutputMarkerSchema(void* aContext, MarkerType aMarkerType, namespace ETW { static inline void Init() {} static inline void Shutdown() {} -static inline void EmitETWMarker(const mozilla::ProfilerString8View& aName, - const mozilla::MarkerCategory& aCategory, - const mozilla::MarkerOptions& aOptions = {}) {} template <typename MarkerType, typename... PayloadArguments> static inline void EmitETWMarker(const mozilla::ProfilerString8View& aName, const mozilla::MarkerCategory& aCategory, diff --git a/tools/profiler/public/GeckoProfiler.h b/tools/profiler/public/GeckoProfiler.h index f7c045297e..6b819addd8 100644 --- a/tools/profiler/public/GeckoProfiler.h +++ b/tools/profiler/public/GeckoProfiler.h @@ -269,7 +269,8 @@ class ProfilerStackCollector { virtual void CollectJitReturnAddr(void* aAddr) = 0; - virtual void CollectWasmFrame(const char* aLabel) = 0; + virtual void CollectWasmFrame(JS::ProfilingCategoryPair aCategory, + const char* aLabel) = 0; virtual void CollectProfilingStackFrame( const js::ProfilingStackFrame& aFrame) = 0; diff --git a/tools/profiler/public/GeckoTraceEvent.h b/tools/profiler/public/GeckoTraceEvent.h index 75affaf9c8..0887f74ac5 100644 --- a/tools/profiler/public/GeckoTraceEvent.h +++ b/tools/profiler/public/GeckoTraceEvent.h @@ -627,7 +627,18 @@ # else # define MOZ_INTERNAL_UPROFILER_SIMPLE_EVENT(phase, category_enabled, name, \ id, num_args, arg_names, \ - arg_types, arg_values, flags) + arg_types, arg_values, flags) \ + do { \ + (void)phase; \ + (void)category_enabled; \ + (void)name; \ + (void)id; \ + (void)num_args; \ + (void)arg_names; \ + (void)arg_types; \ + (void)arg_values; \ + (void)flags; \ + } while (0); # endif // Notes regarding the following definitions: diff --git a/tools/profiler/public/ProfilerMarkers.h b/tools/profiler/public/ProfilerMarkers.h index b1ba8c762f..cddb0fc307 100644 --- a/tools/profiler/public/ProfilerMarkers.h +++ b/tools/profiler/public/ProfilerMarkers.h @@ -389,34 +389,10 @@ extern template mozilla::ProfileBufferBlockIndex profiler_add_marker_impl( #endif // MOZ_GECKO_PROFILER namespace mozilla { - namespace detail { -// GCC doesn't allow this to live inside the class. -template <typename PayloadType> -static void StreamPayload(baseprofiler::SpliceableJSONWriter& aWriter, - const Span<const char> aKey, - const PayloadType& aPayload) { - aWriter.StringProperty(aKey, aPayload); -} - -template <typename PayloadType> -inline void StreamPayload(baseprofiler::SpliceableJSONWriter& aWriter, - const Span<const char> aKey, - const Maybe<PayloadType>& aPayload) { - if (aPayload.isSome()) { - StreamPayload(aWriter, aKey, *aPayload); - } else { - aWriter.NullProperty(aKey); - } -} - -template <> -inline void StreamPayload<bool>(baseprofiler::SpliceableJSONWriter& aWriter, - const Span<const char> aKey, - const bool& aPayload) { - aWriter.BoolProperty(aKey, aPayload); -} +// Implement this here to prevent BaseProfilerMarkersPrerequisites from pulling +// in nsString.h template <> inline void StreamPayload<ProfilerString16View>( baseprofiler::SpliceableJSONWriter& aWriter, const Span<const char> aKey, @@ -424,86 +400,6 @@ inline void StreamPayload<ProfilerString16View>( aWriter.StringProperty(aKey, NS_ConvertUTF16toUTF8(aPayload)); } -template <> -inline void StreamPayload<ProfilerString8View>( - baseprofiler::SpliceableJSONWriter& aWriter, const Span<const char> aKey, - const ProfilerString8View& aPayload) { - aWriter.StringProperty(aKey, aPayload); -} } // namespace detail - -// This helper class is used by MarkerTypes that want to support the general -// MarkerType object schema. When using this the markers will also transmit -// their payload to the ETW tracer as well as requiring less inline code. -// This is a curiously recurring template, the template argument is the child -// class itself. -template <typename T> -struct BaseMarkerType { - static constexpr const char* AllLabels = nullptr; - static constexpr const char* ChartLabel = nullptr; - static constexpr const char* TableLabel = nullptr; - static constexpr const char* TooltipLabel = nullptr; - - static constexpr MarkerSchema::ETWMarkerGroup Group = - MarkerSchema::ETWMarkerGroup::Generic; - - static MarkerSchema MarkerTypeDisplay() { - using MS = MarkerSchema; - MS schema{T::Locations, std::size(T::Locations)}; - if (T::AllLabels) { - schema.SetAllLabels(T::AllLabels); - } - if (T::ChartLabel) { - schema.SetChartLabel(T::ChartLabel); - } - if (T::TableLabel) { - schema.SetTableLabel(T::TableLabel); - } - if (T::TooltipLabel) { - schema.SetTooltipLabel(T::TooltipLabel); - } - for (const MS::PayloadField field : T::PayloadFields) { - if (field.Label) { - if (uint32_t(field.Flags) & uint32_t(MS::PayloadFlags::Searchable)) { - schema.AddKeyLabelFormatSearchable(field.Key, field.Label, field.Fmt, - MS::Searchable::Searchable); - } else { - schema.AddKeyLabelFormat(field.Key, field.Label, field.Fmt); - } - } else { - if (uint32_t(field.Flags) & uint32_t(MS::PayloadFlags::Searchable)) { - schema.AddKeyFormatSearchable(field.Key, field.Fmt, - MS::Searchable::Searchable); - } else { - schema.AddKeyFormat(field.Key, field.Fmt); - } - } - } - if (T::Description) { - schema.AddStaticLabelValue("Description", T::Description); - } - return schema; - } - - static constexpr Span<const char> MarkerTypeName() { - return MakeStringSpan(T::Name); - } - - // This is called by the child class since the child class version of this - // function is used to infer the argument types by the profile buffer and - // allows the child to do any special data conversion it needs to do. - // Optionally the child can opt not to use this at all and write the data - // out itself. - template <typename... PayloadArguments> - static void StreamJSONMarkerDataImpl( - baseprofiler::SpliceableJSONWriter& aWriter, - const PayloadArguments&... aPayloadArguments) { - size_t i = 0; - (detail::StreamPayload(aWriter, MakeStringSpan(T::PayloadFields[i++].Key), - aPayloadArguments), - ...); - } -}; - } // namespace mozilla #endif // ProfilerMarkers_h diff --git a/tools/profiler/public/ProfilerThreadRegistrationInfo.h b/tools/profiler/public/ProfilerThreadRegistrationInfo.h index e116c3059e..18a1c8fbaf 100644 --- a/tools/profiler/public/ProfilerThreadRegistrationInfo.h +++ b/tools/profiler/public/ProfilerThreadRegistrationInfo.h @@ -46,7 +46,10 @@ class ThreadRegistrationInfo { private: static TimeStamp ExistingRegisterTimeOrNow() { - TimeStamp registerTime = baseprofiler::detail::GetThreadRegistrationTime(); + TimeStamp registerTime; +#ifdef MOZ_GECKO_PROFILER + registerTime = baseprofiler::detail::GetThreadRegistrationTime(); +#endif if (!registerTime) { registerTime = TimeStamp::Now(); } diff --git a/tools/profiler/tests/browser/browser.toml b/tools/profiler/tests/browser/browser.toml index 57d8ad0875..fdbdd7c7ce 100644 --- a/tools/profiler/tests/browser/browser.toml +++ b/tools/profiler/tests/browser/browser.toml @@ -15,14 +15,12 @@ support-files = ["do_work_500ms.html"] support-files = ["do_work_500ms.html"] ["browser_test_marker_network_cancel.js"] -https_first_disabled = true support-files = ["simple.html"] ["browser_test_marker_network_private_browsing.js"] support-files = ["simple.html"] ["browser_test_marker_network_redirect.js"] -https_first_disabled = true support-files = [ "redirect.sjs", "simple.html", @@ -67,7 +65,6 @@ support-files = [ ] ["browser_test_marker_network_simple.js"] -https_first_disabled = true support-files = ["simple.html"] ["browser_test_marker_network_sts.js"] @@ -81,24 +78,20 @@ support-files = ["simple.html"] support-files = ["single_frame.html"] ["browser_test_profile_capture_by_pid.js"] -https_first_disabled = true support-files = ["single_frame.html"] ["browser_test_profile_fission.js"] support-files = ["single_frame.html"] ["browser_test_profile_multi_frame_page_info.js"] -https_first_disabled = true support-files = [ "multi_frame.html", "single_frame.html", ] ["browser_test_profile_single_frame_page_info.js"] -https_first_disabled = true support-files = ["single_frame.html"] ["browser_test_profile_slow_capture.js"] -https_first_disabled = true support-files = ["single_frame.html"] skip-if = ["!debug"] diff --git a/tools/profiler/tests/browser/browser_test_marker_network_cancel.js b/tools/profiler/tests/browser/browser_test_marker_network_cancel.js index df3de2b99a..4e144ba700 100644 --- a/tools/profiler/tests/browser/browser_test_marker_network_cancel.js +++ b/tools/profiler/tests/browser/browser_test_marker_network_cancel.js @@ -13,7 +13,7 @@ add_task(async function test_network_markers_early_cancel() { startProfilerForMarkerTests(); - const url = BASE_URL + "simple.html?cacheBust=" + Math.random(); + const url = BASE_URL_HTTPS + "simple.html?cacheBust=" + Math.random(); const options = { gBrowser, url: "about:blank", diff --git a/tools/profiler/tests/browser/browser_test_marker_network_redirect.js b/tools/profiler/tests/browser/browser_test_marker_network_redirect.js index 28478c2b3b..f5597e97e7 100644 --- a/tools/profiler/tests/browser/browser_test_marker_network_redirect.js +++ b/tools/profiler/tests/browser/browser_test_marker_network_redirect.js @@ -28,10 +28,10 @@ add_task(async function test_network_markers_redirect_simple() { const targetFileNameWithCacheBust = "simple.html"; const url = - BASE_URL + + BASE_URL_HTTPS + "redirect.sjs?" + encodeURIComponent(targetFileNameWithCacheBust); - const targetUrl = BASE_URL + targetFileNameWithCacheBust; + const targetUrl = BASE_URL_HTTPS + targetFileNameWithCacheBust; await BrowserTestUtils.withNewTab(url, async contentBrowser => { const contentPid = await SpecialPowers.spawn( @@ -149,7 +149,8 @@ add_task(async function test_network_markers_redirect_resources() { startProfilerForMarkerTests(); - const url = BASE_URL + "page_with_resources.html?cacheBust=" + Math.random(); + const url = + BASE_URL_HTTPS + "page_with_resources.html?cacheBust=" + Math.random(); await BrowserTestUtils.withNewTab(url, async contentBrowser => { const contentPid = await SpecialPowers.spawn( contentBrowser, @@ -225,6 +226,9 @@ add_task(async function test_network_markers_redirect_resources() { id: Expect.number(), pri: Expect.number(), innerWindowID: Expect.number(), + requestStart: Expect.number(), + responseStart: Expect.number(), + responseEnd: Expect.number(), }; // These properties are present when a connection is fully opened. This is @@ -239,9 +243,6 @@ add_task(async function test_network_markers_redirect_resources() { connectStart: Expect.number(), tcpConnectEnd: Expect.number(), connectEnd: Expect.number(), - requestStart: Expect.number(), - responseStart: Expect.number(), - responseEnd: Expect.number(), }; const expectedPropertiesForStopMarker = { @@ -250,7 +251,6 @@ add_task(async function test_network_markers_redirect_resources() { const expectedDataPropertiesForStopMarker = { ...expectedCommonDataProperties, - ...expectedConnectionProperties, status: "STATUS_STOP", URI: Expect.stringContains("/firefox-logo-nightly.svg"), contentType: "image/svg+xml", @@ -280,6 +280,7 @@ add_task(async function test_network_markers_redirect_resources() { ); Assert.objectContainsOnly(parentFirstStopMarker.data, { ...expectedDataPropertiesForStopMarker, + ...expectedConnectionProperties, // The cache information is missing from the content marker, it's only part // of the parent marker. See Bug 1544821. // Also, because the request races with the cache, these 2 values are valid: @@ -292,10 +293,10 @@ add_task(async function test_network_markers_redirect_resources() { contentFirstStopMarker, expectedPropertiesForStopMarker ); - Assert.objectContainsOnly( - contentFirstStopMarker.data, - expectedDataPropertiesForStopMarker - ); + Assert.objectContainsOnly(contentFirstStopMarker.data, { + ...expectedDataPropertiesForStopMarker, + ...expectedConnectionProperties, + }); Assert.objectContains( parentRedirectMarker, @@ -321,7 +322,11 @@ add_task(async function test_network_markers_redirect_resources() { parentSecondStopMarker, expectedPropertiesForStopMarker ); - Assert.objectContainsOnly(parentSecondStopMarker.data, { + // In Test-Verify mode, sometimes the properties from + // `expectedConnectionProperties` are missing. That's why they're not + // included here, and objectContains is used instead of objectContainsOnly + // like above. + Assert.objectContains(parentSecondStopMarker.data, { ...expectedDataPropertiesForStopMarker, // The "count" property is absent from the content marker. count: Expect.number(), @@ -333,7 +338,7 @@ add_task(async function test_network_markers_redirect_resources() { contentSecondStopMarker, expectedPropertiesForStopMarker ); - Assert.objectContainsOnly( + Assert.objectContains( contentSecondStopMarker.data, expectedDataPropertiesForStopMarker ); diff --git a/tools/profiler/tests/browser/browser_test_marker_network_simple.js b/tools/profiler/tests/browser/browser_test_marker_network_simple.js index 15894305a7..01f68216ee 100644 --- a/tools/profiler/tests/browser/browser_test_marker_network_simple.js +++ b/tools/profiler/tests/browser/browser_test_marker_network_simple.js @@ -13,7 +13,7 @@ add_task(async function test_network_markers() { startProfilerForMarkerTests(); - const url = BASE_URL + "simple.html?cacheBust=" + Math.random(); + const url = BASE_URL_HTTPS + "simple.html?cacheBust=" + Math.random(); await BrowserTestUtils.withNewTab(url, async contentBrowser => { const contentPid = await SpecialPowers.spawn( contentBrowser, diff --git a/tools/profiler/tests/browser/browser_test_markers_parent_process.js b/tools/profiler/tests/browser/browser_test_markers_parent_process.js index 28b82f8054..939271ee66 100644 --- a/tools/profiler/tests/browser/browser_test_markers_parent_process.js +++ b/tools/profiler/tests/browser/browser_test_markers_parent_process.js @@ -26,12 +26,13 @@ add_task(async function test_markers_parent_process() { ); ok(domEventStart, "A start DOMEvent was generated"); ok(domEventEnd, "An end DOMEvent was generated"); - ok( - domEventEnd.data.latency > 0, + Assert.greater( + domEventEnd.data.latency, + 0, "DOMEvent had a a latency value generated." ); - ok(domEventEnd.data.type === "DOMEvent"); - ok(domEventEnd.name === "DOMEvent"); + Assert.strictEqual(domEventEnd.data.type, "DOMEvent"); + Assert.strictEqual(domEventEnd.name, "DOMEvent"); } // Add more marker tests. }); diff --git a/tools/profiler/tests/browser/browser_test_profile_capture_by_pid.js b/tools/profiler/tests/browser/browser_test_profile_capture_by_pid.js index 14d76dbcaf..0d206a7148 100644 --- a/tools/profiler/tests/browser/browser_test_profile_capture_by_pid.js +++ b/tools/profiler/tests/browser/browser_test_profile_capture_by_pid.js @@ -26,7 +26,7 @@ async function test_with_filter(fnFilterWithContentId) { await Services.profiler.ClearAllPages(); info("Open a tab with single_frame.html in it."); - const url = BASE_URL + "single_frame.html"; + const url = BASE_URL_HTTPS + "single_frame.html"; return BrowserTestUtils.withNewTab(url, async function (contentBrowser) { const contentPid = await SpecialPowers.spawn(contentBrowser, [], () => { return Services.appinfo.processID; @@ -107,7 +107,7 @@ add_task(async function browser_test_profile_capture_along_with_content_pid() { add_task(async function browser_test_profile_capture_along_with_other_pid() { const parentPid = Services.appinfo.processID; const { contentPid, pidsWithSamplerThread, profile } = await test_with_filter( - contentPid => ["GeckoMain", "pid:" + parentPid] + () => ["GeckoMain", "pid:" + parentPid] ); Assert.greater( @@ -174,9 +174,9 @@ add_task(async function browser_test_profile_capture_by_only_content_pid() { add_task(async function browser_test_profile_capture_by_only_parent_pid() { const parentPid = Services.appinfo.processID; - const { pidsWithSamplerThread, profile } = await test_with_filter( - contentPid => ["pid:" + parentPid] - ); + const { pidsWithSamplerThread, profile } = await test_with_filter(() => [ + "pid:" + parentPid, + ]); Assert.deepEqual( pidsWithSamplerThread, diff --git a/tools/profiler/tests/browser/browser_test_profile_multi_frame_page_info.js b/tools/profiler/tests/browser/browser_test_profile_multi_frame_page_info.js index 854587678d..b1dfbb60c3 100644 --- a/tools/profiler/tests/browser/browser_test_profile_multi_frame_page_info.js +++ b/tools/profiler/tests/browser/browser_test_profile_multi_frame_page_info.js @@ -23,7 +23,7 @@ add_task(async function test_profile_multi_frame_page_info() { info("Open a tab with multi_frame.html in it."); // multi_frame.html embeds single_frame.html inside an iframe. - const url = BASE_URL + "multi_frame.html"; + const url = BASE_URL_HTTPS + "multi_frame.html"; await BrowserTestUtils.withNewTab(url, async function (contentBrowser) { const contentPid = await SpecialPowers.spawn(contentBrowser, [], () => { return Services.appinfo.processID; @@ -63,8 +63,8 @@ add_task(async function test_profile_multi_frame_page_info() { for (const page of contentProcess.pages) { // Child page (iframe) - if (page.url == BASE_URL + "single_frame.html") { - Assert.equal(page.url, BASE_URL + "single_frame.html"); + if (page.url == BASE_URL_HTTPS + "single_frame.html") { + Assert.equal(page.url, BASE_URL_HTTPS + "single_frame.html"); Assert.equal(typeof page.tabID, "number"); Assert.equal(page.tabID, activeTabID); Assert.equal(typeof page.innerWindowID, "number"); diff --git a/tools/profiler/tests/browser/browser_test_profile_single_frame_page_info.js b/tools/profiler/tests/browser/browser_test_profile_single_frame_page_info.js index 0385413c16..3249e728b7 100644 --- a/tools/profiler/tests/browser/browser_test_profile_single_frame_page_info.js +++ b/tools/profiler/tests/browser/browser_test_profile_single_frame_page_info.js @@ -22,7 +22,7 @@ add_task(async function test_profile_single_frame_page_info() { await startProfiler(); info("Open a tab with single_frame.html in it."); - const url = BASE_URL + "single_frame.html"; + const url = BASE_URL_HTTPS + "single_frame.html"; await BrowserTestUtils.withNewTab(url, async function (contentBrowser) { const contentPid = await SpecialPowers.spawn(contentBrowser, [], () => { return Services.appinfo.processID; diff --git a/tools/profiler/tests/browser/browser_test_profile_slow_capture.js b/tools/profiler/tests/browser/browser_test_profile_slow_capture.js index 4a675b84d1..16684a35dd 100644 --- a/tools/profiler/tests/browser/browser_test_profile_slow_capture.js +++ b/tools/profiler/tests/browser/browser_test_profile_slow_capture.js @@ -13,7 +13,7 @@ add_task(async function browser_test_profile_slow_capture() { await startProfiler({ threads: ["GeckoMain", "test-debug-child-slow-json"] }); info("Open a tab with single_frame.html in it."); - const url = BASE_URL + "single_frame.html"; + const url = BASE_URL_HTTPS + "single_frame.html"; await BrowserTestUtils.withNewTab(url, async function (contentBrowser) { const contentPid = await SpecialPowers.spawn(contentBrowser, [], () => { return Services.appinfo.processID; @@ -78,7 +78,7 @@ add_task(async function browser_test_profile_very_slow_capture() { }); info("Open a tab with single_frame.html in it."); - const url = BASE_URL + "single_frame.html"; + const url = BASE_URL_HTTPS + "single_frame.html"; await BrowserTestUtils.withNewTab(url, async function (contentBrowser) { const contentPid = await SpecialPowers.spawn(contentBrowser, [], () => { return Services.appinfo.processID; diff --git a/tools/profiler/tests/browser/serviceworkers/serviceworker_no_fetch_handler.js b/tools/profiler/tests/browser/serviceworkers/serviceworker_no_fetch_handler.js index f656665ca0..7a8ed91d28 100644 --- a/tools/profiler/tests/browser/serviceworkers/serviceworker_no_fetch_handler.js +++ b/tools/profiler/tests/browser/serviceworkers/serviceworker_no_fetch_handler.js @@ -1,4 +1,4 @@ -self.addEventListener("install", event => { +self.addEventListener("install", () => { performance.mark("__serviceworker_event"); console.log("[SW]:", "Install event"); }); diff --git a/tools/profiler/tests/browser/serviceworkers/serviceworker_no_respondWith_in_fetch_handler.js b/tools/profiler/tests/browser/serviceworkers/serviceworker_no_respondWith_in_fetch_handler.js index 255c8269a1..ba0610665b 100644 --- a/tools/profiler/tests/browser/serviceworkers/serviceworker_no_respondWith_in_fetch_handler.js +++ b/tools/profiler/tests/browser/serviceworkers/serviceworker_no_respondWith_in_fetch_handler.js @@ -1,4 +1,4 @@ -self.addEventListener("install", event => { +self.addEventListener("install", () => { performance.mark("__serviceworker_event"); console.log("[SW]:", "Install event"); }); diff --git a/tools/profiler/tests/browser/serviceworkers/serviceworker_synthetized_response.js b/tools/profiler/tests/browser/serviceworkers/serviceworker_synthetized_response.js index 891b679a5f..13c529d0d3 100644 --- a/tools/profiler/tests/browser/serviceworkers/serviceworker_synthetized_response.js +++ b/tools/profiler/tests/browser/serviceworkers/serviceworker_synthetized_response.js @@ -1,4 +1,4 @@ -self.addEventListener("install", event => { +self.addEventListener("install", () => { performance.mark("__serviceworker_event"); dump("[SW]:", "Install event\n"); }); diff --git a/tools/profiler/tests/gtest/GeckoProfiler.cpp b/tools/profiler/tests/gtest/GeckoProfiler.cpp index 79ed7cb52a..c9a26250db 100644 --- a/tools/profiler/tests/gtest/GeckoProfiler.cpp +++ b/tools/profiler/tests/gtest/GeckoProfiler.cpp @@ -140,8 +140,10 @@ TEST(GeckoProfiler, ThreadRegistrationInfo) EXPECT_STREQ(trInfoHere.Name(), "Here"); EXPECT_NE(trInfoHere.Name(), "Here") << "ThreadRegistrationInfo should keep its own copy of the name"; - TimeStamp baseRegistrationTime = - baseprofiler::detail::GetThreadRegistrationTime(); + TimeStamp baseRegistrationTime; +#ifdef MOZ_GECKO_PROFILER + baseRegistrationTime = baseprofiler::detail::GetThreadRegistrationTime(); +#endif if (baseRegistrationTime) { EXPECT_EQ(trInfoHere.RegisterTime(), baseRegistrationTime); } else { @@ -3228,12 +3230,14 @@ TEST(GeckoProfiler, Markers) EXPECT_EQ(display[0u].asString(), "marker-chart"); EXPECT_EQ(display[1u].asString(), "marker-table"); - ASSERT_EQ(data.size(), 1u); + ASSERT_EQ(data.size(), 2u); ASSERT_TRUE(data[0u].isObject()); EXPECT_EQ_JSON(data[0u]["key"], String, "name"); EXPECT_EQ_JSON(data[0u]["label"], String, "Details"); EXPECT_EQ_JSON(data[0u]["format"], String, "string"); + EXPECT_EQ_JSON(data[1u]["label"], String, "Description"); + EXPECT_EQ_JSON(data[1u]["value"], String, "Generic text marker"); } else if (nameString == "NoPayloadUserData") { // TODO: Remove this when bug 1646714 lands. @@ -3252,12 +3256,14 @@ TEST(GeckoProfiler, Markers) EXPECT_EQ(display[1u].asString(), "marker-table"); EXPECT_EQ(display[2u].asString(), "timeline-overview"); - ASSERT_EQ(data.size(), 1u); + ASSERT_EQ(data.size(), 2u); ASSERT_TRUE(data[0u].isObject()); EXPECT_EQ_JSON(data[0u]["key"], String, "category"); EXPECT_EQ_JSON(data[0u]["label"], String, "Type"); EXPECT_EQ_JSON(data[0u]["format"], String, "string"); + EXPECT_EQ_JSON(data[1u]["label"], String, "Description"); + EXPECT_EQ_JSON(data[1u]["value"], String, "Generic tracing marker"); } else if (nameString == "BHR-detected hang") { EXPECT_EQ(display.size(), 2u); @@ -3913,7 +3919,10 @@ class GTestStackCollector final : public ProfilerStackCollector { virtual void CollectNativeLeafAddr(void* aAddr) { mFrames++; } virtual void CollectJitReturnAddr(void* aAddr) { mFrames++; } - virtual void CollectWasmFrame(const char* aLabel) { mFrames++; } + virtual void CollectWasmFrame(JS::ProfilingCategoryPair aCategory, + const char* aLabel) { + mFrames++; + } virtual void CollectProfilingStackFrame( const js::ProfilingStackFrame& aFrame) { mFrames++; diff --git a/tools/profiler/tests/shared-head.js b/tools/profiler/tests/shared-head.js index d1b2f6868a..b01ef6ed25 100644 --- a/tools/profiler/tests/shared-head.js +++ b/tools/profiler/tests/shared-head.js @@ -547,7 +547,7 @@ Object.assign(Assert, { const Expect = { any: () => - actual => {} /* We don't check anything more than the presence of this property. */, + () => {} /* We don't check anything more than the presence of this property. */, }; /* These functions are part of the Assert object, and we want to reuse them. */ diff --git a/tools/profiler/tests/xpcshell/test_feature_cpufreq.js b/tools/profiler/tests/xpcshell/test_feature_cpufreq.js index 1d8e0d9a36..4bab2d1019 100644 --- a/tools/profiler/tests/xpcshell/test_feature_cpufreq.js +++ b/tools/profiler/tests/xpcshell/test_feature_cpufreq.js @@ -87,7 +87,7 @@ function getInflatedCPUFreqMarkers(thread) { * schema: MarkerSchema; * }} */ -async function runProfilerWithCPUSpeed(features, filename) { +async function runProfilerWithCPUSpeed(features) { const entries = 10000; const interval = 10; const threads = []; diff --git a/tools/profiler/tests/xpcshell/xpcshell.toml b/tools/profiler/tests/xpcshell/xpcshell.toml index a04dcd6789..5c094899a4 100644 --- a/tools/profiler/tests/xpcshell/xpcshell.toml +++ b/tools/profiler/tests/xpcshell/xpcshell.toml @@ -39,6 +39,7 @@ skip-if = ["tsan"] # Times out on TSan, bug 1612707 skip-if = [ "release_or_beta", "os == 'win' && socketprocess_networking", + "tsan", # bug 1885381 ] ["test_feature_nativeallocations.js"] |