diff --git a/change/react-native-windows-2019-12-09-21-30-05-TRACING_CURRENT.json b/change/react-native-windows-2019-12-09-21-30-05-TRACING_CURRENT.json new file mode 100644 index 00000000000..be4db4e072a --- /dev/null +++ b/change/react-native-windows-2019-12-09-21-30-05-TRACING_CURRENT.json @@ -0,0 +1,8 @@ +{ + "type": "prerelease", + "comment": "Submitting the ETW schema resouce dll and the register script", + "packageName": "react-native-windows", + "email": "anandrag@microsoft.com", + "commit": "cc3682e642cb6ee446d6183dd60f126767d4e936", + "date": "2019-12-10T05:30:05.029Z" +} \ No newline at end of file diff --git a/vnext/Desktop/React.Windows.Desktop.vcxproj b/vnext/Desktop/React.Windows.Desktop.vcxproj index eee91750a38..d6d761f2934 100644 --- a/vnext/Desktop/React.Windows.Desktop.vcxproj +++ b/vnext/Desktop/React.Windows.Desktop.vcxproj @@ -56,10 +56,9 @@ BOOST_ASIO_HAS_IOCP - Force unique layout/size for boost::asio::basic_stream_socket<> subtypes. --> BOOST_ASIO_HAS_IOCP;_WINSOCK_DEPRECATED_NO_WARNINGS;_WIN32_WINNT=_WIN32_WINNT_WIN7;WIN32;_WINDOWS;REACTNATIVEWIN32_EXPORTS;FOLLY_NO_CONFIG;NOMINMAX;GLOG_NO_ABBREVIATED_SEVERITIES;_HAS_AUTO_PTR_ETC;CHAKRACORE;RN_PLATFORM=win32;RN_EXPORT=;JSI_EXPORT=;%(PreprocessorDefinitions) - ENABLE_TRACING;%(PreprocessorDefinitions) - ENABLE_NATIVE_SYSTRACE;WITH_FBSYSTRACE;%(PreprocessorDefinitions) - ENABLE_JS_SYSTRACE;WITH_FBSYSTRACE;%(PreprocessorDefinitions) - ENABLE_TRACE_POSTPROCESSING;%(PreprocessorDefinitions) + ENABLE_ETW_TRACING;%(PreprocessorDefinitions) + ENABLE_NATIVE_SYSTRACE_TO_ETW;WITH_FBSYSTRACE;%(PreprocessorDefinitions) + ENABLE_JS_SYSTRACE_TO_ETW;WITH_FBSYSTRACE;%(PreprocessorDefinitions) %(AdditionalOptions) /Zc:strictStrings /bigobj Use pch.h diff --git a/vnext/JSI.Desktop.UnitTests/JSI.Desktop.UnitTests.vcxproj b/vnext/JSI.Desktop.UnitTests/JSI.Desktop.UnitTests.vcxproj index a13b12a0645..781ae42b822 100644 --- a/vnext/JSI.Desktop.UnitTests/JSI.Desktop.UnitTests.vcxproj +++ b/vnext/JSI.Desktop.UnitTests/JSI.Desktop.UnitTests.vcxproj @@ -49,10 +49,9 @@ string literals. It prevents code like wchar_t* str = L"hello"; from compiling. --> - ENABLE_TRACING;%(PreprocessorDefinitions) - ENABLE_NATIVE_SYSTRACE;WITH_FBSYSTRACE;%(PreprocessorDefinitions) - ENABLE_JS_SYSTRACE;WITH_FBSYSTRACE;%(PreprocessorDefinitions) - ENABLE_TRACE_POSTPROCESSING;%(PreprocessorDefinitions) + ENABLE_ETW_TRACING;%(PreprocessorDefinitions) + ENABLE_NATIVE_SYSTRACE_TO_ETW;WITH_FBSYSTRACE;%(PreprocessorDefinitions) + ENABLE_JS_SYSTRACE_TO_ETW;WITH_FBSYSTRACE;%(PreprocessorDefinitions) %(AdditionalOptions) /Zc:strictStrings diff --git a/vnext/PropertySheets/React.Cpp.props b/vnext/PropertySheets/React.Cpp.props index 1bdbb1c6174..f514845af0c 100644 --- a/vnext/PropertySheets/React.Cpp.props +++ b/vnext/PropertySheets/React.Cpp.props @@ -25,10 +25,14 @@ 0.1.6 $(SolutionDir)packages\ReactNative.V8JSI.Windows.$(HERMES_Version) - true - true - true - false + + true + + + true + + + true diff --git a/vnext/ReactCommon/ReactCommon.vcxproj b/vnext/ReactCommon/ReactCommon.vcxproj index 760d3817f69..729361ef95d 100644 --- a/vnext/ReactCommon/ReactCommon.vcxproj +++ b/vnext/ReactCommon/ReactCommon.vcxproj @@ -66,9 +66,8 @@ false true $(ReactNativeDir)\ReactCommon;$(JSI_Source);$(ReactNativeDir)\ReactCommon\jscallinvoker;$(ReactNativeDir)\ReactCommon\jsiexecutor;$(FollyDir);$(ReactNativeWindowsDir)stubs;$(ReactNativeWindowsDir)\ReactWindowsCore\tracing;%(AdditionalIncludeDirectories) - ENABLE_NATIVE_SYSTRACE;WITH_FBSYSTRACE;%(PreprocessorDefinitions) - ENABLE_JS_SYSTRACE;WITH_FBSYSTRACE;%(PreprocessorDefinitions) - ENABLE_TRACE_POSTPROCESSING;%(PreprocessorDefinitions) + ENABLE_NATIVE_SYSTRACE_TO_ETW;WITH_FBSYSTRACE;%(PreprocessorDefinitions) + ENABLE_JS_SYSTRACE_TO_ETW;WITH_FBSYSTRACE;%(PreprocessorDefinitions) _WIN32;_CRT_SECURE_NO_WARNINGS;FOLLY_NO_CONFIG;NOMINMAX;RN_EXPORT=;JSI_EXPORT=;WIN32;_WINDLL;%(PreprocessorDefinitions) 4715;4146;4251;4800;4804;4305;4722;%(DisableSpecificWarnings) diff --git a/vnext/ReactUWP/ReactUWP.vcxproj b/vnext/ReactUWP/ReactUWP.vcxproj index c8c23995d8c..bb7291198f1 100644 --- a/vnext/ReactUWP/ReactUWP.vcxproj +++ b/vnext/ReactUWP/ReactUWP.vcxproj @@ -76,10 +76,9 @@ USE_EDGEMODE_JSRT;%(PreprocessorDefinitions) USE_HERMES;%(PreprocessorDefinitions) USE_V8;%(PreprocessorDefinitions) - ENABLE_TRACING;%(PreprocessorDefinitions) - ENABLE_NATIVE_SYSTRACE;WITH_FBSYSTRACE;%(PreprocessorDefinitions) - ENABLE_JS_SYSTRACE;WITH_FBSYSTRACE;%(PreprocessorDefinitions) - ENABLE_TRACE_POSTPROCESSING;%(PreprocessorDefinitions) + ENABLE_ETW_TRACING;%(PreprocessorDefinitions) + ENABLE_NATIVE_SYSTRACE_TO_ETW;WITH_FBSYSTRACE;%(PreprocessorDefinitions) + ENABLE_JS_SYSTRACE_TO_ETW;WITH_FBSYSTRACE;%(PreprocessorDefinitions) REACTWINDOWS_BUILD; RN_PLATFORM=windows; diff --git a/vnext/ReactWindowsCore/ReactWindowsCore.vcxproj b/vnext/ReactWindowsCore/ReactWindowsCore.vcxproj index ce508282b28..a6e822a71f9 100644 --- a/vnext/ReactWindowsCore/ReactWindowsCore.vcxproj +++ b/vnext/ReactWindowsCore/ReactWindowsCore.vcxproj @@ -70,10 +70,9 @@ REACTWINDOWS_BUILD;NOMINMAX;FOLLY_NO_CONFIG;WIN32=0;RN_EXPORT=;CHAKRACORE;%(PreprocessorDefinitions) USE_HERMES;%(PreprocessorDefinitions) USE_V8;%(PreprocessorDefinitions) - ENABLE_TRACING;%(PreprocessorDefinitions) - ENABLE_NATIVE_SYSTRACE;WITH_FBSYSTRACE;%(PreprocessorDefinitions) - ENABLE_JS_SYSTRACE;WITH_FBSYSTRACE;%(PreprocessorDefinitions) - ENABLE_TRACE_POSTPROCESSING;%(PreprocessorDefinitions) + ENABLE_ETW_TRACING;%(PreprocessorDefinitions) + ENABLE_NATIVE_SYSTRACE_TO_ETW;WITH_FBSYSTRACE;%(PreprocessorDefinitions) + ENABLE_JS_SYSTRACE_TO_ETW;WITH_FBSYSTRACE;%(PreprocessorDefinitions) $(ReactNativeWindowsDir);$(ReactNativeWindowsDir)Common;$(ReactNativeWindowsDir)Shared;$(ReactNativeWindowsDir)include;$(ReactNativeWindowsDir)include\ReactWindowsCore;$(ReactNativeDir)\ReactCommon;$(JSI_Source);$(ReactNativeWindowsDir)stubs;$(FollyDir);$(ReactNativeWindowsDir)\ReactWindowsCore\tracing;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) $(HERMES_Package)\installed\$(VcpkgTriplet)\include\;%(AdditionalIncludeDirectories) $(V8_Package)\installed\$(VcpkgTriplet)\include\;%(AdditionalIncludeDirectories) diff --git a/vnext/ReactWindowsCore/etw/build.bat b/vnext/ReactWindowsCore/etw/build.bat new file mode 100644 index 00000000000..5c2c0ffb61e --- /dev/null +++ b/vnext/ReactWindowsCore/etw/build.bat @@ -0,0 +1,4 @@ +@echo off +mc -um react_native_windows.man +rc.exe react_native_windows.rc +link.exe /dll /noentry /machine:x64 react_native_windows.res /OUT:react_native_windows_etw_res.dll \ No newline at end of file diff --git a/vnext/ReactWindowsCore/etw/react_native_windows.h b/vnext/ReactWindowsCore/etw/react_native_windows.h index c017cf782d4..a7b8f8b6422 100644 --- a/vnext/ReactWindowsCore/etw/react_native_windows.h +++ b/vnext/ReactWindowsCore/etw/react_native_windows.h @@ -104,8 +104,7 @@ extern "C" { // or more provider in a manifest has provider traits. // #ifndef MCGEN_HAVE_EVENTSETINFORMATION -#ifdef MCGEN_EVENTSETINFORMATION // if MCGEN_EVENTSETINFORMATION has been - // customized, +#ifdef MCGEN_EVENTSETINFORMATION // if MCGEN_EVENTSETINFORMATION has been customized, #define MCGEN_HAVE_EVENTSETINFORMATION 1 // directly invoke MCGEN_EVENTSETINFORMATION(...). #elif MCGEN_USE_KERNEL_MODE_APIS // else if using kernel-mode APIs, #if NTDDI_VERSION >= 0x06040000 // if target OS is Windows 10 or later, @@ -330,8 +329,8 @@ Routine Description: FilterData - The provider-defined data. - CallbackContext - The context of the callback that is defined when the -provider called EtwRegister to register itself. + CallbackContext - The context of the callback that is defined when the provider + called EtwRegister to register itself. Remarks: @@ -670,35 +669,37 @@ EXTERN_C __declspec(selectany) MCGEN_TRACE_CONTEXT REACT_NATIVE_WINDOWS_Context // // Event write macros for JS_BEGIN_SECTION // -#define EventWriteJS_BEGIN_SECTION(tag, profileName, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \ - MCGEN_EVENT_ENABLED(JS_BEGIN_SECTION) \ - ? McTemplateU0xsssssssss( \ - &REACT_NATIVE_WINDOWS_Context, \ - &JS_BEGIN_SECTION, \ - tag, \ - profileName, \ - arg0, \ - arg1, \ - arg2, \ - arg3, \ - arg4, \ - arg5, \ - arg6, \ - arg7) \ +#define EventWriteJS_BEGIN_SECTION(id, tag, profileName, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \ + MCGEN_EVENT_ENABLED(JS_BEGIN_SECTION) \ + ? McTemplateU0xxsssssssss( \ + &REACT_NATIVE_WINDOWS_Context, \ + &JS_BEGIN_SECTION, \ + id, \ + tag, \ + profileName, \ + arg0, \ + arg1, \ + arg2, \ + arg3, \ + arg4, \ + arg5, \ + arg6, \ + arg7) \ : 0 -#define EventWriteJS_BEGIN_SECTION_AssumeEnabled(tag, profileName, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \ - McTemplateU0xsssssssss( \ - &REACT_NATIVE_WINDOWS_Context, \ - &JS_BEGIN_SECTION, \ - tag, \ - profileName, \ - arg0, \ - arg1, \ - arg2, \ - arg3, \ - arg4, \ - arg5, \ - arg6, \ +#define EventWriteJS_BEGIN_SECTION_AssumeEnabled(id, tag, profileName, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \ + McTemplateU0xxsssssssss( \ + &REACT_NATIVE_WINDOWS_Context, \ + &JS_BEGIN_SECTION, \ + id, \ + tag, \ + profileName, \ + arg0, \ + arg1, \ + arg2, \ + arg3, \ + arg4, \ + arg5, \ + arg6, \ arg7) // @@ -709,11 +710,11 @@ EXTERN_C __declspec(selectany) MCGEN_TRACE_CONTEXT REACT_NATIVE_WINDOWS_Context // // Event write macros for JS_END_SECTION // -#define EventWriteJS_END_SECTION(tag, profileName, duration) \ - MCGEN_EVENT_ENABLED(JS_END_SECTION) \ - ? McTemplateU0xsg(&REACT_NATIVE_WINDOWS_Context, &JS_END_SECTION, tag, profileName, duration) : 0 -#define EventWriteJS_END_SECTION_AssumeEnabled(tag, profileName, duration) \ - McTemplateU0xsg(&REACT_NATIVE_WINDOWS_Context, &JS_END_SECTION, tag, profileName, duration) +#define EventWriteJS_END_SECTION(id, tag, profileName, duration) \ + MCGEN_EVENT_ENABLED(JS_END_SECTION) \ + ? McTemplateU0xxsg(&REACT_NATIVE_WINDOWS_Context, &JS_END_SECTION, id, tag, profileName, duration) : 0 +#define EventWriteJS_END_SECTION_AssumeEnabled(id, tag, profileName, duration) \ + McTemplateU0xxsg(&REACT_NATIVE_WINDOWS_Context, &JS_END_SECTION, id, tag, profileName, duration) // // Enablement check macro for JS_ASYNC_BEGIN_SECTION @@ -793,36 +794,38 @@ EXTERN_C __declspec(selectany) MCGEN_TRACE_CONTEXT REACT_NATIVE_WINDOWS_Context // // Event write macros for EVALUATE_SCRIPT_BEGIN // -#define EventWriteEVALUATE_SCRIPT_BEGIN(tag, profileName, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \ - MCGEN_EVENT_ENABLED(EVALUATE_SCRIPT_BEGIN) \ - ? McTemplateU0xsssssssss( \ - &REACT_NATIVE_WINDOWS_Context, \ - &EVALUATE_SCRIPT_BEGIN, \ - tag, \ - profileName, \ - arg0, \ - arg1, \ - arg2, \ - arg3, \ - arg4, \ - arg5, \ - arg6, \ - arg7) \ +#define EventWriteEVALUATE_SCRIPT_BEGIN(id, tag, profileName, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \ + MCGEN_EVENT_ENABLED(EVALUATE_SCRIPT_BEGIN) \ + ? McTemplateU0xxsssssssss( \ + &REACT_NATIVE_WINDOWS_Context, \ + &EVALUATE_SCRIPT_BEGIN, \ + id, \ + tag, \ + profileName, \ + arg0, \ + arg1, \ + arg2, \ + arg3, \ + arg4, \ + arg5, \ + arg6, \ + arg7) \ : 0 -#define EventWriteEVALUATE_SCRIPT_BEGIN_AssumeEnabled( \ - tag, profileName, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \ - McTemplateU0xsssssssss( \ - &REACT_NATIVE_WINDOWS_Context, \ - &EVALUATE_SCRIPT_BEGIN, \ - tag, \ - profileName, \ - arg0, \ - arg1, \ - arg2, \ - arg3, \ - arg4, \ - arg5, \ - arg6, \ +#define EventWriteEVALUATE_SCRIPT_BEGIN_AssumeEnabled( \ + id, tag, profileName, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \ + McTemplateU0xxsssssssss( \ + &REACT_NATIVE_WINDOWS_Context, \ + &EVALUATE_SCRIPT_BEGIN, \ + id, \ + tag, \ + profileName, \ + arg0, \ + arg1, \ + arg2, \ + arg3, \ + arg4, \ + arg5, \ + arg6, \ arg7) // @@ -833,11 +836,11 @@ EXTERN_C __declspec(selectany) MCGEN_TRACE_CONTEXT REACT_NATIVE_WINDOWS_Context // // Event write macros for EVALUATE_SCRIPT_END // -#define EventWriteEVALUATE_SCRIPT_END(tag, profileName, duration) \ - MCGEN_EVENT_ENABLED(EVALUATE_SCRIPT_END) \ - ? McTemplateU0xsg(&REACT_NATIVE_WINDOWS_Context, &EVALUATE_SCRIPT_END, tag, profileName, duration) : 0 -#define EventWriteEVALUATE_SCRIPT_END_AssumeEnabled(tag, profileName, duration) \ - McTemplateU0xsg(&REACT_NATIVE_WINDOWS_Context, &EVALUATE_SCRIPT_END, tag, profileName, duration) +#define EventWriteEVALUATE_SCRIPT_END(id, tag, profileName, duration) \ + MCGEN_EVENT_ENABLED(EVALUATE_SCRIPT_END) \ + ? McTemplateU0xxsg(&REACT_NATIVE_WINDOWS_Context, &EVALUATE_SCRIPT_END, id, tag, profileName, duration) : 0 +#define EventWriteEVALUATE_SCRIPT_END_AssumeEnabled(id, tag, profileName, duration) \ + McTemplateU0xxsg(&REACT_NATIVE_WINDOWS_Context, &EVALUATE_SCRIPT_END, id, tag, profileName, duration) // // Enablement check macro for CALL_JSFUNCTION_BEGIN @@ -847,36 +850,38 @@ EXTERN_C __declspec(selectany) MCGEN_TRACE_CONTEXT REACT_NATIVE_WINDOWS_Context // // Event write macros for CALL_JSFUNCTION_BEGIN // -#define EventWriteCALL_JSFUNCTION_BEGIN(tag, profileName, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \ - MCGEN_EVENT_ENABLED(CALL_JSFUNCTION_BEGIN) \ - ? McTemplateU0xsssssssss( \ - &REACT_NATIVE_WINDOWS_Context, \ - &CALL_JSFUNCTION_BEGIN, \ - tag, \ - profileName, \ - arg0, \ - arg1, \ - arg2, \ - arg3, \ - arg4, \ - arg5, \ - arg6, \ - arg7) \ +#define EventWriteCALL_JSFUNCTION_BEGIN(id, tag, profileName, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \ + MCGEN_EVENT_ENABLED(CALL_JSFUNCTION_BEGIN) \ + ? McTemplateU0xxsssssssss( \ + &REACT_NATIVE_WINDOWS_Context, \ + &CALL_JSFUNCTION_BEGIN, \ + id, \ + tag, \ + profileName, \ + arg0, \ + arg1, \ + arg2, \ + arg3, \ + arg4, \ + arg5, \ + arg6, \ + arg7) \ : 0 -#define EventWriteCALL_JSFUNCTION_BEGIN_AssumeEnabled( \ - tag, profileName, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \ - McTemplateU0xsssssssss( \ - &REACT_NATIVE_WINDOWS_Context, \ - &CALL_JSFUNCTION_BEGIN, \ - tag, \ - profileName, \ - arg0, \ - arg1, \ - arg2, \ - arg3, \ - arg4, \ - arg5, \ - arg6, \ +#define EventWriteCALL_JSFUNCTION_BEGIN_AssumeEnabled( \ + id, tag, profileName, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \ + McTemplateU0xxsssssssss( \ + &REACT_NATIVE_WINDOWS_Context, \ + &CALL_JSFUNCTION_BEGIN, \ + id, \ + tag, \ + profileName, \ + arg0, \ + arg1, \ + arg2, \ + arg3, \ + arg4, \ + arg5, \ + arg6, \ arg7) // @@ -887,11 +892,11 @@ EXTERN_C __declspec(selectany) MCGEN_TRACE_CONTEXT REACT_NATIVE_WINDOWS_Context // // Event write macros for CALL_JSFUNCTION_END // -#define EventWriteCALL_JSFUNCTION_END(tag, profileName, duration) \ - MCGEN_EVENT_ENABLED(CALL_JSFUNCTION_END) \ - ? McTemplateU0xsg(&REACT_NATIVE_WINDOWS_Context, &CALL_JSFUNCTION_END, tag, profileName, duration) : 0 -#define EventWriteCALL_JSFUNCTION_END_AssumeEnabled(tag, profileName, duration) \ - McTemplateU0xsg(&REACT_NATIVE_WINDOWS_Context, &CALL_JSFUNCTION_END, tag, profileName, duration) +#define EventWriteCALL_JSFUNCTION_END(id, tag, profileName, duration) \ + MCGEN_EVENT_ENABLED(CALL_JSFUNCTION_END) \ + ? McTemplateU0xxsg(&REACT_NATIVE_WINDOWS_Context, &CALL_JSFUNCTION_END, id, tag, profileName, duration) : 0 +#define EventWriteCALL_JSFUNCTION_END_AssumeEnabled(id, tag, profileName, duration) \ + McTemplateU0xxsg(&REACT_NATIVE_WINDOWS_Context, &CALL_JSFUNCTION_END, id, tag, profileName, duration) // // Enablement check macro for CALL_NATIVEMODULES_BEGIN @@ -901,36 +906,38 @@ EXTERN_C __declspec(selectany) MCGEN_TRACE_CONTEXT REACT_NATIVE_WINDOWS_Context // // Event write macros for CALL_NATIVEMODULES_BEGIN // -#define EventWriteCALL_NATIVEMODULES_BEGIN(tag, profileName, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \ - MCGEN_EVENT_ENABLED(CALL_NATIVEMODULES_BEGIN) \ - ? McTemplateU0xsssssssss( \ - &REACT_NATIVE_WINDOWS_Context, \ - &CALL_NATIVEMODULES_BEGIN, \ - tag, \ - profileName, \ - arg0, \ - arg1, \ - arg2, \ - arg3, \ - arg4, \ - arg5, \ - arg6, \ - arg7) \ +#define EventWriteCALL_NATIVEMODULES_BEGIN(id, tag, profileName, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \ + MCGEN_EVENT_ENABLED(CALL_NATIVEMODULES_BEGIN) \ + ? McTemplateU0xxsssssssss( \ + &REACT_NATIVE_WINDOWS_Context, \ + &CALL_NATIVEMODULES_BEGIN, \ + id, \ + tag, \ + profileName, \ + arg0, \ + arg1, \ + arg2, \ + arg3, \ + arg4, \ + arg5, \ + arg6, \ + arg7) \ : 0 -#define EventWriteCALL_NATIVEMODULES_BEGIN_AssumeEnabled( \ - tag, profileName, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \ - McTemplateU0xsssssssss( \ - &REACT_NATIVE_WINDOWS_Context, \ - &CALL_NATIVEMODULES_BEGIN, \ - tag, \ - profileName, \ - arg0, \ - arg1, \ - arg2, \ - arg3, \ - arg4, \ - arg5, \ - arg6, \ +#define EventWriteCALL_NATIVEMODULES_BEGIN_AssumeEnabled( \ + id, tag, profileName, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \ + McTemplateU0xxsssssssss( \ + &REACT_NATIVE_WINDOWS_Context, \ + &CALL_NATIVEMODULES_BEGIN, \ + id, \ + tag, \ + profileName, \ + arg0, \ + arg1, \ + arg2, \ + arg3, \ + arg4, \ + arg5, \ + arg6, \ arg7) // @@ -941,11 +948,11 @@ EXTERN_C __declspec(selectany) MCGEN_TRACE_CONTEXT REACT_NATIVE_WINDOWS_Context // // Event write macros for CALL_NATIVEMODULES_END // -#define EventWriteCALL_NATIVEMODULES_END(tag, profileName, duration) \ - MCGEN_EVENT_ENABLED(CALL_NATIVEMODULES_END) \ - ? McTemplateU0xsg(&REACT_NATIVE_WINDOWS_Context, &CALL_NATIVEMODULES_END, tag, profileName, duration) : 0 -#define EventWriteCALL_NATIVEMODULES_END_AssumeEnabled(tag, profileName, duration) \ - McTemplateU0xsg(&REACT_NATIVE_WINDOWS_Context, &CALL_NATIVEMODULES_END, tag, profileName, duration) +#define EventWriteCALL_NATIVEMODULES_END(id, tag, profileName, duration) \ + MCGEN_EVENT_ENABLED(CALL_NATIVEMODULES_END) \ + ? McTemplateU0xxsg(&REACT_NATIVE_WINDOWS_Context, &CALL_NATIVEMODULES_END, id, tag, profileName, duration) : 0 +#define EventWriteCALL_NATIVEMODULES_END_AssumeEnabled(id, tag, profileName, duration) \ + McTemplateU0xxsg(&REACT_NATIVE_WINDOWS_Context, &CALL_NATIVEMODULES_END, id, tag, profileName, duration) // // Enablement check macro for NATIVE_BEGIN_SECTION @@ -955,35 +962,38 @@ EXTERN_C __declspec(selectany) MCGEN_TRACE_CONTEXT REACT_NATIVE_WINDOWS_Context // // Event write macros for NATIVE_BEGIN_SECTION // -#define EventWriteNATIVE_BEGIN_SECTION(tag, profileName, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \ - MCGEN_EVENT_ENABLED(NATIVE_BEGIN_SECTION) \ - ? McTemplateU0xsssssssss( \ - &REACT_NATIVE_WINDOWS_Context, \ - &NATIVE_BEGIN_SECTION, \ - tag, \ - profileName, \ - arg0, \ - arg1, \ - arg2, \ - arg3, \ - arg4, \ - arg5, \ - arg6, \ - arg7) \ +#define EventWriteNATIVE_BEGIN_SECTION(id, tag, profileName, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \ + MCGEN_EVENT_ENABLED(NATIVE_BEGIN_SECTION) \ + ? McTemplateU0xxsssssssss( \ + &REACT_NATIVE_WINDOWS_Context, \ + &NATIVE_BEGIN_SECTION, \ + id, \ + tag, \ + profileName, \ + arg0, \ + arg1, \ + arg2, \ + arg3, \ + arg4, \ + arg5, \ + arg6, \ + arg7) \ : 0 -#define EventWriteNATIVE_BEGIN_SECTION_AssumeEnabled(tag, profileName, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \ - McTemplateU0xsssssssss( \ - &REACT_NATIVE_WINDOWS_Context, \ - &NATIVE_BEGIN_SECTION, \ - tag, \ - profileName, \ - arg0, \ - arg1, \ - arg2, \ - arg3, \ - arg4, \ - arg5, \ - arg6, \ +#define EventWriteNATIVE_BEGIN_SECTION_AssumeEnabled( \ + id, tag, profileName, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \ + McTemplateU0xxsssssssss( \ + &REACT_NATIVE_WINDOWS_Context, \ + &NATIVE_BEGIN_SECTION, \ + id, \ + tag, \ + profileName, \ + arg0, \ + arg1, \ + arg2, \ + arg3, \ + arg4, \ + arg5, \ + arg6, \ arg7) // @@ -994,11 +1004,11 @@ EXTERN_C __declspec(selectany) MCGEN_TRACE_CONTEXT REACT_NATIVE_WINDOWS_Context // // Event write macros for NATIVE_END_SECTION // -#define EventWriteNATIVE_END_SECTION(tag, profileName, duration) \ - MCGEN_EVENT_ENABLED(NATIVE_END_SECTION) \ - ? McTemplateU0xsg(&REACT_NATIVE_WINDOWS_Context, &NATIVE_END_SECTION, tag, profileName, duration) : 0 -#define EventWriteNATIVE_END_SECTION_AssumeEnabled(tag, profileName, duration) \ - McTemplateU0xsg(&REACT_NATIVE_WINDOWS_Context, &NATIVE_END_SECTION, tag, profileName, duration) +#define EventWriteNATIVE_END_SECTION(id, tag, profileName, duration) \ + MCGEN_EVENT_ENABLED(NATIVE_END_SECTION) \ + ? McTemplateU0xxsg(&REACT_NATIVE_WINDOWS_Context, &NATIVE_END_SECTION, id, tag, profileName, duration) : 0 +#define EventWriteNATIVE_END_SECTION_AssumeEnabled(id, tag, profileName, duration) \ + McTemplateU0xxsg(&REACT_NATIVE_WINDOWS_Context, &NATIVE_END_SECTION, id, tag, profileName, duration) // // Enablement check macro for NATIVE_ASYNC_BEGIN_SECTION @@ -1148,45 +1158,48 @@ McTemplateU0xsdg( // // Template from manifest : tidEndSection // -#ifndef McTemplateU0xsg_def -#define McTemplateU0xsg_def +#ifndef McTemplateU0xxsg_def +#define McTemplateU0xxsg_def ETW_INLINE ULONG -McTemplateU0xsg( +McTemplateU0xxsg( _In_ PMCGEN_TRACE_CONTEXT Context, _In_ PCEVENT_DESCRIPTOR Descriptor, _In_ const unsigned __int64 _Arg0, - _In_opt_ PCSTR _Arg1, - _In_ const double _Arg2) { -#define McTemplateU0xsg_ARGCOUNT 3 + _In_ const unsigned __int64 _Arg1, + _In_opt_ PCSTR _Arg2, + _In_ const double _Arg3) { +#define McTemplateU0xxsg_ARGCOUNT 4 - EVENT_DATA_DESCRIPTOR EventData[McTemplateU0xsg_ARGCOUNT + 1]; + EVENT_DATA_DESCRIPTOR EventData[McTemplateU0xxsg_ARGCOUNT + 1]; EventDataDescCreate(&EventData[1], &_Arg0, sizeof(const unsigned __int64)); + EventDataDescCreate(&EventData[2], &_Arg1, sizeof(const unsigned __int64)); + EventDataDescCreate( - &EventData[2], - (_Arg1 != NULL) ? _Arg1 : "NULL", - (_Arg1 != NULL) ? (ULONG)((strlen(_Arg1) + 1) * sizeof(char)) : (ULONG)sizeof("NULL")); + &EventData[3], + (_Arg2 != NULL) ? _Arg2 : "NULL", + (_Arg2 != NULL) ? (ULONG)((strlen(_Arg2) + 1) * sizeof(char)) : (ULONG)sizeof("NULL")); - EventDataDescCreate(&EventData[3], &_Arg2, sizeof(const double)); + EventDataDescCreate(&EventData[4], &_Arg3, sizeof(const double)); - return McGenEventWrite(Context, Descriptor, NULL, McTemplateU0xsg_ARGCOUNT + 1, EventData); + return McGenEventWrite(Context, Descriptor, NULL, McTemplateU0xxsg_ARGCOUNT + 1, EventData); } -#endif // McTemplateU0xsg_def +#endif // McTemplateU0xxsg_def // // Template from manifest : tidBeginSection // -#ifndef McTemplateU0xsssssssss_def -#define McTemplateU0xsssssssss_def +#ifndef McTemplateU0xxsssssssss_def +#define McTemplateU0xxsssssssss_def ETW_INLINE ULONG -McTemplateU0xsssssssss( +McTemplateU0xxsssssssss( _In_ PMCGEN_TRACE_CONTEXT Context, _In_ PCEVENT_DESCRIPTOR Descriptor, _In_ const unsigned __int64 _Arg0, - _In_opt_ PCSTR _Arg1, + _In_ const unsigned __int64 _Arg1, _In_opt_ PCSTR _Arg2, _In_opt_ PCSTR _Arg3, _In_opt_ PCSTR _Arg4, @@ -1194,17 +1207,15 @@ McTemplateU0xsssssssss( _In_opt_ PCSTR _Arg6, _In_opt_ PCSTR _Arg7, _In_opt_ PCSTR _Arg8, - _In_opt_ PCSTR _Arg9) { -#define McTemplateU0xsssssssss_ARGCOUNT 10 + _In_opt_ PCSTR _Arg9, + _In_opt_ PCSTR _Arg10) { +#define McTemplateU0xxsssssssss_ARGCOUNT 11 - EVENT_DATA_DESCRIPTOR EventData[McTemplateU0xsssssssss_ARGCOUNT + 1]; + EVENT_DATA_DESCRIPTOR EventData[McTemplateU0xxsssssssss_ARGCOUNT + 1]; EventDataDescCreate(&EventData[1], &_Arg0, sizeof(const unsigned __int64)); - EventDataDescCreate( - &EventData[2], - (_Arg1 != NULL) ? _Arg1 : "NULL", - (_Arg1 != NULL) ? (ULONG)((strlen(_Arg1) + 1) * sizeof(char)) : (ULONG)sizeof("NULL")); + EventDataDescCreate(&EventData[2], &_Arg1, sizeof(const unsigned __int64)); EventDataDescCreate( &EventData[3], @@ -1246,9 +1257,14 @@ McTemplateU0xsssssssss( (_Arg9 != NULL) ? _Arg9 : "NULL", (_Arg9 != NULL) ? (ULONG)((strlen(_Arg9) + 1) * sizeof(char)) : (ULONG)sizeof("NULL")); - return McGenEventWrite(Context, Descriptor, NULL, McTemplateU0xsssssssss_ARGCOUNT + 1, EventData); + EventDataDescCreate( + &EventData[11], + (_Arg10 != NULL) ? _Arg10 : "NULL", + (_Arg10 != NULL) ? (ULONG)((strlen(_Arg10) + 1) * sizeof(char)) : (ULONG)sizeof("NULL")); + + return McGenEventWrite(Context, Descriptor, NULL, McTemplateU0xxsssssssss_ARGCOUNT + 1, EventData); } -#endif // McTemplateU0xsssssssss_def +#endif // McTemplateU0xxsssssssss_def #endif // MCGEN_DISABLE_PROVIDER_CODE_GENERATION diff --git a/vnext/ReactWindowsCore/etw/react_native_windows.man b/vnext/ReactWindowsCore/etw/react_native_windows.man index 6bcd9e9f176..775c5b3169d 100644 --- a/vnext/ReactWindowsCore/etw/react_native_windows.man +++ b/vnext/ReactWindowsCore/etw/react_native_windows.man @@ -1,89 +1,86 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/vnext/ReactWindowsCore/etw/react_native_windows_etw_res.dll b/vnext/ReactWindowsCore/etw/react_native_windows_etw_res.dll new file mode 100644 index 00000000000..e440233d863 Binary files /dev/null and b/vnext/ReactWindowsCore/etw/react_native_windows_etw_res.dll differ diff --git a/vnext/ReactWindowsCore/etw/register.bat b/vnext/ReactWindowsCore/etw/register.bat new file mode 100644 index 00000000000..438a42cf71e --- /dev/null +++ b/vnext/ReactWindowsCore/etw/register.bat @@ -0,0 +1,3 @@ +@echo off +wevtutil um %~dp0\react_native_windows.man +wevtutil im react_native_windows.man /rf:"%~dp0\react_native_windows_etw_res.dll " /mf:"%~dp0\react_native_windows_etw_res.dll" \ No newline at end of file diff --git a/vnext/ReactWindowsCore/tracing/fbsystrace.h b/vnext/ReactWindowsCore/tracing/fbsystrace.h index 5376324be71..256ea90d209 100644 --- a/vnext/ReactWindowsCore/tracing/fbsystrace.h +++ b/vnext/ReactWindowsCore/tracing/fbsystrace.h @@ -9,7 +9,7 @@ #include #define TRACE_TAG_REACT_CXX_BRIDGE 1 << 10 -#define TRACE_TAG_REACT_APPS 1 << 17 +#define TRACE_TAG_REACT_APPS 1 << 11 // Assuming maximum 8 arguments. // TODO :: We assume this magic number "8" at a couple of other places without @@ -20,16 +20,14 @@ namespace facebook { namespace react { namespace tracing { -enum class TraceTask : uint16_t { EvaluateScript, CallJSFunction, CallNativeModules, Unknown }; - void trace_begin_section( + uint64_t id, uint64_t tag, const std::string &profile_name, std::array &&args, - uint8_t size, - TraceTask task); + uint8_t size); -void trace_end_section(uint64_t tag, const std::string &profile_name, double duration, TraceTask task); +void trace_end_section(uint64_t id, uint64_t tag, const std::string &profile_name, double duration); } // namespace tracing } // namespace react } // namespace facebook @@ -41,16 +39,16 @@ namespace fbsystrace { class FbSystraceSection { public: void begin_section() { - facebook::react::tracing::trace_begin_section(tag_, profile_name_, std::move(args_), index_, task_); + facebook::react::tracing::trace_begin_section(id_, tag_, profile_name_, std::move(args_), index_); } void end_section() { facebook::react::tracing::trace_end_section( + id_, tag_, profile_name_, std::chrono::duration_cast>(std::chrono::high_resolution_clock::now() - start_) - .count(), - task_); + .count()); } void init(std::string &&v) { @@ -82,20 +80,7 @@ class FbSystraceSection { template FbSystraceSection(uint64_t tag, std::string &&v, ConvertsToStringPiece &&... rest) : tag_(tag), profile_name_(std::move(v)) { -// This post processing helps in analysing the trace when profiling, but it adds -// some overhead even when the traces are not being captured (i.e. ETW provider -// not enabled.) Hence, the post processing is disabled by default. -#ifdef ENABLE_TRACE_POSTPROCESSING - // Note : We don't want to add any fuzzy text search here as they are - // usually a lot more expensive .. - if (profile_name_.compare("JSIExecutor::loadApplicationScript") == 0) { - task_ = facebook::react::tracing::TraceTask::EvaluateScript; - } else if (profile_name_.compare("JSIExecutor::callFunction") == 0) { - task_ = facebook::react::tracing::TraceTask::CallJSFunction; - } else if (profile_name_.compare("JSIExecutor::callNativeModules") == 0) { - task_ = facebook::react::tracing::TraceTask::CallNativeModules; - } -#endif + id_ = s_id_counter++; init(std::forward(rest)...); } @@ -106,9 +91,12 @@ class FbSystraceSection { private: std::array args_; uint64_t tag_{0}; + + static uint64_t s_id_counter; + uint64_t id_; + std::string profile_name_; uint8_t index_{0}; - facebook::react::tracing::TraceTask task_{facebook::react::tracing::TraceTask::Unknown}; std::chrono::high_resolution_clock::time_point start_{std::chrono::high_resolution_clock::now()}; }; diff --git a/vnext/ReactWindowsCore/tracing/tracing.cpp b/vnext/ReactWindowsCore/tracing/tracing.cpp index ac2cfa674a5..259bffed3e9 100644 --- a/vnext/ReactWindowsCore/tracing/tracing.cpp +++ b/vnext/ReactWindowsCore/tracing/tracing.cpp @@ -17,6 +17,8 @@ using namespace facebook; namespace fbsystrace { +/*static */ uint64_t FbSystraceSection::s_id_counter = 0; + /*static */ std::unordered_map FbSystraceAsyncFlow::s_tracker_; /*static */ std::mutex FbSystraceAsyncFlow::s_tracker_mutex_; @@ -58,99 +60,36 @@ namespace react { namespace tracing { void trace_begin_section( + uint64_t id, uint64_t tag, const std::string &profile_name, std::array &&args, - uint8_t size, - TraceTask task) { - switch (task) { - case TraceTask::EvaluateScript: - EventWriteEVALUATE_SCRIPT_BEGIN( - tag, - profile_name.c_str(), - args[0].c_str(), - args[1].c_str(), - args[2].c_str(), - args[3].c_str(), - args[4].c_str(), - args[5].c_str(), - args[6].c_str(), - args[7].c_str()); - break; - - case TraceTask::CallJSFunction: - EventWriteCALL_JSFUNCTION_BEGIN( - tag, - profile_name.c_str(), - args[0].c_str(), - args[1].c_str(), - args[2].c_str(), - args[3].c_str(), - args[4].c_str(), - args[5].c_str(), - args[6].c_str(), - args[7].c_str()); - break; - - case TraceTask::CallNativeModules: - EventWriteCALL_NATIVEMODULES_BEGIN( - tag, - profile_name.c_str(), - args[0].c_str(), - args[1].c_str(), - args[2].c_str(), - args[3].c_str(), - args[4].c_str(), - args[5].c_str(), - args[6].c_str(), - args[7].c_str()); - break; - - case TraceTask::Unknown: - default: - EventWriteNATIVE_BEGIN_SECTION( - tag, - profile_name.c_str(), - args[0].c_str(), - args[1].c_str(), - args[2].c_str(), - args[3].c_str(), - args[4].c_str(), - args[5].c_str(), - args[6].c_str(), - args[7].c_str()); - break; - } + uint8_t size) { + EventWriteNATIVE_BEGIN_SECTION( + id, + tag, + profile_name.c_str(), + args[0].c_str(), + args[1].c_str(), + args[2].c_str(), + args[3].c_str(), + args[4].c_str(), + args[5].c_str(), + args[6].c_str(), + args[7].c_str()); } -void trace_end_section(uint64_t tag, const std::string &profile_name, double duration, TraceTask task) { - switch (task) { - case TraceTask::EvaluateScript: - EventWriteEVALUATE_SCRIPT_END(tag, profile_name.c_str(), duration); - break; - - case TraceTask::CallJSFunction: - EventWriteCALL_JSFUNCTION_END(tag, profile_name.c_str(), duration); - break; - - case TraceTask::CallNativeModules: - EventWriteCALL_NATIVEMODULES_END(tag, profile_name.c_str(), duration); - break; - - case TraceTask::Unknown: - default: - EventWriteNATIVE_END_SECTION(tag, profile_name.c_str(), duration); - break; - } +void trace_end_section(uint64_t id, uint64_t tag, const std::string &profile_name, double duration) { + EventWriteNATIVE_END_SECTION(id, tag, profile_name.c_str(), duration); } void syncSectionBeginJSHook(uint64_t tag, const std::string &profile_name, const std::string &args) { EventWriteJS_BEGIN_SECTION( - tag, profile_name.c_str(), args.c_str(), nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr); + 0, tag, profile_name.c_str(), args.c_str(), nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr); } void syncSectionEndJSHook(uint64_t tag) { - EventWriteJS_END_SECTION(tag, "", 0); + EventWriteJS_END_SECTION(0, tag, "", 0); } void asyncSectionBeginJSHook(uint64_t tag, const std::string &profile_name, int cookie) { diff --git a/vnext/Shared/OInstance.cpp b/vnext/Shared/OInstance.cpp index 28236e29c5d..a450c701b0e 100644 --- a/vnext/Shared/OInstance.cpp +++ b/vnext/Shared/OInstance.cpp @@ -157,7 +157,7 @@ namespace react { namespace { void runtimeInstaller(jsi::Runtime &runtime) { -#ifdef ENABLE_JS_SYSTRACE +#ifdef ENABLE_JS_SYSTRACE_TO_ETW facebook::react::tracing::initializeJSHooks(runtime); #endif } @@ -362,7 +362,7 @@ InstanceImpl::InstanceImpl( // Temp set the logmarker here facebook::react::ReactMarker::logTaggedMarker = logMarker; -#ifdef ENABLE_TRACING +#ifdef ENABLE_ETW_TRACING // TODO :: Find a better place to initialize ETW once per process. facebook::react::tracing::initializeETW(); #endif