diff --git a/change/react-native-windows-2019-12-09-21-30-51-TRACING_59.json b/change/react-native-windows-2019-12-09-21-30-51-TRACING_59.json new file mode 100644 index 00000000000..44762cd236e --- /dev/null +++ b/change/react-native-windows-2019-12-09-21-30-51-TRACING_59.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": "d24ae5a5f45c08dc7b71750c230fb7374c4febbe", + "date": "2019-12-10T05:30:51.283Z" +} \ No newline at end of file diff --git a/vnext/Chakra/ChakraExecutor.cpp b/vnext/Chakra/ChakraExecutor.cpp index 1355f3f9ffb..abcf0cb6eaa 100644 --- a/vnext/Chakra/ChakraExecutor.cpp +++ b/vnext/Chakra/ChakraExecutor.cpp @@ -391,7 +391,7 @@ void ChakraExecutor::initOnJSVMThread() { } // JS Tracing enabled only in verbose mode. -#ifdef ENABLE_JS_SYSTRACE +#ifdef ENABLE_JS_SYSTRACE_TO_ETW addNativeTracingHooks(); setGlobalVariable( "__RCTProfileIsProfiling", std::make_unique("true")); diff --git a/vnext/Chakra/ChakraTracing.cpp b/vnext/Chakra/ChakraTracing.cpp index 6206390581d..bb2c67cce0d 100644 --- a/vnext/Chakra/ChakraTracing.cpp +++ b/vnext/Chakra/ChakraTracing.cpp @@ -17,7 +17,7 @@ namespace { INativeTraceHandler *g_nativeTracingHook = nullptr; -#ifdef ENABLE_JS_SYSTRACE +#ifdef ENABLE_JS_SYSTRACE_TO_ETW static JsValueRef __stdcall nativeTraceBeginSectionJNF( JsValueRef /*function*/, @@ -307,7 +307,7 @@ void SystraceEndSection( } } -#ifdef ENABLE_JS_SYSTRACE +#ifdef ENABLE_JS_SYSTRACE_TO_ETW void addNativeTracingHooks() { installGlobalFunction("nativeTraceBeginSection", nativeTraceBeginSectionJNF); diff --git a/vnext/Desktop/React.Windows.Desktop.vcxproj b/vnext/Desktop/React.Windows.Desktop.vcxproj index 081d2bea06a..fb71dbfcb89 100644 --- a/vnext/Desktop/React.Windows.Desktop.vcxproj +++ b/vnext/Desktop/React.Windows.Desktop.vcxproj @@ -47,7 +47,7 @@ - $(ReactNativeWindowsDir);$(FollyDir);$(ReactNativeWindowsDir)stubs;$(MSBuildProjectDirectory);$(ReactNativeWindowsDir)ReactWindowsCore;$(ReactNativeWindowsDir)include\ReactWindowsCore;$(ReactNativeDir)\ReactCommon;$(ReactNativeDir)\ReactCommon\jsi;$(IncludePath) + $(ReactNativeWindowsDir);$(FollyDir);$(ReactNativeWindowsDir)stubs;$(MSBuildProjectDirectory);$(ReactNativeWindowsDir)ReactWindowsCore;$(ReactNativeWindowsDir)\ReactWindowsCore\tracing;$(ReactNativeWindowsDir)include\ReactWindowsCore;$(ReactNativeDir)\ReactCommon;$(ReactNativeDir)\ReactCommon\jsi;$(IncludePath) true @@ -56,6 +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_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/PropertySheets/React.Cpp.props b/vnext/PropertySheets/React.Cpp.props index 01d9b19395c..a0d92042d67 100644 --- a/vnext/PropertySheets/React.Cpp.props +++ b/vnext/PropertySheets/React.Cpp.props @@ -19,9 +19,14 @@ false false - false - false - false + + true + + + true + + + true diff --git a/vnext/ReactCommon/ReactCommon.vcxproj b/vnext/ReactCommon/ReactCommon.vcxproj index dab8fa352fc..bb9245b5937 100644 --- a/vnext/ReactCommon/ReactCommon.vcxproj +++ b/vnext/ReactCommon/ReactCommon.vcxproj @@ -66,8 +66,8 @@ false true $(ReactNativeDir)\ReactCommon;$(ReactNativeDir)\ReactCommon\jsi;$(ReactNativeDir)\ReactCommon\jsiexecutor;$(FollyDir);$(ReactNativeWindowsDir)stubs;;$(ReactNativeWindowsDir)\ReactWindowsCore\tracing;%(AdditionalIncludeDirectories) - ENABLE_NATIVE_SYSTRACE;WITH_FBSYSTRACE;%(PreprocessorDefinitions) - ENABLE_JS_SYSTRACE;WITH_FBSYSTRACE;%(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 b47ef097181..fdd97781b57 100644 --- a/vnext/ReactUWP/ReactUWP.vcxproj +++ b/vnext/ReactUWP/ReactUWP.vcxproj @@ -75,9 +75,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_ETW_TRACING;%(PreprocessorDefinitions) + ENABLE_NATIVE_SYSTRACE_TO_ETW;WITH_FBSYSTRACE;%(PreprocessorDefinitions) + ENABLE_JS_SYSTRACE_TO_ETW;WITH_FBSYSTRACE;%(PreprocessorDefinitions) OLD_CPPWINRT;REACTWINDOWS_BUILD;RN_PLATFORM=windows;NOMINMAX;FOLLY_NO_CONFIG;RN_EXPORT=;JSI_EXPORT=;WIN32=0;WINRT=1;_HAS_AUTO_PTR_ETC;%(PreprocessorDefinitions) $(ReactNativeWindowsDir);$(ReactNativeWindowsDir)Pch;$(ReactNativeWindowsDir)ReactUWP\GeneratedWinmdHeader;$(ReactNativeWindowsDir)ReactWindowsCore;$(ReactNativeWindowsDir)include\ReactWindowsCore;$(ReactNativeWindowsDir)include\ReactUWP;$(YogaDir);$(ReactNativeDir)\ReactCommon;$(ReactNativeDir)\ReactCommon\jsi;$(ReactNativeWindowsDir)include;$(ReactNativeWindowsDir)stubs;$(ReactNativeWindowsDir)Shared;$(ReactNativeWindowsDir)\ReactWindowsCore\tracing;$(FollyDir);%(AdditionalIncludeDirectories) $(ChakraCoreInclude);$(ChakraCoreDebugInclude);%(AdditionalIncludeDirectories) diff --git a/vnext/ReactWindowsCore/ReactWindowsCore.vcxproj b/vnext/ReactWindowsCore/ReactWindowsCore.vcxproj index 36a5b2fcd3c..6bdd09b6dc2 100644 --- a/vnext/ReactWindowsCore/ReactWindowsCore.vcxproj +++ b/vnext/ReactWindowsCore/ReactWindowsCore.vcxproj @@ -70,9 +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_ETW_TRACING;%(PreprocessorDefinitions) + ENABLE_NATIVE_SYSTRACE_TO_ETW;WITH_FBSYSTRACE;%(PreprocessorDefinitions) + ENABLE_JS_SYSTRACE_TO_ETW;WITH_FBSYSTRACE;%(PreprocessorDefinitions) $(ReactNativeWindowsDir)Shared;$(ReactNativeWindowsDir);$(ReactNativeWindowsDir)include;$(ReactNativeWindowsDir)include\ReactWindowsCore;$(ReactNativeDir)\ReactCommon;$(ReactNativeDir)\ReactCommon\jsi;$(ReactNativeWindowsDir)stubs;$(FollyDir);$(ReactNativeWindowsDir)\ReactWindowsCore\tracing;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) $(SolutionDir)packages\ReactNative.Hermes.Windows.0.1.3\installed\$(VcpkgTriplet)\include\;%(AdditionalIncludeDirectories) $(SolutionDir)packages\ReactNative.V8JSI.Windows.0.1.4\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 28fd15249ff..e75b4baea2d 100644 --- a/vnext/ReactWindowsCore/etw/react_native_windows.h +++ b/vnext/ReactWindowsCore/etw/react_native_windows.h @@ -733,37 +733,39 @@ EXTERN_C __declspec(selectany) MCGEN_TRACE_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) // @@ -775,21 +777,23 @@ EXTERN_C __declspec(selectany) MCGEN_TRACE_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) \ +#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(tag, profileName, duration) \ - McTemplateU0xsg( \ - &REACT_NATIVE_WINDOWS_Context, \ - &JS_END_SECTION, \ - tag, \ - profileName, \ +#define EventWriteJS_END_SECTION_AssumeEnabled(id, tag, profileName, duration) \ + McTemplateU0xxsg( \ + &REACT_NATIVE_WINDOWS_Context, \ + &JS_END_SECTION, \ + id, \ + tag, \ + profileName, \ duration) // @@ -935,37 +939,39 @@ EXTERN_C __declspec(selectany) MCGEN_TRACE_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) // @@ -977,20 +983,22 @@ EXTERN_C __declspec(selectany) MCGEN_TRACE_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) \ +#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( \ - tag, profileName, duration) \ - McTemplateU0xsg( \ + id, tag, profileName, duration) \ + McTemplateU0xxsg( \ &REACT_NATIVE_WINDOWS_Context, \ &EVALUATE_SCRIPT_END, \ + id, \ tag, \ profileName, \ duration) @@ -1004,37 +1012,39 @@ EXTERN_C __declspec(selectany) MCGEN_TRACE_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) // @@ -1046,20 +1056,22 @@ EXTERN_C __declspec(selectany) MCGEN_TRACE_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) \ +#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( \ - tag, profileName, duration) \ - McTemplateU0xsg( \ + id, tag, profileName, duration) \ + McTemplateU0xxsg( \ &REACT_NATIVE_WINDOWS_Context, \ &CALL_JSFUNCTION_END, \ + id, \ tag, \ profileName, \ duration) @@ -1073,37 +1085,39 @@ EXTERN_C __declspec(selectany) MCGEN_TRACE_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) // @@ -1115,20 +1129,22 @@ EXTERN_C __declspec(selectany) MCGEN_TRACE_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) \ +#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( \ - tag, profileName, duration) \ - McTemplateU0xsg( \ + id, tag, profileName, duration) \ + McTemplateU0xxsg( \ &REACT_NATIVE_WINDOWS_Context, \ &CALL_NATIVEMODULES_END, \ + id, \ tag, \ profileName, \ duration) @@ -1142,37 +1158,39 @@ EXTERN_C __declspec(selectany) MCGEN_TRACE_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) // @@ -1184,21 +1202,24 @@ EXTERN_C __declspec(selectany) MCGEN_TRACE_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) \ +#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(tag, profileName, duration) \ - McTemplateU0xsg( \ - &REACT_NATIVE_WINDOWS_Context, \ - &NATIVE_END_SECTION, \ - tag, \ - profileName, \ +#define EventWriteNATIVE_END_SECTION_AssumeEnabled( \ + id, tag, profileName, duration) \ + McTemplateU0xxsg( \ + &REACT_NATIVE_WINDOWS_Context, \ + &NATIVE_END_SECTION, \ + id, \ + tag, \ + profileName, \ duration) // @@ -1422,47 +1443,50 @@ 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)) + &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); + 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, @@ -1470,18 +1494,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], @@ -1531,14 +1552,20 @@ McTemplateU0xsssssssss( (_Arg9 != NULL) ? (ULONG)((strlen(_Arg9) + 1) * sizeof(char)) : (ULONG)sizeof("NULL")); + EventDataDescCreate( + &EventData[11], + (_Arg10 != NULL) ? _Arg10 : "NULL", + (_Arg10 != NULL) ? (ULONG)((strlen(_Arg10) + 1) * sizeof(char)) + : (ULONG)sizeof("NULL")); + return McGenEventWrite( Context, Descriptor, NULL, - McTemplateU0xsssssssss_ARGCOUNT + 1, + 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 88b1376cd66..9e50ffe86b1 100644 --- a/vnext/ReactWindowsCore/tracing/fbsystrace.h +++ b/vnext/ReactWindowsCore/tracing/fbsystrace.h @@ -20,25 +20,18 @@ 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 id, uint64_t tag, const std::string &profile_name, - double duration, - TraceTask task); + double duration); } // namespace tracing } // namespace react } // namespace facebook @@ -51,17 +44,17 @@ class FbSystraceSection { public: void begin_section() { facebook::react::tracing::trace_begin_section( - tag_, profile_name_, std::move(args_), index_, task_); + 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) { @@ -96,16 +89,7 @@ class FbSystraceSection { std::string &&v, ConvertsToStringPiece &&... rest) : tag_(tag), profile_name_(std::move(v)) { - // 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; - } - + id_ = s_id_counter++; init(std::forward(rest)...); } @@ -116,10 +100,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 0667519a103..ed79ab58d4a 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_; @@ -62,94 +64,31 @@ 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 id, 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; - } + double duration) { + EventWriteNATIVE_END_SECTION(id, tag, profile_name.c_str(), duration); } void syncSectionBeginJSHook( @@ -157,6 +96,7 @@ void syncSectionBeginJSHook( const std::string &profile_name, const std::string &args) { EventWriteJS_BEGIN_SECTION( + 0, tag, profile_name.c_str(), args.c_str(), @@ -170,7 +110,7 @@ void syncSectionBeginJSHook( } void syncSectionEndJSHook(uint64_t tag) { - EventWriteJS_END_SECTION(tag, "", 0); + EventWriteJS_END_SECTION(0, tag, "", 0); } void asyncSectionBeginJSHook( @@ -206,6 +146,10 @@ void counterJSHook(uint64_t tag, const std::string &profile_name, int value) { } void initializeJSHooks(jsi::Runtime &runtime) { + // Don't hook up unless the provider is enabled. + if (!EventEnabledJS_ASYNC_BEGIN_FLOW()) + return; + runtime.global().setProperty(runtime, "__RCTProfileIsProfiling", true); runtime.global().setProperty( diff --git a/vnext/Shared/OInstance.cpp b/vnext/Shared/OInstance.cpp index 17d4375bcd4..be1e89a667c 100644 --- a/vnext/Shared/OInstance.cpp +++ b/vnext/Shared/OInstance.cpp @@ -198,7 +198,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 } @@ -421,7 +421,7 @@ InstanceImpl::InstanceImpl( facebook::react::ReactMarker::logTaggedMarker = logMarker; #endif -#ifdef ENABLE_TRACING +#ifdef ENABLE_ETW_TRACING // TODO :: Find a better place to initialize ETW once per process. facebook::react::tracing::initializeETW(); #endif