Skip to content

Commit 30f25d0

Browse files
Adding docs for recording with WPR and for the Xaml Frame Analysis plugin for WPA (#4137)
* Add files via upload * Add files via upload * Add files via upload * Add files via upload * Add files via upload * Update wpa-xaml-frame-analysis.md * Kbridge/user/gegao/winui perf docs (#4169) * snapshot * ready for review * dupe image * review feedback * deleting unnecessary files --------- Co-authored-by: KB <[email protected]>
1 parent 47208a0 commit 30f25d0

9 files changed

+92
-17
lines changed

hub/apps/develop/settings/settings-common.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ The format of the backup JSON file. Install, Update, and Uninstall nodes contain
6666
"productVersion": Product version obtained from GetFileVersionInfo,
6767
"peImageType": Image type obtained from PE header,
6868
"peSubsystem": Subsystem obtained from PE header,
69-
"runLevel": Executable's runl”evel obtained from app manifest,
69+
"runLevel": Executable's runlevel obtained from app manifest,
7070
"uiAccess": UI access obtained from app manifest,
7171
"crcChecksum": File's CRC checksum,
7272
"clrVersion": CLR version obtained from app manifest,
@@ -232,7 +232,7 @@ The settings below are for a deprecated Windows calling experience and are no lo
232232
| callerIdBlocked | Bool | Indicates whether the call was blocked. |
233233
| emergencycall | Bool | Indicates whether call was an emergency call. |
234234
| linenumber | String | The number of the phone line that received the call. |
235-
| lineName | String | The phone lines name. |
235+
| lineName | String | The phone line's name. |
236236
| callerLocation | String | Caller location. |
237237
| callerCategory | String | Caller category. |
238238
| callerCategoryDescription | String | Caller category description. |
@@ -247,7 +247,7 @@ The settings below are for a deprecated Windows calling experience and are no lo
247247

248248
| Name | Type | Description |
249249
|------|------|-------------|
250-
| historyItems | Map&lt;string, CallHistoryItem&gt; | A collection of call history items where the keys are each history items UniqueId. |
250+
| historyItems | Map&lt;string, CallHistoryItem&gt; | A collection of call history items where the keys are each history item's UniqueId. |
251251
| highestSequenceNumber | Unit32 | Highest sequence number issued, used for internal business logic. |
252252

253253
### Type: Windows.data.calling.callfavorites structure
@@ -513,8 +513,8 @@ These are blobs that are in the registry. There are three things that use regist
513513

514514
These are settings found in File Explorer->Folder options(...)->General tab
515515

516-
File explorer can be opened to either Home or This PC
517-
File explorer can be opened to One Drive folder as well if user has signed in to One Drive (This option is available only if user has signed in)
516+
* File explorer can be opened to either Home or This PC
517+
* File explorer can be opened to One Drive folder as well if user has signed in to One Drive (This option is available only if user has signed in)
518518

519519
#### FolderOptionGeneralSettings Properties
520520

@@ -704,7 +704,7 @@ The scope of this type is per device.
704704
|------|------|-------------|
705705
| kind | **LockScreenKind** | Specifies whether current Lockscreen is set as Wallpaper or Slideshow or Spotlight |
706706
| pictureOnSignInScreen | bool | Specifies whether show the lock screen background picture on the sign-in screen is enabled. |
707-
| funItems | bool | Specifies whether Get fun facts, tips, tricks, and more on your lock screen" is enabled. |
707+
| funItems | bool | Specifies whether "Get fun facts, tips, tricks, and more on your lock screen" is enabled. |
708708
| itemId | wstring | The unique ID for the lockscreen wallpaper uploaded to during backup. |
709709
| contentUri | wstring | The url for the lockscreen wallpaper uploaded to during backup |
710710
| lockScreenStatus | wstring | Not used. |
@@ -925,15 +925,15 @@ Specifies the folders that are shown at the bottom of the Start menu.
925925
| VisiblePlaces | REG_BINARY | A vector of GUIDs. | A list of GUIDs indicating the folders that are shown at the bottom of Start. |
926926
927927
The folder GUIDs that are supported for *Start_Layout* are:
928-
Documents: {2D34D5CE-FA5A-4543-82F2-22E6EAF7773C}
929-
Downloads: {E367B32F-89DE-4355-BFCE-61F37B18A937}
930-
Music: {B00B0620-7F51-4C32-AA1E-34CC547F7315}
931-
Pictures: {383F07A0-E80A-4C80-B05A-86DB845DBC4D}
932-
Videos: {42B3A5C5-7D86-42F4-80A4-93FACA7A88B5}
933-
Network: {FE758144-080D-42AE-8BDA-34ED97B66394}
934-
UserProfile: {74BDB04A-F94A-4F68-8BD6-4398071DA8BC}
935-
Explorer: {148A24BC-D60C-4289-A080-6ED9BBA24882}
936-
Settings: {52730886-51AA-4243-9F7B-2776584659D4}
928+
* Documents: {2D34D5CE-FA5A-4543-82F2-22E6EAF7773C}
929+
* Downloads: {E367B32F-89DE-4355-BFCE-61F37B18A937}
930+
* Music: {B00B0620-7F51-4C32-AA1E-34CC547F7315}
931+
* Pictures: {383F07A0-E80A-4C80-B05A-86DB845DBC4D}
932+
* Videos: {42B3A5C5-7D86-42F4-80A4-93FACA7A88B5}
933+
* Network: {FE758144-080D-42AE-8BDA-34ED97B66394}
934+
* UserProfile: {74BDB04A-F94A-4F68-8BD6-4398071DA8BC}
935+
* Explorer: {148A24BC-D60C-4289-A080-6ED9BBA24882}
936+
* Settings: {52730886-51AA-4243-9F7B-2776584659D4}
937937
938938
## Personalization - Start - Layout
939939
@@ -1045,7 +1045,7 @@ Provides information about Microsoft accounts (MSA) and work or school accounts
10451045
| country | wstring | The code of the country or region in which a MSA is registered. |
10461046
| safeCustomerId | wstring | An alternative identifier for an MSA. |
10471047
| ageGroup | wstring | Age group of an MSA, based on the registered birth date of the MSA user. Current values are 0 = unknown, 1 = child, 2 = teen, 3 = adult. |
1048-
| scope | wstring | Represents the Sign in options" setting state. |
1048+
| scope | wstring | Represents the "Sign in options" setting state. |
10491049
10501050
### Type: Windows.Data.Account.SecondaryAccounts structure
10511051
@@ -1127,7 +1127,7 @@ Settings related to Windows Update.
11271127
11281128
| Registry value | Type | Data | Description |
11291129
|---------------|------|-------|-------------|
1130-
| IsContinuousInnovationOptedIn | REG_DWORD | 0/1 | Enables devices to get the latest updates as soon as theyre released. |
1130+
| IsContinuousInnovationOptedIn | REG_DWORD | 0/1 | Enables devices to get the latest updates as soon as they're released. |
11311131
| AllowMUUpdateService | REG_DWORD | 0/1 | Allows users to get other Microsoft products alongside with Windows Updates. |
11321132
| IsExpedited | REG_DWORD | 0/1 | User selects this to invoke device restart 15 min after all updates finished installing. |
11331133
| RestartNotificationsAllowed2 | REG_DWORD | 0/1 | Users decides if they want to be notified about the updates pending restart. |
35.7 KB
Loading
457 KB
Loading
226 KB
Loading
290 KB
Loading
125 KB
Loading
64.3 KB
Loading

hub/apps/performance/winui-perf.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
---
2+
title: WinUI performance optimization
3+
description: Learn how to use performance monitoring tools from the Windows Performance Toolkit to produce in-depth performance profiles of WinUI applications.
4+
ms.topic: conceptual
5+
ms.date: 03/06/2024
6+
#Customer intent: As a Windows application developer, I want to improve the responsiveness of my WinUI application by finding slow UI thread frames to optimize.
7+
---
8+
9+
# WinUI performance optimization
10+
11+
This topic describes how to use performance monitoring tools from the [Windows Performance Toolkit](/windows-hardware/test/wpt/) to produce in-depth performance profiles for WinUI applications.
12+
13+
## How do I use the Windows Performance Recorder to monitor WinUI apps?
14+
15+
The [Windows Performance Recorder (WPR)](/windows-hardware/test/wpt/windows-performance-recorder) can be used to create detailed [Event Tracing for Windows (ETW)](/windows/win32/etw/event-tracing-portal) recordings of system and application behavior and resource usage based on built-in profiles. These ETW recordings can then be processed by the [Windows Performance Analyzer (WPA)](/windows-hardware/test/wpt/windows-performance-analyzer) to produce a set of graphs and tables for easier consumption and in-depth analysis of CPU usage, power issues, poor system or application performance, and other performance issues.
16+
17+
> [!NOTE]
18+
> While there are both GUI and command-line versions of the WPR, this topic refers only to the GUI version (see [Introduction to WPR](/windows-hardware/test/wpt/introduction-to-wpr) for more details on both versions).
19+
20+
### WPR profiles
21+
22+
WPR profiles are used to collect information on various aspects and behaviors of your app.
23+
24+
In the following image, the Windows Performance Recorder window is shown with the "CPU usage" profile (CPU utilization for each CPU on the system) and "XAML activity" profile (events from XAML-related providers, such as WinUI) selected.
25+
26+
:::image type="content" source="images/windows-performance-recorder-profile-selector.png" alt-text="Screenshot of the Windows Performance Recorder with CPU usage and XAML activity profiles selected.":::
27+
28+
## How do I use the Windows Performance Analyzer with WinUI apps?
29+
30+
WinUI is a declarative, [retained-mode](/windows/win32/learnwin32/retained-mode-versus-immediate-mode) API where the app describes a tree of UIElements and WinUI runs layout and renders it. This is done on the UI thread in batches called "frames", which should complete quickly, ideally within one refresh interval of the display. When frames run long, not only does it delay updates from making it to the display, but it also prevents the UI thread from handling input. Slow frames, while not the only reason for responsiveness problems, are one of the most common.
31+
32+
### Install the "XAML Frame Analysis" plugin
33+
34+
WinUI logs ETW events that track the start and stop of each frame (shown in the following screenshot of the WPA "Generic Events" table). However, because the duration of each frame needs to be calculated manually, it's difficult to identify slow frame occurences.
35+
36+
:::image type="content" source="images/wpa-generic-events.png" alt-text="Screenshot of the Windows Performance Analyzer showing the Generic Events table with a series of frame starts and stops.":::
37+
38+
To address this issue, a new "XAML Frame Analysis" table plugin is included with the [Windows Assessment Toolkit (ADK) preview](https://www.microsoft.com/software-download/windowsinsiderpreviewadk), build 26020 and later. This table calculates and shows the duration of each frame (along with other time-consuming operations).
39+
40+
> [!NOTE]
41+
> While only the preview version of the Windows Performance Analyzer (WPA) has the "XAML Frame Analysis" table, the version of WPR used to take the trace does not matter.
42+
43+
Once the ADK preview is installed, the "XAML Frame Analysis" table must be enabled by editing the "perfcore.ini" config file in the WPA folder (typically, C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\). To do this, close any open instances of WPA, open "perfcore.ini" in a text editor, add `perf_xaml.dll` to the list of dlls, and save and close the file. Restart WPA, which should now show the "XAML Frame Analysis" graph at the bottom of the System Activity section.
44+
45+
:::image type="content" source="images/wpa-xaml-frame-analysis.png" alt-text="Screenshot of the Windows Performance Analyzer showing the XAML Frame Analysis table at the bottom of the System Activity section.":::
46+
47+
### Use the "XAML Frame Analysis" plugin
48+
49+
The Xaml Frame Analysis supports two views (both views show the same columns):
50+
51+
- "Interesting Xaml Frames" (default) - Shows WinUI frames based on heuristics that identify those most likely to cause responsiveness problems. These correspond to regions that start with operations like WinUI initialization, frame navigation, or flyout display, and stop with the end of the next frame. These scenarios typically involve extensive changes to the UIElement tree and are the most susceptible to performance problems.
52+
- "All Xaml Info" - Shows all WinUI frames from all process found in the trace. For operations like a frame or a layout pass, the plugin automatically computes and displays the durations based on the Start and Stop events.
53+
54+
The following screenshot highlights how to switch between Xaml Frame Analysis views.
55+
56+
:::image type="content" source="images/wpa-xaml-frame-analysis-all-xaml-info.png" alt-text="Screenshot of the Windows Performance Analyzer showing the View selectors for the Xaml Frame Analysis table.":::
57+
58+
Both Xaml Frame Analysis views include the following columns:
59+
60+
| Title | Value |
61+
| ----- | ----- |
62+
| Process | Process name and ID |
63+
| Thread ID | Thread ID |
64+
| Type | Describes the event corresponding to the row. Possible values include:<br><ul><li>*WXM::InitializeForCurrentThread* - A call to [WindowsXamlManager.InitializeForCurrentThread](/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.hosting.windowsxamlmanager.initializeforcurrentthread). Initializes WinUI on the thread.</li><li>*DWXS::Initialize* - A call to [DesktopWindowXamlSource.Initialize](/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.hosting.desktopwindowxamlsource.initialize). Initializes a WinUI island.</li><li>*Frame* - A frame on the UI thread. Runs layout and renders changes to the tree since the previous frame.</li><li>*Create graphics device* - Create a D3D and a D2D device for WinUI. Occurs on a background thread.</li><li>*UpdateLayout* - A layout pass on the UI thread. Occurs as part of a frame, but can also be triggered by the app through [UIElement.UpdateLayout](/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.uielement.updatelayout).</li><li>*Frame::Navigating* - WinUI raises the [Frame.Navigating](/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.controls.frame.navigating) event.</li><li>*Frame::Navigated* - WinUI raises the [Frame.Navigated](/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.controls.frame.navigated) event.</li><li>*Hwnd Focus* - The active hwnd changed.</li><li>*Region of Interest* - A region computed by the plugin for interesting scenarios. Starts after events such as WinUI initialization, frame navigation, and opening menus. Stops at the end of the next frame.</li></ul>|
65+
| IsInteresting | Whether the row is considered interesting. Only interesting rows show up in the Interesting Xaml Frames view. |
66+
| Duration (ms) | The duration of the row. Computed from Start and Stop events. |
67+
| Weight (ms) | The actual CPU execution time corresponding to the duration. |
68+
| Start (s) | The time of the Start event |
69+
| Stop (s) | The time of the Stop event |
70+
71+
Columns can be sorted by Type or Duration to help identify potential issues such as the most expensive, longest duration frames in the trace (see following image). You can also drill down into specific rows to identify the expensive operations and potential optimizations.
72+
73+
:::image type="content" source="images/wpa-xaml-frame-analysis-sort-frames.png" alt-text="Screenshot of the Windows Performance Analyzer showing the All XAML Info table, sorted by Duration (ms).":::

hub/apps/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,8 @@ items:
555555
href: performance/power.md
556556
- name: Improve responsiveness
557557
href: performance/responsive.md
558+
- name: WinUI performance optimization
559+
href: performance/winui-perf.md
558560
- name: Deploy
559561
items:
560562
- name: Deployment overview

0 commit comments

Comments
 (0)