Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: how to trace slow UI in a XAML app (e.g. Windows Terminal) #2648

Closed
vadimkantorov opened this issue Jun 12, 2020 · 21 comments
Closed

Comments

@vadimkantorov
Copy link

vadimkantorov commented Jun 12, 2020

I have slow reaction (up to 5 seconds) reaction of New Tab buttons in Windows Terminal (context menu takes a few seconds to appear; new tab button freezes for a few seconds before even a new tab is created). I reported the issue in WT repo: microsoft/terminal#6409

I asked how to enable tracing of WT UI handling. I was directed by @zadjii-msft to ask this question in this repo, and @zadjii-msft strongly suggested that the slowness comes not from WT code but from XAML framework itself.

Are there generic ways to trace what is happening? (e.g. what events are emitted and how long do their handling takes). I have zero context about how WT uses XAML or what it does on handling the button clicks. Unfortunately, I don't have experience with using perf.exe or Event Tracing, but I'll be happy to try any instructions you suggest.

My system has about 80% of used physical memory and HDD (it's a L470 lenovo laptop).

@msft-github-bot msft-github-bot added the needs-triage Issue needs to be triaged by the area owners label Jun 12, 2020
@StephenLPeters
Copy link
Contributor

@MikeHillberg @codendone @Austin-Lamb do one of you know the proper route for this question? @vadimkantorov does your performance issue persist even when no debugger is attached to the process? What about release mode?

@vadimkantorov
Copy link
Author

vadimkantorov commented Jun 12, 2020

I haven't tried attaching debugger to WT. I can try using perf.exe / procmon / Event Tracing / some other tracing if you have some suggestions (I never used them before for perf investigations, I just know they exist).

I think the problem is somehow related to slow disk, and that something is getting loaded from relatively slow HDD. Maybe Windows still swap some pages even though I have 20% memory free as reported by Task Manager, maybe some shared libraries are getting loaded back into memory, maybe some configs are re-read from disk? Maybe some memory compression at fault? After I use these buttons once, they become much faster, so some caching effects are definitely in play.

Ideally it would be good to first get some wall-clock and system-clock timing logs for e.g. button click perceived by XAML and menu drawn/tab created. This should confirm the effect

I assume WT is built in release mode, it's 1.0rc2 version downloaded from Releases, I didn't compile it myself. I'll upgrade it to 1.0 release, just in case.

@vadimkantorov
Copy link
Author

vadimkantorov commented Jun 12, 2020

I've done a quick perfmon run on "fast" speed of just showing the New Tab menu, and I see a lot of language/i18n-related registry operations, some font loads and some pagefile reads. Probably Windows swaps things to disk even though WT has 7mb working set (reported by Task Manager).

A question is: why is there a pagefile read to just show a menu?

image

I'll do a similar run for on "slow" speed as well

Pagefile read details are:

Offset: 9,828,593,664, Length: 32,768, I/O Flags: Non-cached, Paging I/O, Synchronous Paging I/O, Priority: Normal

it's only a 32k read - probably a slow one, I wish it could be avoided

@vadimkantorov
Copy link
Author

I did two "slow" procmon traces and attach them in native procmon format inside the zip.

They confirm that the problem is loading from pagefile.sys. The question is: can you figure out what is it loading from pagefile.sys? It seems that it's just the app DLLs. Do you see some other things?

procmon_traces.zip

Process Explorer shows that WT uses a lot of dynamic shared libraries including a dozen XAML ones. Procexp shows that real WorkingSet is around 65Mb and PrivateBytes 250Mb (just one open tab inside Terminal).

Should we just ask WT to reduce WorkingSet and used shared libraries / fonts? Does XAML framework have some guidelines for apps to follow that want to minimize resource usage?

Process: WindowsTerminal.exe Pid: 992

Name	Description	Company Name	Path
{6AF0698E-D558-4F6E-9B3C-3716689AF493}.2.ver0x0000000000000002.db			C:\ProgramData\Microsoft\Windows\Caches\{6AF0698E-D558-4F6E-9B3C-3716689AF493}.2.ver0x0000000000000002.db
{AFBF9F1A-8EE8-4C77-AF34-C647E37CA0D9}.1.ver0x0000000000000005.db			C:\Users\user\AppData\Local\Microsoft\Windows\Caches\{AFBF9F1A-8EE8-4C77-AF34-C647E37CA0D9}.1.ver0x0000000000000005.db
{DDF571F2-BE98-426D-8288-1A9A39C3FDA2}.2.ver0x0000000000000002.db			C:\ProgramData\Microsoft\Windows\Caches\{DDF571F2-BE98-426D-8288-1A9A39C3FDA2}.2.ver0x0000000000000002.db
~FontCache-FontFace.dat			C:\Windows\ServiceProfiles\LocalService\AppData\Local\FontCache\~FontCache-FontFace.dat
~FontCache-S-1-5-21-111876015-96469450-1807641949-1001.dat			C:\Windows\ServiceProfiles\LocalService\AppData\Local\FontCache\~FontCache-S-1-5-21-111876015-96469450-1807641949-1001.dat
advapi32.dll	Advanced Windows 32 Base API	Microsoft Corporation	C:\Windows\System32\advapi32.dll
avrt.dll	Multimedia Realtime Runtime	Microsoft Corporation	C:\Windows\System32\avrt.dll
BCP47Langs.dll	BCP47 Language Classes	Microsoft Corporation	C:\Windows\System32\BCP47Langs.dll
BCP47mrm.dll	BCP47 Language Classes for Resource Management	Microsoft Corporation	C:\Windows\System32\BCP47mrm.dll
bcrypt.dll	Windows Cryptographic Primitives Library	Microsoft Corporation	C:\Windows\System32\bcrypt.dll
bcryptprimitives.dll	Windows Cryptographic Primitives Library	Microsoft Corporation	C:\Windows\System32\bcryptprimitives.dll
capauthz.dll	Capability Authorization APIs	Microsoft Corporation	C:\Windows\System32\capauthz.dll
CascadiaMono.ttf			C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_0.11.1333.0_x64__8wekyb3d8bbwe\CascadiaMono.ttf
cfgmgr32.dll	Configuration Manager DLL	Microsoft Corporation	C:\Windows\System32\cfgmgr32.dll
clbcatq.dll	COM+ Configuration Catalog	Microsoft Corporation	C:\Windows\System32\clbcatq.dll
cldapi.dll	Cloud API user mode API	Microsoft Corporation	C:\Windows\System32\cldapi.dll
combase.dll	Microsoft COM for Windows	Microsoft Corporation	C:\Windows\System32\combase.dll
comctl32.dll	User Experience Controls Library	Microsoft Corporation	C:\Windows\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.18362.836_none_e6c4b943130f18ed\comctl32.dll
coml2.dll	Microsoft COM for Windows	Microsoft Corporation	C:\Windows\System32\coml2.dll
concrt140.dll	Microsoft® Concurrency Runtime Library	Microsoft Corporation	C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_0.11.1333.0_x64__8wekyb3d8bbwe\concrt140.dll
concrt140_app.dll			C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_0.11.1333.0_x64__8wekyb3d8bbwe\concrt140_app.dll
container.dll	Windows Containers	Microsoft Corporation	C:\Windows\System32\container.dll
CoreMessaging.dll	Microsoft CoreMessaging Dll	Microsoft Corporation	C:\Windows\System32\CoreMessaging.dll
CoreUIComponents.dll	Microsoft Core UI Components Dll	Microsoft Corporation	C:\Windows\System32\CoreUIComponents.dll
cpprest142_2_10.dll			C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_0.11.1333.0_x64__8wekyb3d8bbwe\cpprest142_2_10.dll
crypt32.dll	Crypto API32	Microsoft Corporation	C:\Windows\System32\crypt32.dll
cryptbase.dll	Base cryptographic API DLL	Microsoft Corporation	C:\Windows\System32\cryptbase.dll
cryptsp.dll	Cryptographic Service Provider API	Microsoft Corporation	C:\Windows\System32\cryptsp.dll
cversions.2.db			C:\ProgramData\Microsoft\Windows\Caches\cversions.2.db
cversions.2.db			C:\ProgramData\Microsoft\Windows\Caches\cversions.2.db
d2d1.dll	Microsoft D2D Library	Microsoft Corporation	C:\Windows\System32\d2d1.dll
d3d11.dll	Direct3D 11 Runtime	Microsoft Corporation	C:\Windows\System32\d3d11.dll
D3DCompiler_47.dll	Direct3D HLSL Compiler	Microsoft Corporation	C:\Windows\System32\D3DCompiler_47.dll
DataExchange.dll	Data exchange	Microsoft Corporation	C:\Windows\System32\DataExchange.dll
daxexec.dll	daxexec	Microsoft Corporation	C:\Windows\System32\daxexec.dll
dcomp.dll	Microsoft DirectComposition Library	Microsoft Corporation	C:\Windows\System32\dcomp.dll
directmanipulation.dll	Microsoft Direct Manipulation Component	Microsoft Corporation	C:\Windows\System32\directmanipulation.dll
dpapi.dll	Data Protection API	Microsoft Corporation	C:\Windows\System32\dpapi.dll
dwmapi.dll	Microsoft Desktop Window Manager API	Microsoft Corporation	C:\Windows\System32\dwmapi.dll
DWrite.dll	Microsoft DirectX Typography Services	Microsoft Corporation	C:\Windows\System32\DWrite.dll
DXCore.dll	DXCore	Microsoft Corporation	C:\Windows\System32\DXCore.dll
dxgi.dll	DirectX Graphics Infrastructure	Microsoft Corporation	C:\Windows\System32\dxgi.dll
edputil.dll	EDP util	Microsoft Corporation	C:\Windows\System32\edputil.dll
fltLib.dll	Filter Library	Microsoft Corporation	C:\Windows\System32\fltLib.dll
FontCache-Obsolete-828.dat			C:\Windows\ServiceProfiles\LocalService\AppData\Local\FontCache\FontCache-Obsolete-828.dat
gdi32.dll	GDI Client DLL	Microsoft Corporation	C:\Windows\System32\gdi32.dll
gdi32full.dll	GDI Client DLL	Microsoft Corporation	C:\Windows\System32\gdi32full.dll
iertutil.dll	Run time utility for Internet Explorer	Microsoft Corporation	C:\Windows\System32\iertutil.dll
igc64.dll	Intel Graphics Shader Compiler for Intel(R) Graphics Accelerator	Intel Corporation	C:\Windows\System32\DriverStore\FileRepository\igdlh64.inf_amd64_77aa8b07b10eaefc\igc64.dll
igd10iumd64.dll	User Mode Driver for Intel(R) Graphics Technology	Intel Corporation	C:\Windows\System32\DriverStore\FileRepository\igdlh64.inf_amd64_77aa8b07b10eaefc\igd10iumd64.dll
imm32.dll	Multi-User Windows IMM32 API Client DLL	Microsoft Corporation	C:\Windows\System32\imm32.dll
InputHost.dll	InputHost	Microsoft Corporation	C:\Windows\System32\InputHost.dll
IPHLPAPI.DLL	IP Helper API	Microsoft Corporation	C:\Windows\System32\IPHLPAPI.DLL
kernel.appcore.dll	AppModel API Host	Microsoft Corporation	C:\Windows\System32\kernel.appcore.dll
kernel32.dll	Windows NT BASE API Client DLL	Microsoft Corporation	C:\Windows\System32\kernel32.dll
KernelBase.dll	Windows NT BASE API Client DLL	Microsoft Corporation	C:\Windows\System32\KernelBase.dll
KernelBase.dll.mui	Windows NT BASE API Client DLL	Microsoft Corporation	C:\Program Files\WindowsApps\Microsoft.LanguageExperiencePacken-US_18362.14.15.0_neutral__8wekyb3d8bbwe\Windows\System32\en-US\KernelBase.dll.mui
locale.nls			C:\Windows\System32\locale.nls
Microsoft.Toolkit.Win32.UI.XamlHost.dll			C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_0.11.1333.0_x64__8wekyb3d8bbwe\Microsoft.Toolkit.Win32.UI.XamlHost.dll
Microsoft.UI.Xaml.dll	Microsoft.UI.Xaml.dll	Microsoft Corporation	C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_0.11.1333.0_x64__8wekyb3d8bbwe\Microsoft.UI.Xaml.dll
mlang.dll	Multi Language Support DLL	Microsoft Corporation	C:\Windows\System32\mlang.dll
mpr.dll	Multiple Provider Router DLL	Microsoft Corporation	C:\Windows\System32\mpr.dll
MrmCoreR.dll	Microsoft Windows MRM	Microsoft Corporation	C:\Windows\System32\MrmCoreR.dll
msasn1.dll	ASN.1 Runtime APIs	Microsoft Corporation	C:\Windows\System32\msasn1.dll
msctf.dll	MSCTF Server DLL	Microsoft Corporation	C:\Windows\System32\msctf.dll
msvcp_win.dll	Microsoft® C Runtime Library	Microsoft Corporation	C:\Windows\System32\msvcp_win.dll
msvcp110_win.dll	Microsoft® STL110 C++ Runtime Library	Microsoft Corporation	C:\Windows\System32\msvcp110_win.dll
msvcp140.dll	Microsoft® C Runtime Library	Microsoft Corporation	C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_0.11.1333.0_x64__8wekyb3d8bbwe\msvcp140.dll
msvcp140_app.dll			C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_0.11.1333.0_x64__8wekyb3d8bbwe\msvcp140_app.dll
msvcrt.dll	Windows NT CRT DLL	Microsoft Corporation	C:\Windows\System32\msvcrt.dll
ncrypt.dll	Windows NCrypt Router	Microsoft Corporation	C:\Windows\System32\ncrypt.dll
ninput.dll	Microsoft Pen and Touch Input Component	Microsoft Corporation	C:\Windows\System32\ninput.dll
NoiseAsset_256X256_PNG.png			C:\Program Files\WindowsApps\Microsoft.WindowsStore_12005.1001.1.0_x64__8wekyb3d8bbwe\Microsoft.UI.Xaml\Assets\NoiseAsset_256X256_PNG.png
ntasn1.dll	Microsoft ASN.1 API	Microsoft Corporation	C:\Windows\System32\ntasn1.dll
ntdll.dll	NT Layer DLL	Microsoft Corporation	C:\Windows\System32\ntdll.dll
ntmarta.dll	Windows NT MARTA provider	Microsoft Corporation	C:\Windows\System32\ntmarta.dll
ole32.dll	Microsoft OLE for Windows	Microsoft Corporation	C:\Windows\System32\ole32.dll
oleaut32.dll	OLEAUT32.DLL	Microsoft Corporation	C:\Windows\System32\oleaut32.dll
OneCoreUAPCommonProxyStub.dll	OneCoreUAP Common Proxy Stub	Microsoft Corporation	C:\Windows\System32\OneCoreUAPCommonProxyStub.dll
pcacli.dll	Program Compatibility Assistant Client Module	Microsoft Corporation	C:\Windows\System32\pcacli.dll
pdh.dll	Windows Performance Data Helper DLL	Microsoft Corporation	C:\Windows\System32\pdh.dll
policymanager.dll	Policy Manager DLL	Microsoft Corporation	C:\Windows\System32\policymanager.dll
powrprof.dll	Power Profile Helper DLL	Microsoft Corporation	C:\Windows\System32\powrprof.dll
profapi.dll	User Profile Basic API	Microsoft Corporation	C:\Windows\System32\profapi.dll
profext.dll	profext	Microsoft Corporation	C:\Windows\System32\profext.dll
propsys.dll	Microsoft Property System	Microsoft Corporation	C:\Windows\System32\propsys.dll
resources.pri			C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_0.11.1333.0_x64__8wekyb3d8bbwe\resources.pri
rmclient.dll	Resource Manager Client	Microsoft Corporation	C:\Windows\System32\rmclient.dll
rometadata.dll	Microsoft MetaData Library	Microsoft Corporation	C:\Windows\System32\rometadata.dll
rpcrt4.dll	Remote Procedure Call Runtime	Microsoft Corporation	C:\Windows\System32\rpcrt4.dll
sechost.dll	Host for SCM/SDDL/LSA Lookup APIs	Microsoft Corporation	C:\Windows\System32\sechost.dll
secur32.dll	Security Support Provider Interface	Microsoft Corporation	C:\Windows\System32\secur32.dll
segoeui.ttf			C:\Windows\Fonts\segoeui.ttf
segoeuib.ttf			C:\Windows\Fonts\segoeuib.ttf
setupapi.dll	Windows Setup API	Microsoft Corporation	C:\Windows\System32\setupapi.dll
sfc_os.dll	Windows File Protection	Microsoft Corporation	C:\Windows\System32\sfc_os.dll
SHCore.dll	SHCORE	Microsoft Corporation	C:\Windows\System32\SHCore.dll
shell32.dll	Windows Shell Common Dll	Microsoft Corporation	C:\Windows\System32\shell32.dll
shlwapi.dll	Shell Light-weight Utility Library	Microsoft Corporation	C:\Windows\System32\shlwapi.dll
SortDefault.nls			C:\Windows\Globalization\Sorting\SortDefault.nls
sspicli.dll	Security Support Provider Interface	Microsoft Corporation	C:\Windows\System32\sspicli.dll
StaticCache.dat			C:\Windows\Fonts\StaticCache.dat
sxs.dll	Fusion 2.5	Microsoft Corporation	C:\Windows\System32\sxs.dll
telnetpp.dll			C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_0.11.1333.0_x64__8wekyb3d8bbwe\telnetpp.dll
TerminalApp.dll			C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_0.11.1333.0_x64__8wekyb3d8bbwe\TerminalApp.dll
TerminalConnection.dll			C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_0.11.1333.0_x64__8wekyb3d8bbwe\TerminalConnection.dll
TerminalControl.dll			C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_0.11.1333.0_x64__8wekyb3d8bbwe\TerminalControl.dll
TerminalSettings.dll			C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_0.11.1333.0_x64__8wekyb3d8bbwe\TerminalSettings.dll
TerminalThemeHelpers.dll			C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_0.11.1333.0_x64__8wekyb3d8bbwe\TerminalThemeHelpers.dll
TextInputFramework.dll	"TextInputFramework.DYNLINK"	Microsoft Corporation	C:\Windows\System32\TextInputFramework.dll
threadpoolwinrt.dll	Windows WinRT Threadpool	Microsoft Corporation	C:\Windows\System32\threadpoolwinrt.dll
twinapi.appcore.dll	twinapi.appcore	Microsoft Corporation	C:\Windows\System32\twinapi.appcore.dll
twinapi.dll	twinapi	Microsoft Corporation	C:\Windows\System32\twinapi.dll
twinui.appcore.dll	TWINUI.APPCORE	Microsoft Corporation	C:\Windows\System32\twinui.appcore.dll
twinui.dll	TWINUI	Microsoft Corporation	C:\Windows\System32\twinui.dll
ucrtbase.dll	Microsoft® C Runtime Library	Microsoft Corporation	C:\Windows\System32\ucrtbase.dll
UiaManager.dll	UiaManager	Microsoft Corporation	C:\Windows\System32\UiaManager.dll
UIAutomationCore.dll	Microsoft UI Automation Core	Microsoft Corporation	C:\Windows\System32\UIAutomationCore.dll
umpdc.dll			C:\Windows\System32\umpdc.dll
urlmon.dll	OLE32 Extensions for Win32	Microsoft Corporation	C:\Windows\System32\urlmon.dll
user32.dll	Multi-User Windows USER API Client DLL	Microsoft Corporation	C:\Windows\System32\user32.dll
userenv.dll	Userenv	Microsoft Corporation	C:\Windows\System32\userenv.dll
uxtheme.dll	Microsoft UxTheme Library	Microsoft Corporation	C:\Windows\System32\uxtheme.dll
vccorlib140.dll	Microsoft ® VC WinRT core library	Microsoft Corporation	C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_0.11.1333.0_x64__8wekyb3d8bbwe\vccorlib140.dll
vccorlib140_app.dll			C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_0.11.1333.0_x64__8wekyb3d8bbwe\vccorlib140_app.dll
vcruntime140.dll	Microsoft® C Runtime Library	Microsoft Corporation	C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_0.11.1333.0_x64__8wekyb3d8bbwe\vcruntime140.dll
vcruntime140_1.dll	Microsoft® C Runtime Library	Microsoft Corporation	C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_0.11.1333.0_x64__8wekyb3d8bbwe\vcruntime140_1.dll
vcruntime140_1_app.dll			C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_0.11.1333.0_x64__8wekyb3d8bbwe\vcruntime140_1_app.dll
vcruntime140_app.dll			C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_0.11.1333.0_x64__8wekyb3d8bbwe\vcruntime140_app.dll
win32u.dll	Win32u	Microsoft Corporation	C:\Windows\System32\win32u.dll
windows.applicationmodel.datatransfer.dll	Windows.ApplicationModel.DataTransfer	Microsoft Corporation	C:\Windows\System32\windows.applicationmodel.datatransfer.dll
Windows.ApplicationModel.dll	Windows ApplicationModel API Server	Microsoft Corporation	C:\Windows\System32\Windows.ApplicationModel.dll
Windows.Energy.dll	Windows Energy Runtime DLL	Microsoft Corporation	C:\Windows\System32\Windows.Energy.dll
Windows.Globalization.dll	Windows Globalization	Microsoft Corporation	C:\Windows\System32\Windows.Globalization.dll
Windows.Graphics.dll	WinRT Windows Graphics DLL	Microsoft Corporation	C:\Windows\System32\Windows.Graphics.dll
Windows.StateRepositoryCore.dll	Windows StateRepository API Core	Microsoft Corporation	C:\Windows\System32\Windows.StateRepositoryCore.dll
windows.storage.dll	Microsoft WinRT Storage API	Microsoft Corporation	C:\Windows\System32\windows.storage.dll
windows.storage.dll.mui	Microsoft WinRT Storage API	Microsoft Corporation	C:\Program Files\WindowsApps\Microsoft.LanguageExperiencePacken-US_18362.14.15.0_neutral__8wekyb3d8bbwe\Windows\System32\en-US\windows.storage.dll.mui
Windows.System.Launcher.dll	Windows.System.Launcher	Microsoft Corporation	C:\Windows\System32\Windows.System.Launcher.dll
Windows.UI.Core.TextInput.dll	Windows.UI.Core.TextInput dll	Microsoft Corporation	C:\Windows\System32\Windows.UI.Core.TextInput.dll
Windows.UI.dll	Windows Runtime UI Foundation DLL	Microsoft Corporation	C:\Windows\System32\Windows.UI.dll
Windows.UI.dll.mui	Windows Runtime UI Foundation DLL	Microsoft Corporation	C:\Program Files\WindowsApps\Microsoft.LanguageExperiencePacken-US_18362.14.15.0_neutral__8wekyb3d8bbwe\Windows\System32\en-US\Windows.UI.dll.mui
Windows.UI.Immersive.dll	WINDOWS.UI.IMMERSIVE	Microsoft Corporation	C:\Windows\System32\Windows.UI.Immersive.dll
Windows.UI.winmd	Windows SDK metadata	Microsoft Corporation	C:\Windows\System32\WinMetadata\Windows.UI.winmd
Windows.UI.Xaml.Controls.dll	Windows.UI.Xaml.Controls	Microsoft Corporation	C:\Windows\System32\Windows.UI.Xaml.Controls.dll
Windows.UI.Xaml.Controls.dll	Windows.UI.Xaml.Controls	Microsoft Corporation	C:\Windows\System32\Windows.UI.Xaml.Controls.dll
Windows.UI.Xaml.dll	Windows.UI.Xaml dll	Microsoft Corporation	C:\Windows\System32\Windows.UI.Xaml.dll
windows.ui.xaml.dll.mui	Windows.UI.Xaml dll	Microsoft Corporation	C:\Program Files\WindowsApps\Microsoft.LanguageExperiencePacken-US_18362.14.15.0_neutral__8wekyb3d8bbwe\Windows\System32\en-US\windows.ui.xaml.dll.mui
Windows.UI.Xaml.InkControls.dll	Windows UI XAML InkControls API	Microsoft Corporation	C:\Windows\System32\Windows.UI.Xaml.InkControls.dll
Windows.UI.Xaml.Maps.dll	Windows UI XAML Maps API	Microsoft Corporation	C:\Windows\System32\Windows.UI.Xaml.Maps.dll
Windows.UI.Xaml.Phone.dll	Windows UI XAML Phone API	Microsoft Corporation	C:\Windows\System32\Windows.UI.Xaml.Phone.dll
Windows.UI.Xaml.Resources.19h1.dll	Windows.UI.Xaml.Resources.19H1 dll	Microsoft Corporation	C:\Windows\System32\Windows.UI.Xaml.Resources.19h1.dll
Windows.UI.Xaml.Resources.Common.dll	Windows.UI.Xaml.Resources.Common.dll	Microsoft Corporation	C:\Windows\System32\Windows.UI.Xaml.Resources.Common.dll
Windows.UI.Xaml.winmd	Windows SDK metadata	Microsoft Corporation	C:\Windows\System32\WinMetadata\Windows.UI.Xaml.winmd
WindowsCodecs.dll	Microsoft Windows Codecs Library	Microsoft Corporation	C:\Windows\System32\WindowsCodecs.dll
WindowsTerminal.exe			C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_0.11.1333.0_x64__8wekyb3d8bbwe\WindowsTerminal.exe
wininet.dll	Internet Extensions for Win32	Microsoft Corporation	C:\Windows\System32\wininet.dll
wintrust.dll	Microsoft Trust Verification APIs	Microsoft Corporation	C:\Windows\System32\wintrust.dll
WinTypes.dll	Windows Base Types DLL	Microsoft Corporation	C:\Windows\System32\WinTypes.dll
wuceffects.dll	Microsoft Composition Effects	Microsoft Corporation	C:\Windows\System32\wuceffects.dll

@weltkante
Copy link

weltkante commented Jun 14, 2020

My system has about 80% of used physical memory

Its usually bad to let used physical memory get such high because it leaves too little room for file caching. That means Windows has more often to take the significantly slower path to the disk instead of reading from caches. Depending on what you do you want a few GB of unused memory for file caching.

A question is: why is there a pagefile read to just show a menu?

Windows backs (almost) everyhing by the pagefile, this is necessary because it is overcommitting memory, allowing you to run more applications than you actually have memory for, knowing that most application will not be using all the memory they reserved.

It is normal that with high physical memory load Windows will swap out currently unused memory and swap it back in when its used again. This means with higher memory load you get more disk access and generally things become slower, long before you actually hit "out of memory" errors.

Try the RamMap tool from sysinternals and "Empty Working Sets" - it forces to flush out memory from currently unused applications when Windows isn't doing its job good enough, leaving more space for file caches etc. It helps a lot for my 8 GB notebook, without manually flushing from time to time my notebook starts swapping (and slowing down) like crazy.

If that helps you are just observing your machine approaching the out of memory barrier, and Windows trying to keep the system responsive by doing more swapping, which ironically reduces responsiveness. I think the OS heuristics for the pagefile have been tuned for more modern machines, thats probably why the slowdown on older ones with less RAM are so exaggerated.

PS: just commenting based on research I did on my own notebook slowdowns, may or may not be related to yours

@vadimkantorov
Copy link
Author

@weltkante RAMMap "Empty *" seems to have helped considerably

@weltkante
Copy link

weltkante commented Jun 15, 2020

Then its probably an OS level issue and its unlikely WinUI by itself can do much about it, not sure what the appropriate way is to handle this, lets wait for a response from the team.

I fully agree that the OS should handle older hardware with limited RAM better, you shouldn't have to do a manually forced flush to get a responsive system.

@vadimkantorov
Copy link
Author

@welkante I wonder if XAML controls could benefit from IL linker / symbol trimming in general

@vadimkantorov
Copy link
Author

@StephenLPeters I think a summary for my asks of WinRT / XAML / WinUI side would be:

  1. easy tracing ways to measure responsiveness of UI

  2. advice on measuring perf, including measuring working set, inducing Windows to low-memory mode (probably easily done with a VM, but maybe other simpler ways exist), counting page faults, waiting on accessing memory because of memory compression, not getting CPU time because of low-pri / being blocked on UI thread waiting for sth, et cetera

  3. advice for apps on how to reduce working set. is there some linker that can strip unused controls from the dll? why is xaml.maps / xaml.phone getting loaded in Terminal that has nothing to do with them?

Terminal by itself is not very keen on doing these investigations, reason being roughly "we are not doing anything special, so it perf should be fixed upstream so that everyone benefits" (speaking from my original issue in the repo)

@StephenLPeters
Copy link
Contributor

I think @Austin-Lamb @MikeHillberg or @codendone would have more context or be able to point to someone who does. Could one of you weigh in here?

@ranjeshj
Copy link
Contributor

@bartekk8 as FYI

@bartekk8
Copy link
Contributor

bartekk8 commented Jul 2, 2020

Hello,

Let's start with getting a trace of your sceanrio. To trace XAML app, follow these steps:

  1. Install ADK (https://docs.microsoft.com/en-us/windows-hardware/get-started/adk-install). You only need Windows Performance Toolkit option to be selected.
  2. Execute wprui.exe (Windows Performance Recorder).
  3. The default profile options should provide enough information about what's going on in the system / app. Click on Start.
  4. Run your scenario.
  5. Click Save and follow the prompts. If you'd like to look at the trace right away, after it's saved click on Open in WPA.
  6. WPA is a great tool for analyzing traces. For intro on how to use it take a look here: https://docs.microsoft.com/en-us/windows-hardware/test/wpt/windows-performance-analyzer

I hope this helps!

@vadimkantorov
Copy link
Author

vadimkantorov commented Jul 2, 2020

I kind of confirmed it’s low memory / swapping that is the problem. And I could see in the procmon taking time to load libraries from disk. When I have more memory available, Terminal works faster.

Speaking more generally, it would be great if these tools could be easily installed from Store or shipped with windows. Having perf kit shipped only with adk seems s big stumbling part.

Ideally, there would be some library that a client app like Terminal could use to do some trace of perf, and e.g. use it in Telemetry or in issue reports.

Questions about libraries and reducing working set / linker still hold.

Also maybe this issue should be moved to https://github.com/microsoft/ProjectReunion, please feel free to move it if it better fits there :)

@StephenLPeters StephenLPeters removed the needs-triage Issue needs to be triaged by the area owners label Jul 2, 2020
@vadimkantorov
Copy link
Author

One example that would also benefit from super-easy perf recording (by non windev-experienced end users) is slow Calculator start-up microsoft/calculator#209

@trgibeau
Copy link

trgibeau commented Jul 14, 2020

Hi @vadimkantorov,

For your comment:

Speaking more generally, it would be great if these tools could be easily installed from Store or shipped with windows. Having perf kit shipped only with adk seems s big stumbling part.

If your running Windows 10;

Hopefully these can get you started without the ADK.

@vadimkantorov
Copy link
Author

vadimkantorov commented Jul 14, 2020

Thanks for advice about WPA. I'll try it next time! Unfortunately, these are "advanced" tools enough so that Microsoft Terminal devs sent me to this repo and suggested asking a question as an issue here. Maybe they are not accustomed to using these tools either :( They didn't communicate to me any prior attempts to measure Working Set memory or number of used shared libraries or testing the app in low-memory conditions and continued to refer that I should investigate this myself (with your help) in this repo :(

The general questions about "why Terminal (that uses winrt/winui?)" uses so many assemblies and if it can make use of some linker to strip unused controls holds.

@zadjii-msft
Copy link
Member

For the record, the Terminal team is plenty accustomed to using those tools, we've just focused our efforts primarily on CPU performance, because the memory impact of the actual terminal bits of the Terminal is pretty minimal. We've kicked this thread over to the WinUI repo because the people who are best equipped to analyze the memory impact of WinUI are the people who own WinUI.

@vadimkantorov
Copy link
Author

vadimkantorov commented Jul 15, 2020

On my side, I'll incur my machine in low-memory mode and will provide you a wprp file.

About tools / WinUI: even a simple procmon run sufficed to find low-memory / swapping problems. And procexp.exe showed the problem of a lot of (seemingly unrelated) shared libraries. If you had adviced directly to download WPA (also completely generic, not WinUI-specific) from windows store and how to configure it to run on Terminal, I would have tried to use it from the get-go.

@zadjii-msft Sorry for a lot of mis-communication.

@vadimkantorov
Copy link
Author

Maybe this issue now would be better transferred to https://github.com/microsoft/windev (as per too many libraries used by winrt and for optimizing down the working set of winrt/winui apps including Terminal)

@zadjii-msft
Copy link
Member

IMO It would probably just get punted back to the experts over here, or to Kenny over in microsoft/xlang / microsoft/cppwinrt, but I doubt the language itself is at fault here - I'd imagine that those libraries are getting regardless if XAML is being used via c++/winrt, c#, rust, cxx, or whatever other language the xlang team adds WinRT support to next.

@github-actions
Copy link

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Aug 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants