-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
261 additions
and
1,423 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/react-native-windows-df0a05f5-87f4-41ae-a165-0a455e0278fa.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "patch", | ||
"comment": "Initialize ETW provider only once", | ||
"packageName": "react-native-windows", | ||
"email": "asklar@microsoft.com", | ||
"dependentChangeType": "patch" | ||
} |
7 changes: 7 additions & 0 deletions
7
change/react-native-windows-f33f3a80-612e-479a-8d8c-c51c611b8e29.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "patch", | ||
"comment": "Last year, we had plumbed the Systrace sections and events in the core react native to windows code and fired ETW events. But, it was hard for people to use because we used manifest based ETW events. This change converts the event triggering code to use Tracelogging APIs (aka self describing events) which doesn't require the manifest to be registered on the host machine to inspect traces.\n Post this change, the systrace events can be inspected on any windows machines where the RNW based apps are running by issuing the following commands, \nwpr.exe -start rnw.wprp\nwpr.exe -stop rnw.etl\nwpa.exe rnw.etl\n\nThis works for Win32 apps too, say Office.", | ||
"packageName": "react-native-windows", | ||
"email": "mganandraj@outlook.com", | ||
"dependentChangeType": "patch" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Event Tracing in ReactNative for Windows | ||
|
||
React native for Windows implements an event provider using [Event Tracing for Windows (ETW)](https://docs.microsoft.com/en-us/windows/win32/etw/event-tracing-portal) framework, to enable instrumenting and analyzing performance critical source code. Events generated by an ETW provider can be observed and analyzed using tools available through [Windows Performance Toolkit (WPT)](https://docs.microsoft.com/en-us/windows-hardware/test/wpt/). | ||
|
||
Currently, we have implemented the [Systrace APIs](https://stuff.mit.edu/afs/sipb/project/android/docs/tools/help/systrace.html) on Windows to generate ETW events. Systrace APIs are used to instrument the core React Native source code. In future, we will instrument more of the React Native Windows source code with ETW events. | ||
|
||
Tracing sessions can be managed as described below, | ||
|
||
## Start a tracing session | ||
|
||
1. Trace only events generated by React Native For Windows providers, | ||
|
||
```powershell | ||
& .\vnext\Scripts\Tracing\Start-Tracing.ps1 | ||
``` | ||
|
||
2. Trace events generated by React Native For Windows as well as the general system providers, | ||
|
||
```powershell | ||
& .\vnext\Scripts\Tracing\Start-Tracing.ps1 -IncludeGeneralTrace=$True | ||
``` | ||
|
||
## Stop a tracing session and anayze the traces | ||
|
||
1. Stop the session and start anaylizing the traces, | ||
|
||
```powershell | ||
& .\vnext\Scripts\Tracing\Stop-Tracing.ps1 | ||
``` | ||
|
||
2. Stop the session only, | ||
|
||
```powershell | ||
& .\vnext\Scripts\Tracing\Stop-Tracing.ps1 -NoAnalysis=$True | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
param( | ||
[bool]$IncludeGeneralTrace = $False | ||
) | ||
|
||
$scriptPath = split-path -parent $MyInvocation.MyCommand.Definition | ||
$wprpPath = Join-Path -Path $scriptPath -ChildPath "rnw.wprp" | ||
|
||
if (!(Get-Command "wpr.exe" -ErrorAction SilentlyContinue)) { | ||
throw " | ||
################################################################ | ||
wpr.exe (Windows Performance Recorder) unavailable ! | ||
Ensure that WPT (Windows Performance Toolkit) is installed and its tools are added to the path | ||
################################################################" | ||
} | ||
|
||
$wprArgs = "-start", $wprpPath | ||
|
||
if ($IncludeGeneralTrace) { | ||
$wprArgs += "-start", "GeneralProfile" | ||
} | ||
|
||
|
||
Write-Host "wpr.exe $wprArgs" | ||
& Start-Process -Verb RunAs "wpr.exe" -ArgumentList $wprArgs -PassThru -Wait | ||
|
||
Write-Host "To stop this trace and start analysis, run .\Stop-Tracing.ps1" | ||
Write-Host "To stop this trace only, run .\Stop-Tracing.ps1 -NoAnalysis $True" | ||
Write-Host |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
param( | ||
[bool]$NoAnalysis = $False | ||
) | ||
|
||
$mypath = split-path -parent $MyInvocation.MyCommand.Definition | ||
$timestamp = [DateTime]::Now.ToString("yyyyMMdd_HHmmss") | ||
$fileName = "rnw_" + $timestamp + ".etl" | ||
$etlPath = Join-Path -Path $mypath -ChildPath $fileName | ||
|
||
if (!(Get-Command "wpr.exe" -ErrorAction SilentlyContinue)) { | ||
throw " | ||
################################################################ | ||
wpr.exe (Windows Performance Recorder) unavailable ! | ||
Ensure that WPT (Windows Performance Toolkit) is installed and its tools are added to the path | ||
################################################################" | ||
} | ||
|
||
$wprArgs = "-stop", $etlPath | ||
|
||
Write-Host "wpr.exe $wprArgs" | ||
& Start-Process -Verb RunAs "wpr.exe" -ArgumentList $wprArgs -PassThru -Wait | ||
|
||
if (!(Get-Command "wpa.exe" -ErrorAction SilentlyContinue)) { | ||
Write-Host "wpa.exe (Windows Performance Analyzer) unavailable !" | ||
Write-Host "Ensure that WPT (Windows Performance Toolkit) is installed and its tools are added to the path " | ||
} | ||
|
||
if ($NoAnalysis) { | ||
Write-Host "To analys this trace, install WPT and run: 'wpa $etlPath'" | ||
} | ||
else { | ||
|
||
if (!(Get-Command "wpa.exe" -ErrorAction SilentlyContinue)) { | ||
throw " | ||
################################################################ | ||
wpa.exe (Windows Performance Analyzer) unavailable ! | ||
Ensure that WPT (Windows Performance Toolkit) is installed and its tools are added to the path | ||
################################################################" | ||
} | ||
|
||
$wpaArgs = $etlPath | ||
Write-Host "wpa.exe $wpaArgs" | ||
& Start-Process -Verb RunAs "wpa.exe" -ArgumentList $wpaArgs | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- TODO: | ||
1. Find and replace "RNWTraceLoggingProvider" with the name of your provider. | ||
2. See TODO below to update GUID for your event provider | ||
--> | ||
<WindowsPerformanceRecorder Version="1.0" Author="Microsoft Corporation" Copyright="Microsoft Corporation" Company="Microsoft Corporation"> | ||
<Profiles> | ||
<EventCollector Id="EventCollector_RNWTraceLoggingProvider" Name="RNWTraceLoggingProvider"> | ||
<BufferSize Value="64" /> | ||
<Buffers Value="4" /> | ||
</EventCollector> | ||
|
||
<!-- TODO: | ||
1. Update Name attribute in EventProvider xml element with your provider GUID, eg: Name="3970F9cf-2c0c-4f11-b1cc-e3a1e9958833". Or | ||
if you specify an EventSource C# provider or call TraceLoggingRegister(...) without a GUID, use star (*) before your provider | ||
name, eg: Name="*MyEventSourceProvider" which will enable your provider appropriately. | ||
2. This sample lists one EventProvider xml element and references it in a Profile with EventProviderId xml element. | ||
For your component wprp, enable the required number of providers and fix the Profile xml element appropriately | ||
--> | ||
<EventProvider Id="EventProvider_RNWTraceLoggingProvider" Name="910fb9a1-75dd-4cf4-beec-da21341f20c8" /> | ||
|
||
<Profile Id="RNWTraceLoggingProvider.Verbose.File" Name="RNWTraceLoggingProvider" Description="RNWTraceLoggingProvider" LoggingMode="File" DetailLevel="Verbose"> | ||
<Collectors> | ||
<EventCollectorId Value="EventCollector_RNWTraceLoggingProvider"> | ||
<EventProviders> | ||
<!-- TODO: | ||
1. Fix your EventProviderId with Value same as the Id attribute on EventProvider xml element above | ||
--> | ||
<EventProviderId Value="EventProvider_RNWTraceLoggingProvider" /> | ||
</EventProviders> | ||
</EventCollectorId> | ||
</Collectors> | ||
</Profile> | ||
|
||
<Profile Id="RNWTraceLoggingProvider.Light.File" Name="RNWTraceLoggingProvider" Description="RNWTraceLoggingProvider" Base="RNWTraceLoggingProvider.Verbose.File" LoggingMode="File" DetailLevel="Light" /> | ||
<Profile Id="RNWTraceLoggingProvider.Verbose.Memory" Name="RNWTraceLoggingProvider" Description="RNWTraceLoggingProvider" Base="RNWTraceLoggingProvider.Verbose.File" LoggingMode="Memory" DetailLevel="Verbose" /> | ||
<Profile Id="RNWTraceLoggingProvider.Light.Memory" Name="RNWTraceLoggingProvider" Description="RNWTraceLoggingProvider" Base="RNWTraceLoggingProvider.Verbose.File" LoggingMode="Memory" DetailLevel="Light" /> | ||
|
||
</Profiles> | ||
</WindowsPerformanceRecorder> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.