react-native-windows icon indicating copy to clipboard operation
react-native-windows copied to clipboard

Adds Systrace to view management APIs for UIManager

Open rozele opened this issue 3 years ago • 2 comments

Description

Type of Change

Erase all that don't apply.

  • New feature (non-breaking change which adds functionality)

Why

Adds a few SystraceSections to improve instrumentation for performance measurements.

What

This change adds SystraceSections to many relevant UIManager and View calls for more visibility into what work is being done by RN.

Specifically, it instruments the following:

  1. Frequent view management APIs for the top-level UIManager and the NativeUIManager (e.g., createView, updateView, manageChildren, etc.). It does not currently measure any context switching from JS to UI thread.
  2. Potential hot spots for ViewViewManager, like replacing the ViewPanel with a ViewControl (via ReplaceView, TransferProperties, etc.).
  3. Time spent preparing for and executing Yoga layout, including extra XAML layout calls made to prepare the view for Yoga layout (e.g., UpdateExtraLayout and NeedsForceLayout), the call to YGNodeCalculateLayout, and the calls to SetLayoutProps.

Screenshots

I have not tested what this does in ETW, but here is a screen shot from one of our perf traces using an internal tool at Meta:

image

This has a bit of extra detail, as I added a few other traces (e.g., text measurement callbacks, XAML layout calls in MeasureOverride/ArrangeOverride), but most of these get throttled because they are too short and too frequent.

Optional: Describe the tests that you ran locally to verify your changes.

Microsoft Reviewers: Open in CodeFlow

rozele avatar Aug 02 '22 14:08 rozele

CC @marlenecota - we should make sure these events show up properly in WPA and other Windows perf tools.

asklar avatar Aug 02 '22 18:08 asklar

CC @marlenecota Marlene Cota FTE - we should make sure these events show up properly in WPA and other Windows perf tools.

As I understand it, the SystraceSection blocks will cause start and end ETW events to be Tracelogged:

// Define the GUID to use in TraceLoggingProviderRegister
// {910FB9A1-75DD-4CF4-BEEC-DA21341F20C8}
TRACELOGGING_DEFINE_PROVIDER(
    g_hTraceLoggingProvider,
    "Microsoft.ReactNativeWindows",
    (0x910fb9a1, 0x75dd, 0x4cf4, 0xbe, 0xec, 0xda, 0x21, 0x34, 0x1f, 0x20, 0xc8));

jonthysell avatar Aug 05 '22 00:08 jonthysell