WPF performance and .NET Framework Client Profile related blogs provided by Jossef Goldberg.
David Bronman just posted a new version of the CLR Profiler that now also supports .NET Framework 4 as well as Silverlight 4. Key Features:
See more details here.
In the Memory Leak Hotfixes for WPF 3.5 SP1 blog post I mentioned that the memory leak fixes that went into KB981107 were only available for WPF 3.5 SP1. I am now happy to announce that these memory leak fixes are also available for WPF 4.
You can get the fixes for WPF 4 from here: http://support.microsoft.com/kb/2297328 Enjoy. Jossef
Wanted folks know that we have started a new Blog that is dedicated to Silverlight performance. We have uploaded two posts:
We plan to add additional posts in the near future, so please stay tune.
In the WPFPerf Performance Profiling Tools for WPF 4 is now available! post, I mentioned that a bug caused the Visual Profiler to not display any data in certain time zones. A patch is now available to fix this issue. To install the patch:
As you know by default WPF uses Hardware acceleration (GPU) to render its content (aka Hardware rendering). In most cases rendering using Hardware (HW) acceleration is much more performant than rendering using Software. In some small cases SW rendering may be faster (E.g. low end graphics card sometimes found in Netbooks).
WPF will always attempt to use HW rendering, but in certain cases WPF will fall to Software rendering and the application may not be aware of it.Some folks wanted to better understand all the possible cases, so am I am listed these below.WPF will render in Software when:
Which tools can I use to detect if my app renders in Software?The easiest way is to use Perforator which is included with the WPF Performance Profiling Tools and check below check boxes. Read more here.
Option
Description
Draw software rendering with purple tint
Draws all areas rendered by using the software rendering pipeline with a purple tint. This includes software render targets, software 3D content, and per-primitive software fallback.
Draw software rendered bitmap effects with red tint
Draws legacy software rendered bitmap effects with red tint.
How can I detect if my app renders in Software in code?Check the RenderingCapability.Tier . You can also listen on the Tier change event.
Hopefully folks saw my related blog post Finding Memory Leaks in WPF-based applications .In this post below I wanted folks to be aware that we released few other KB Articles (Hotfix) that address other various memory leaks reported in .NET 3.5 SP1. Some of these fixes made it to .NET 4.
1. KB981107 (See: http://support.microsoft.com/kb/981107)
This Hotfix fixes the following memory leaks in .NET 3.5 SP1 WPF-based applications.Issue 1:This affects an app that contains styles or templates that refer to application resources (via StaticResource or DynamicResource), and that creates a large number of elements that use these styles or templates but never need the actual value of the resource. In this situation, the app can leak DeferredAppResourceReference objects, even after the elements themselves have been reclaimed. (In addition, the app can leak WeakReferences and array space, similar to the issues described below.)
An example: App resources define <sys:Double x:Key="{x:Static SystemParameters.HorizontalScrollBarHeightKey}">20</sys:Double> This creates a resource that's used by any control that can display a horizontal scrollbar. Creating a large number of such controls that never actually display their scrollbar will encounter the leak.
Issue 2:This affects an app that creates a large number of short-lived elements with properties that are data-bound to a DependencyProperty of longer-lived elements. In this situation, the longer-lived elements maintain lists of WeakReference objects, used to notify the short-lived elements about property changes. The app can leak WeakReference objects and the array space to hold them, even after the short-lived elements have been reclaimed.
An example: ListBoxItem binds its HorizontalContentAlignment property to a similar property on its governing ListBox. An app that creates a large number of ListBoxItems (say by doing a large number of additions and deletions to the ListBox's ItemsSource) will encounter the leak.
Issue 3:This issue affects classes derived from TreeView or Selector (including ListBox, ListView, Menu, DataGrid, and many others). These classes register for an internal notification from the KeyboardNavigation class, used for controlling keyboard focus. An app that creates a large number of these elements can leak WeakReference objects and the array space to hold them, even after the elements themselves have been reclaimed. An example: An app that creates a large number of short-lived ListBoxes will encounter the leak. This can happen in a nested scenario, where an outer ListBox displays a collection that undergoes a large number of additions and deletions, and where each item is displayed using an inner ListBox.
These fixes are not included in NET4. We are considering this Hotfix also for NET4, but this decision has not been made, so stay tune.
2. KB967634: (See: http://support.microsoft.com/kb/967634 )
This fixes a memory leaks in .NET 3.5 SP1 WPF-based applications when using software 3D rendering involving a VisualBrush or DrawingBrush.This fix is already included in .NET 4.
3. KB967328 (See: http://support.microsoft.com/Default.aspx?kbid=967328)
This Hotfix fixes memory leaks when a deferred resource isn't inflated due to the resource reference expression hooking up to the Inflated event on the resource dictionary entry.If the resource dictionary is an application or theme dictionary, then these are essentially global and can cause these expressions to stay alive.There are some discussions on this issue here.This fix is already included in .NET 4.
As you may know, when you interoperate WPF with other technologies you can't overlay WPF and WinForms/Win32 content because of the "airspace" limitations (read more here).Any given pixel in a window is either owned by WPF or WinForms/Win32, not both. On the other hand, you can overlay all the WPF content you want because WPF manages and renders all of them.
Many folks however are looking to overlay WPF content over Web content. Chris Cavanagh posted sometimes ago a blog that explain how you can do so using Google's web control.Sources for a sample are available on Codeplex. You would need to license the wrapper called Awesomium.
Not sure if folks are aware, but Visual Studio 2010 now includes WPF Visualizer. This can really help you during debugging.It basically allows you to explore and visualize the Visual Tree and properties of a WPF object during a debug sessions. Similar to what Mole was doing, but this is now built-in to Visual Studio 2010.
To use: During debug, in a DataTip, Watch window, Autos window, or Locals window, next to a WPF object name, click the arrow adjacent to the magnifying glass icon. See images below for the SDK example I used:
Not sure if folks aware that Snoop for WPF 4.0 has been available for a while. You can download it from here.
This version includes other impressive list of improvements that you can read about here. Thanks to Corry Plotts and others (Dan Hanan, Mark Kharitonov, etc) who improved on Pete Blois’ original Snoop.
The WPFPerf tool comprises of a suite of performance profiling tools that allow you to analyze the run-time behavior of your WPF application and point to potential performance bottlenecks. We finally release the version that also supports .NET Framework 4 (WPF 4).
This version of the tool (WPFPerf 4) will allow you to profile both WPF 3.5 SP1 and WPF 4 based applications. The WPFPerf 4 tool is included with the Windows SDK for Windows 7 and .NET Framework 4 (Windows SDK 7.1). So you are welcome to download and send us your feedback.
By the way, the tool itself will run on machines with only .NET 3.5 SP1 or only .NET 4, if both are present it will use .NET 3.5 SP1. Also, I am not sure how many people had a chance to look at the documentation that is installed with the tool , but we think it is very useful so don't forget to check it out.
Update (6/14/2010): We heard that few folks complain that the Visual Profiler cannot correctly attach to the WPF application in the new WPFPerf for WPF 4. After some research we think this has to do with a bug in our DateTime initialization which cause anyone in a time zone > GMT to not get any data in VisualProfiler (for a few hours at least). Until we post a fix, a temporary workaround is to set your time zone > GMT (e.g.to Eastern or Pacific Standard Time Zones) when you first attach VisualProfiler.
Please try this workaround and let us know.
Update (8/24/2010): A patch to that fixes the bug in Visual Profiler for certain time zones is now available. See here.
Hopefully folks saw my first “WPF 3.5 SP1 Performance on Tablet & Touch-enabled machines” blog.
In that blog I have mentioned that depending on the WPF application and scenario you may see significant performance issues and general sluggishness on Tablet & Touch-enabled machines and even on none-touch machines when UI Automation client apps are running (such as UI Spy, Narrator, Magnifier, etc).
This was especially noticeable during scrolling if the application comprise of many visual elements.
As I mentioned we have already fixed this issue in .NET 4.
I am now happy to announce that we just posted a Hotfix for .NET 3.5 SP1 that you can download from MSDN Code Galley site here and the Connect site here.
Enjoy. Jossef.
In .NET Framework 4 we have introduced a streamlined subset and more compact version of the .NET Framework called the Microsoft .NET Framework 4 Client Profile (aka NET4 Client Profile). The Microsoft .NET Framework 4 which is the Full Framework (aka NET4 Full) still exists and it is a superset of the Client Profile. Hopefully folks have seen Soma’s blog announcing the availability of Visual Studio 2010 , .NET Framework 4 and .NET Framework 4 Client Profile. I have discussed some of the beta features of Microsoft .NET Framework 4 Client Profile in details in my previous Beta 1 blog and Beta 2 blog posts. In this post I wanted to highlight some of the key changes from our previous Beta 2 public release and reiterate some of the important features
What are the reasons for a Client Profile? Although the NET4 Client Profile is smaller and faster to install compared to the NET4 Full Framework (NET4 is 7-8MB smaller in size than the Full Framework), the main reasons are not just better deployment size/time but also:
When to use NET4 Client Profile and when to use NET4 Full Framework? NET4 Client Profile: Always target NET4 Client Profile for all your client desktop applications (including Windows Forms and WPF apps).
NET4 Full framework: Target NET4 Full only if the features or assemblies that your app need are not included in the Client Profile. This includes:
How big is Client Profile? Below are the redistributable download size improvements since NET 3.5 SP1. As you can see we have made significant improvements. Note that if you are downloading from the Web, the actual download size could be smaller since some components may already be on your machine (for example, Software Rasterizer (rgb9rast) , etc )
3.5 SP1
4.0 RTM
32 bit Client Profile
Online: 28 MB Offline: 255MB
28.8 MB
32 + 64 bit Client Profile
N/A
41 MB
32 bit Full
35.3 MB
32 + 64 bit Full
48.1 MB
32 + ia64 bit Full
51.7 MB
32 + 64 + ia64 bit Full
231 MB
What is new in NET4 Client Profile RTM vs. Beta 2 ?
Since Beta 2 we made some small but important improvements to the he VS 2010 RTM UI: (You can read about the changes we in Beta2 in my Beta 2 blog ) A) Starting with VS 2010 RTM, the “Add Reference” indicates the target framework that assemblies are filtered against. B) The VS 2010 RTM toolbox now clearly indicates if 3rd party controls are not available for the selected profile.
Visual Studio 2008 introduced multi-targeting to allow application to target 2.0 and 3.x versions of the .NET Framework. VS 2010 has improved multi-targeting and starting in VS 2010 Beta2 many of the Client projects are targeting the NET4 Client Profile by default. I also discussed this in my Beta 2 blog .
These projects starting with VS 20101 Beta2 target the NET4 Client Profile by default: Windows Project (C# and VB) - WPF Application - WPF Browser Application - WPF Custom Control Library - WPF User Control Library - Windows Forms Application - Windows Forms Control Library - Console Application - Empty Project - Window Service
Visual F# - F# Application - F# Tutorial
Workflow (C# & VB) - Activity Designer Library - Activity Library - Workflow Console Application
WCF (C# & VB) - WCF Service Library
Office 2007 & 2010 templates (C# & VB) - All Projects
All other projects, including Class Library, target the Full Framework by default. Mixed-target scenarios using Class Library may present interesting challenges. Read more below.
To change targeting of your project, open the project properties, select the "Application" page, and change the “Target framework” drop-down. C# project example:
VB project example (Project Properties > Compile tab > “Advanced Compile Options…”):
Note that if you right-click the project and select “Add References”, the dialog shows only the .NET Framework assemblies that are part of the selected profile. This is accomplished by using reference assemblies (metadata-only versions of assemblies). The .NET Framework 4 Client Profile Reference Assemblies are located in: %programfiles%\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client
At compile time, the reference assemblies are matched up against the known "Client List" assemblies that are included in the Client Profile. If a project targeting the Client Profile has a reference to a .NET assembly that is not included in the "Client List", Visual Studio displays compile-time errors in the Error List.
Some other VS 2010 projects such as Managed C++ (C++/CLI) still target the Full Framework by default. VS 2010 unfortunately does not provide UI to change the targeting. Fortunately, you can still edit the project file manually in order to change the profile targeting. To do so: a) Right click “Unload Project” b) Right-Click “Edit <project_name>” c) Set the appropriate project property to target Client Profile. e.g.
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <TargetFrameworkProfile>Client</TargetFrameworkProfile>
d) Right click “Reload Project”
In addition, for these projects, notice that VS does not create an <app.config> file for your project. Note: If your project does not add references or access assemblies that are included in the Full Framework but are not part of the Client Profile, there is nothing to worry about. Your app will run on machines with either NET4 Client Profile or Full Framework just fine. Otherwise, if you do access assemblies from the Full Framework, you should add <app.config> to indicate to CLR not to load your app if it is launched on the NET4 Client Profile. E.g. add this:
<?xml version="1.0"?> <configuration> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/> </startup> </configuration>
If you don’t do so, your app may crash at random when it needs to load the assemblies that are missing from the Client Profile.
The project Publish property page allows you to select the prerequisite needed for your ClickOnce deployment. VS 2010 automatically selects the correct profile (Client Profile or Full) depending on your primary project target.
The same prerequisite dialog from above appears when you create “Setup and Deployment” project (under “Add New Project”/“Other Project Types”). The NET4 Client Profile prerequisite entry is checked by default in this case.
If you create a new “Visual Studio Installer” setup project (under “Setup and Deployment“) and add the output of your NET4 Client Profile to it (Right-Click ->“Add”-> “Project Output…”’ select “Primary output”) , VS2010 adds a new “Launch Condition”. (Right-click on your new Setup project and then do “View->Launch Conditions”)
By default VS2010 will add NET4 Client Profile as a launch condition.
What this means is that once all prerequisites are installed and before the main installation launches, setup checks whether all the launch conditions are met. If not, setup blocks and displays an error message.
Testing NET4 Client Profile applications VS 2010 itself requires the NET 4 Full in order to run and it therefore install NET 4 Full. If your target NET4 Client Profile, it is highly recommended that you test your application on a separate machine that only includes NET4 Client Profile.
Common Questions & Issues with NET4 Client Profile 1. How can I select the .NET Profile in the “New Project” dialog? When you create new project in VS 2010, the “New Project” dialog does not indicate if the new project you are about to create is targeting Client Profile or Full. You can always go to the project Properties (see above) and change the target if you like.
2. I cannot find an assembly in “Add Reference” dialog The “Add Reference” .NET tab dialog only shows the .NET Framework assemblies that are part of the selected profile. So some assemblies, such as System.Web.dll are not included in NET4 Client Profile and will only show if you target the Full framework. If you must use System.Web.dll you need to retarget to the Full framework. Starting with VS 2010 RTM, the “Add Reference” indicates the target framework that assemblies are filtered against. 3. My project cannot compile when I reference a Class Library You may encounter mixed-target scenarios: for example, when your Client Profile app adds a reference to a Class Library that is targeting the Full Framework (which it targets by default). You should be able to successfully build such solutions, as long as the Class Library does not use references to assemblies that only exist in the Full Framework. If it does, you may get warning/errors that are not completely clear.
For example you may see an error in your Client Profile app saying: “The type or namespace name 'ClassLibrary1' could not be found (are you missing a using directive or an assembly reference?)”
This error is not clear because the class library exists and can be compiled when it is compiled by itself. However, when MSBuild tries to resolve the transitive closure of the Client Profile project, it cannot find the Full Framework assembly that is referenced by the Class Library. In this case it is better to look at the generated warnings which are more informative: “The referenced assembly " …<your assembly>.." could not be resolved because it has a dependency on ""…<some assembly only available in Full Framework>…” which is not in the currently targeted framework ".NETFramework,Version=v4.0,Profile=Client". Please remove references to assemblies not in the targeted framework or consider retargeting your project.”
4. My controls or 3rd party controls is now showing in the VS 2010 toolbox Some VS 2008 3rd party Winforms controls will not work with VS 2010 NET4 Client Profile projects. The reason is that some of these controls have do not have separate design-time and run-time components and have dependencies on assemblies that are in the Full Framework (for example dependency on System.Windows.Forms.Design.dll which is Full). In VS 2010 RTM we made some changes to make it easier for developers to realize that.
Per the image below you can see that the VS 2008 DevExpress Winforms control are not showing in VS 2010 Toolbox and instead you see the message “Controls in this category are unavailable for the .NET Framework 4 Client Profile. To change this setting, open the Project Properties windows.” The Xceed VS 2008 controls on the other hand do have separate design-time and run-time components and works fine in VS 2008 and VS 2010. The good news is that many of the control vendors plan to release update to their control soon after VS 2010 RTM. Until such updates are available you need to retarget your project to NET4 Full if you must use these controls.
5. What should I do if a component that I need is not in NET4 Client Profile? Your first option is to try to find a workaround by modifying your code to use a component that is included in NET4 Client Profile. If this is not possible retarget your project to NET4 Full. As mentioned before, this is not ideal as most desktops are ikely to only have NET4 Client Profile so your app would need to chain-install NET4 full or block your app setup on NET4 full being present.
6. I want to write a custom WinForms control, what do I need to do for it to work with NET4 Client Profile? When developing Windows Forms control libraries, it is necessary to separate the runtime code from the control designers in order to target the new Client Profile. If the assembly references classes that exist in the Full framework but not in the Client Profile, the project will not compile successfully. Custom control designers usually inherit from the System.Windows.Forms.Design.ControlDesigner class in System.Design.dll, which is not included in .Net Framework 4 Client Profile.
We posted a guide that can walk you through the steps of creating a Windows Forms control that can be used in the .NET Framework 4 Client Profile. See: http://code.msdn.microsoft.com/WinFormsCustomCtrl Note that WPF custom controls do not inherit from classes in System.Design.dll and do not have this issue.
7. What’s the deal with <app.config> file ? If you change the project to target the Full Framework, VS will add a configuration file (<app.config>) that declares the application as a "full" application.
This enables the CLR loader to block any NET4 apps that target full on machines that only have the Client Profile. In this case, the CLR prompts the user to install NET4 full. E.g. you may see this dialog:
Note that in NET4 Beta1 and NET3.5 SP1 Client Profile if the <app.config> was missing the CLR the assumption was that you targeted the Full Framework. This is now reversed. In other words, if your NET4 app is missing <app.config> , by default the CLR assume that your app is targeting NET4 Client Profile! so, your app may crash at random when it needs to load the assemblies that
This has not significantly changed since Beta2, so read my Beta 2 blog. We did make some tweaks however in RTM (and RC), most notably:
Enhancements in NET4 Client Profile vs. NET 3.5 SP1 Client Profile This has not changed since Beta2, so read my Beta 2 blog .
What’s in and what’s not included in the Client Profile? Other than the APIs that were “Grey” out in RTM (and RC) and the tweaks mentioned above, we did not make other significantly changes since Beta2, so read my Beta 2 blog.
Where can I get the NET4 Client Profile? You can get .NET Framework 4 from here:
Related Blogs and Resources
Appendix A:
Here are the files that exist in the NET4 Client Profile and NET4 Full framework.
FileName
Client Profile
or Extended
_DataPerfCounters.h
Client
Perf counters
_DataPerfCounters.ini
_dataperfcounters_shared12_neutral.h
_dataperfcounters_shared12_neutral.ini
_NetworkingPerfCounters.h
_Networkingperfcounters.ini
_NetworkingPerfCounters_v2.h
_NetworkingPerfCounters_v2.ini
_ServiceModelEndpointPerfCounters.h
_ServiceModelEndpointPerfCounters.ini
_ServiceModelOperationPerfCounters.h
_ServiceModelOperationPerfCounters.ini
_ServiceModelServicePerfCounters.h
_ServiceModelServicePerfCounters.ini
_SMSvcHostPerfCounters.h
_SMSvcHostPerfCounters.ini
_TransactionBridgePerfCounters.h
_TransactionBridgePerfCounters.ini
Accessibility.dll
AddInProcess.exe
AddInProcess.exe.config
AddInProcess32.exe
AddInProcess32.exe.config
AddInUtil.exe
AddInUtil.exe.config
AdoNetDiag.dll
adonetdiag.mof
adonetdiag.mof.uninstall
alink.dll
alinkui.dll
AppLaunch.exe
applaunch.exe.config
AssemblyList_4_client.xml
CasPol.exe
caspol.exe.config
clr.dll
CLR.mof
CLR.mof.uninstall
clrjit.dll
CORPerfMonExt.dll
CORPerfMonSymbols.h
corperfmonsymbols.ini
csc.exe
csc.exe.config
cscui.dll
Culture.dll
CustomMarshalers.dll
cvtres.exe
cvtres.exe.config
CvtResUI.dll
default.win32manifest
dfdll.dll
dfsvc.exe
dfsvc.exe.config
diasymreader.dll
DropSqlWorkflowInstanceStoreLogic.sql
DropSqlWorkflowInstanceStoreSchema.sql
dw20.exe
EventLogMessages.dll
fusion.dll
GlobalMonospace.CompositeFont
WPF Composite fonts
GlobalSansSerif.CompositeFont
GlobalSerif.CompositeFont
GlobalUserInterface.CompositeFont
InstallUtil.exe
Moved to Client in RTM
installutil.exe.config
InstallUtilLib.dll
ISymWrapper.dll
jsc.exe
jsc.exe.config
locale.nlp
machine.config
machine.config.comments
machine.config.default
Microsoft.CSharp.dll
Microsoft.JScript.dll
Microsoft.JScript.tlb
Microsoft.Transactions.Bridge.dll
Microsoft.Transactions.Bridge.Dtc.dll
Microsoft.VisualBasic.Activities.Compiler.dll
Microsoft.VisualBasic.Activities.CompilerUI.dll
Microsoft.VisualBasic.Compatibility.Data.dll
Microsoft.VisualBasic.Compatibility.dll
Microsoft.VisualBasic.dll
Microsoft.VisualC.Dll
Microsoft.Windows.ApplicationServer.Applications.dll
Microsoft.Windows.ApplicationServer.Applications.dll.mui
Microsoft.Windows.ApplicationServer.Applications.man
mscordacwks.dll
mscordbi.dll
mscoree.tlb
mscoreei.dll
mscoreeis.dll
mscorlib.dll
mscorlib.tlb
mscorpe.dll
mscorpehost.dll
mscorrc.dll
mscorsecimpl.dll
mscorsecr.dll
mscorsvc.dll
mscorsvw.exe
msvcr100_clr0400.dll
NaturalLanguage6.dll
NETFXRepair.1025.dll
Resource files for .NET OS upgrade repair.
NETFXRepair.1028.dll
NETFXRepair.1029.dll
NETFXRepair.1030.dll
NETFXRepair.1031.dll
NETFXRepair.1032.dll
NETFXRepair.1033.dll
NETFXRepair.1035.dll
NETFXRepair.1036.dll
NETFXRepair.1037.dll
NETFXRepair.1038.dll
NETFXRepair.1040.dll
NETFXRepair.1041.dll
NETFXRepair.1042.dll
NETFXRepair.1043.dll
NETFXRepair.1044.dll
NETFXRepair.1045.dll
NETFXRepair.1046.dll
NETFXRepair.1049.dll
NETFXRepair.1053.dll
NETFXRepair.1055.dll
NETFXRepair.2052.dll
NETFXRepair.2070.dll
NETFXRepair.3076.dll
NETFXRepair.3082.dll
NETFXRepair.exe
ngen.exe
NlsData0009.dll
NlsLexicons0009.dll
nlssorting.dll
normalization.dll
normidna.nlp
normnfc.nlp
normnfd.nlp
normnfkc.nlp
normnfkd.nlp
PenIMC.dll
PerfCounter.dll
PresentationCore.dll
PresentationFramework.Aero.dll
PresentationFramework.Classic.dll
PresentationFramework.dll
PresentationFramework.Luna.dll
PresentationFramework.Royale.dll
PresentationHost_v0400.dll
PresentationHost_v0400.dll.mui
PresentationNative_v0400.dll
PresentationUI.dll
ReachFramework.dll
RegAsm.exe
regasm.exe.config
RegSvcs.exe
regsvcs.exe.config
regtlibv12.exe
SbsNclPerf.dll
ServiceModel.mof
ServiceModel.mof.uninstall
ServiceModel35.mof
ServiceModel35.mof.uninstall
ServiceModelEvents.dll
ServiceModelEvents.dll.mui
ServiceModelInstallRC.dll
ServiceModelInstallRC.dll.mui
ServiceModelPerformanceCounters.dll
ServiceModelPerformanceCounters.dll.mui
ServiceModelPerformanceCounters.man
ServiceModelReg.exe
ServiceModelRegUI.dll
ServiceModelRegUI.dll.mui
SetupUtility.exe
SMDiagnostics.dll
SMSvcHost.exe
SMSvcHost.exe.config
sortdefault.nlp
SOS.dll
SqlWorkflowInstanceStoreLogic.sql
SqlWorkflowInstanceStoreSchema.sql
sysglobl.dll
System.Activities.Core.Presentation.dll
System.Activities.dll
System.Activities.DurableInstancing.dll
System.Activities.Presentation.dll
System.AddIn.Contract.dll
System.AddIn.dll
System.ComponentModel.Composition.dll
System.ComponentModel.DataAnnotations.dll
Moved to Client in RC
System.configuration.dll
System.Configuration.Install.dll
System.Core.dll
System.Data.DataSetExtensions.dll
System.Data.dll
System.Data.Entity.dll
System.Data.Linq.dll
System.Data.Services.Client.dll
System.Data.SqlXml.dll
System.Deployment.dll
System.Device.dll
System.DirectoryServices.AccountManagement.dll
System.DirectoryServices.dll
System.DirectoryServices.Protocols.dll
System.dll
System.Drawing.dll
System.Drawing.tlb
System.Dynamic.dll
System.EnterpriseServices.dll
System.EnterpriseServices.Thunk.dll
System.EnterpriseServices.tlb
System.EnterpriseServices.Wrapper.dll
System.IdentityModel.dll
System.IdentityModel.Selectors.dll
System.IO.Log.dll
System.Management.dll
System.Management.Instrumentation.dll
System.Messaging.dll
System.Net.dll
System.Numerics.dll
System.Printing.dll
System.Runtime.DurableInstancing.dll
System.Runtime.Remoting.dll
System.Runtime.Serialization.dll
System.Runtime.Serialization.Formatters.Soap.dll
System.Security.dll
System.ServiceModel.Activities.dll
System.ServiceModel.Channels.dll
System.ServiceModel.Discovery.dll
System.ServiceModel.dll
System.ServiceModel.Routing.dll
System.ServiceProcess.dll
System.Speech.dll
System.tlb
System.Transactions.dll
System.Web.ApplicationServices.dll
System.Web.Services.dll
System.Windows.Forms.DataVisualization.dll
System.Windows.Forms.dll
System.Windows.Forms.tlb
System.Windows.Input.Manipulations.dll
System.Windows.Presentation.dll
System.Xaml.dll
System.XML.dll
System.Xml.Linq.dll
UIAutomationClient.dll
UIAutomationClientsideProviders.dll
UIAutomationProvider.dll
UIAutomationTypes.dll
vbc.exe
vbc.exe.config
vbc7ui.dll
WindowsBase.dll
WindowsFormsIntegration.dll
WMINet_Utils.dll
wpffontcache_v0400.exe
wpffontcache_v0400.exe.mui
wpfgfx_v0400.dll
wpftxt_v0400.dll
XPThemes.manifest
_DataOracleClientPerfCounters_shared12_neutral.h
Extended
_DataOracleClientPerfCounters_shared12_neutral.ini
addUser.aspx
addUser.aspx.resx
alert_lrg.gif
AppConfigCommon.resx
AppConfigHome.aspx
AppConfigHome.aspx.resx
ApplicationConfigurationPage.cs
AppSetting.ascx
AppSetting.ascx.resx
ASPdotNET_logo.jpg
Aspnet.config
aspnet.mof
aspnet.mof.uninstall
aspnet_compiler.exe
aspnet_counters.dll
aspnet_filter.dll
aspnet_isapi.dll
Aspnet_perf.dll
aspnet_perf.h
aspnet_perf.ini
aspnet_perf2.ini
aspnet_rc.dll
aspnet_regbrowsers.exe
aspnet_regiis.exe
aspnet_regsql.exe
aspnet_state.exe
aspnet_state_perf.h
aspnet_state_perf.ini
aspnet_wp.exe
AspNetMMCExt.dll
aspx_file.gif
AssemblyList_4_extended.xml
blackberry.browser
branding_Full2.gif
chooseProviderManagement.aspx
chooseProviderManagement.aspx.resx
chrome.browser
CLR-ETW.man
clretwrc.dll
ComSvcConfig.exe
confirmation.ascx
confirmation.ascx.resx
CreateAppSetting.aspx
CreateAppSetting.aspx.resx
createPermission.aspx
createPermission.aspx.resx
csc.rsp
darkBlue_GRAD.jpg
DataSvcUtil.exe
DataSvcUtil.exe.config
DebugAndTrace.aspx
DebugAndTrace.aspx.resx
default.aspx
default.aspx.resx
Default.browser
DefaultWsdlHelpGenerator.aspx
DefineErrorPage.aspx
DefineErrorPage.aspx.resx
deselectedTab_1x1.gif
DropSqlPersistenceProviderLogic.sql
DropSqlPersistenceProviderSchema.sql
dv_aspnetmmc.chm
EditAppSetting.aspx
EditAppSetting.aspx.resx
editUser.aspx
editUser.aspx.resx
EdmGen.exe
error.aspx
error.aspx.resx
FileTracker.dll
FileTrackerUI.dll
findUsers.aspx
findUsers.aspx.resx
firefox.browser
folder.gif
gateway.browser
generic.browser
GlobalResources.resx
gradient_onBlue.gif
gradient_onWhite.gif
GroupedProviders.xml
headerGRADIENT_Tall.gif
help.jpg
HelpIcon_solid.gif
home0.aspx
home0.aspx.resx
home1.aspx
home1.aspx.resx
home2.aspx
home2.aspx.resx
ie.browser
iemobile.browser
ilasm.exe
ilasm.exe.config
image1.gif
image2.gif
InstallCommon.sql
InstallMembership.sql
InstallPersistSqlState.sql
InstallPersonalization.sql
InstallProfile.SQL
InstallRoles.sql
InstallSqlState.sql
InstallSqlStateTemplate.sql
InstallWebEventSqlProvider.sql
iPhone.browser
legacy.web_hightrust.config
legacy.web_hightrust.config.default
legacy.web_lowtrust.config
legacy.web_lowtrust.config.default
legacy.web_mediumtrust.config
legacy.web_mediumtrust.config.default
legacy.web_minimaltrust.config
legacy.web_minimaltrust.config.default
manageAllRoles.aspx
manageAllRoles.aspx.resx
ManageAppSettings.aspx
ManageAppSettings.aspx.resx
ManageConsolidatedProviders.aspx
manageconsolidatedProviders.aspx.resx
managePermissions.aspx
managePermissions.aspx.resx
ManageProviders.aspx
manageProviders.aspx.resx
manageSingleRole.aspx
manageSingleRole.aspx.resx
manageUsers.aspx
manageUsers.aspx.resx
Microsoft.Build.Commontypes.xsd
Microsoft.Build.Conversion.v4.0.dll
Microsoft.Build.Core.xsd
Microsoft.Build.dll
Microsoft.Build.Engine.dll
Microsoft.Build.Framework.dll
Microsoft.Build.Tasks.v4.0.dll
Microsoft.Build.Utilities.v4.0.dll
Microsoft.Build.xsd
Microsoft.Common.OverrideTasks
Microsoft.Common.targets
Microsoft.Common.Tasks
Microsoft.CSharp.targets
Microsoft.Data.Entity.Build.Tasks.dll
Microsoft.Data.Entity.targets
Microsoft.NetFramework.props
Microsoft.NetFramework.targets
Microsoft.VisualBasic.targets
Microsoft.VisualC.STLCLR.dll
Microsoft.WinFx.targets
Microsoft.Workflow.Compiler.exe
Microsoft.Workflow.Compiler.exe.config
Microsoft.Xaml.targets
MmcAspExt.dll
MSBuild.exe
msbuild.exe.config
MSBuild.rsp
mscorsn.dll
navigationBar.ascx
navigationBar.ascx.resx
NavigationBar.cs
NetFx40_IIS_schema_update.xml
netmemorycache.h
netmemorycache.ini
opera.browser
PasswordValueTextBox.cs
PerfCounters.h
PerfCounters.ini
peverify.dll
PresentationBuildTasks.dll
ProviderList.ascx
providerList.ascx.resx
ProvidersPage.cs
requiredBang.gif
safari.browser
security.aspx
security.aspx.resx
security_watermark.jpg
security0.aspx
security0.aspx.resx
SecurityPage.cs
selectedTab_1x1.gif
selectedTab_leftCorner.gif
selectedTab_rightCorner.gif
ServiceMonikerSupport.dll
setUpAuthentication.aspx
setUpAuthentication.aspx.resx
SharedReg12.dll
SmtpSettings.aspx
SmtpSettings.aspx.resx
SqlPersistenceProviderLogic.sql
SqlPersistenceProviderSchema.sql
SqlPersistenceService_Logic.sql
SqlPersistenceService_Schema.sql
System.Data.Entity.Design.dll
System.Data.OracleClient.dll
System.Data.Services.Design.dll
System.Data.Services.dll
System.Design.dll
System.Drawing.Design.dll
System.Runtime.Caching.dll
System.ServiceModel.Activation.dll
System.ServiceModel.ServiceMoniker40.dll
System.ServiceModel.WasHosting.dll
System.ServiceModel.Web.dll
System.Web.Abstractions.dll
System.Web.DataVisualization.Design.dll
System.Web.DataVisualization.dll
System.Web.dll
System.Web.DynamicData.Design.dll
System.Web.DynamicData.dll
System.Web.Entity.Design.dll
System.Web.Entity.dll
System.Web.Extensions.Design.dll
System.Web.Extensions.dll
System.Web.Mobile.dll
System.Web.RegularExpressions.dll
System.Web.Routing.dll
System.Web.tlb
System.Windows.Forms.DataVisualization.Design.dll
System.Workflow.Activities.dll
System.Workflow.ComponentModel.dll
System.Workflow.Runtime.dll
System.WorkflowServices.dll
System.Xaml.Hosting.dll
TLBREF.DLL
topGradRepeat.jpg
Tracking_Logic.sql
Tracking_Schema.sql
UninstallCommon.sql
UninstallMembership.sql
UninstallPersistSqlState.sql
UninstallPersonalization.sql
UnInstallProfile.SQL
UninstallRoles.sql
UninstallSqlState.sql
UninstallSqlStateTemplate.sql
UninstallWebEventSqlProvider.sql
unSelectedTab_leftCorner.gif
unSelectedTab_rightCorner.gif
vbc.rsp
web.config
web.config.comments
web.config.default
web_hightrust.config
web_hightrust.config.default
web_lowtrust.config
web_lowtrust.config.default
web_mediumtrust.config
web_mediumtrust.config.default
web_minimaltrust.config
web_minimaltrust.config.default
webAdmin.master
webAdminButtonRow.master
WebAdminHelp.aspx
WebAdminHelp.aspx.resx
WebAdminHelp_Application.aspx
WebAdminHelp_Application.aspx.resx
WebAdminHelp_Internals.aspx
WebAdminHelp_Internals.aspx.resx
WebAdminHelp_Provider.aspx
WebAdminHelp_Provider.aspx.resx
WebAdminHelp_Security.aspx
WebAdminHelp_Security.aspx.resx
webAdminNoButtonRow.master
webAdminNoNavBar.master
WebAdminPage.cs
WebAdminStyles.css
WebAdminWithConfirmation.master
WebAdminWithConfirmationNoButtonRow.master
webengine.dll
webengine4.dll
wizard.aspx
wizard.aspx.resx
wizardAddUser.ascx
wizardAddUser.ascx.resx
wizardAuthentication.ascx
wizardAuthentication.ascx.resx
wizardCreateRoles.ascx
wizardCreateRoles.ascx.resx
wizardFinish.ascx
wizardFinish.ascx.resx
wizardInit.ascx
wizardInit.ascx.resx
WizardPage.cs
wizardPermission.ascx
wizardPermission.ascx.resx
wizardProviderInfo.ascx
wizardProviderInfo.ascx.resx
Workflow.Targets
Workflow.VisualBasic.Targets
wpf-etw.man
WsatConfig.exe
XamlBuildTask.dll
yellowCORNER.gif
Today (4/12/2010) we are excited to make the final .NET Framework 4 RTM build available. It can be downloaded from here and the .NET Framework 4 Client Profile is available from here. You can also check out Soma’s blog officially announcing Visual Studio 2010 which built on top of WPF 4. In previous related blogs I discussed the performance improvements we implemented in WPF in .NET 3.5 SP1 and .NET 3.5/3.0 SP1 (see here, and here). There are many improvements and new features in the WPF 4 release that we are really excited about (read more about those here and here) , but in this post I mainly wanted to focus and provide more details on the specific performance improvements we implemented in WPF 4.
1. New “Cached Composition” API to significantly improve rendering perf of complex visual trees This API provides apps the ability to cache a live UIElement and its sub-tree as a bitmap, and then render the UIElement as quickly as a bitmap (not requiring full rerasterization) when there are no structural changes to the cached subtree.
Transforms, opacities, etc applied above the cached UIElement do not force the cache to be regenerated. The UIElement remains fully interactive while cached, and fully mouse-interactive.
Motivation: Despite hardware acceleration, WPF’s rendering performance throughput is often limited by all the per-primitive work that must be done when rendering complex scenarios. Without this caching, simply animating an otherwise static element across the screen forces that element to be repeatedly be completely re-tessellated and re-rasterized which can be expensive operations. This often leaves WPF’s rendering pipeline bottlenecked in CPU-bound per-primitive setup cost.
The API enables breaking that bottleneck and allows primitives to be rendered as fast as the video card can draw a quad, moving the bottleneck from CPU primitive setup to GPU fill-rate, which is usually dramatically faster.
In doing this, there can be some loss of visual quality for the sake of performance. Many scenarios would gladly make this tradeoff. Scenarios that could benefit from this API:
See UIElement.CacheMode and BitmapCacheBrush for more details. Example: Setting CacheMode through C#:
UIElement.CacheMode= new BitmapCache();
Setting CacheMode though XAML:
<Rectangle CacheMode="BitmapCache" /><Rectangle> <Rectangle.CacheMode> <BitmapCache EnableClearType="true" RenderAtScale="4"/> </Rectangle.CacheMode></Rectangle>
2. New API to allow WPF apps to force SW rendering per process In NET 3.5 SP1 we added new API to allow developers to force software rendering per application window instead of using the GPU (see my Performance improvements in WPF in .Net 3.5 / 3.0 SP1 blog), in NET 4 you can now do so for the entire process.
As reported (see here), depending on the machine configuration and the application, software-based rendering is sometimes faster than hardware. This could improve rendering performance for certain scenarios and machines configuration, in most cases Hardware rendering should perform better. Please use carefully and verify with your app and machine configuration. In certain cases apps may want to use Software rendering for reliability reasons, for example on machines (typically older) that do not have reliable drivers. This APIs should provide developers a much better alternative than setting the global ‘Disable HW Acceleration’ registry key (see here)
ee
)
VS 2010 for example is using this feature to force VS 2010 into Software rendering on VMs thus improving reliability. VS 2010 is doing so since some VMs graphic emulation drivers found VS 2010 is doing so since some VMs graphic emulation drivers found not to be reliable. Here is an example for how to use this API:
public partial class App : Application { protected override void OnStartup(StartupEventArgs e) { if (WeThinkWeShouldRenderInSoftware()) RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly; }}
Notes: I) The precedence order for software rendering is:
II) The app force Software rendering at any time, however there is no way to force Hardware rendering back on once it was set to SoftwareOnly.
3. Added new VisualScrollableAreaClip API This allows line-scroll scenarios (e.g: line scroll in editor) to update less area and therefore be significantly more efficient over Remote Desktop (RDP) and Terminal Services scenarios.
The VS 2010 editor which is WOPF-based for example is taking advantage of this api.
(You can read more about Optimizing WPF for Remote Desktop here)
4. The default RenderOptions.BitmapScalingMode default is now changed Linear instead of Fant. This should provide some perf improvement if you scale images. but will produces lower quality output so be aware of this. If you still want Fant, you can re-enable it.
4. Minor 3D performance improvements. We reduced the amount of DrawPrimitive() calls for large indexed meshes and slightly improved CPU usage for large Model3D counts.
5. The BitmapEffect classes are now no-ops. BitmapEffect used to render in Software and caused perf issues. BitmapEffect are still there so your apps will compile but BitmapEffect will not do anything.
6. Some minor changes to Graphics Rendering Tier classification Pixel Shader 2.0 is now required for hardware acceleration. If your card was Tier 1 but did not have PS 2.0 it is now considered Tier 0 causing your app to render in Software.
1. Significantly improved UI Automation (UIA) performance. Two major improvements went into this effort:
A) Added UI Automation virtualization support.
This allows WPF apps that target NET4 and have virtualized elements (such as ListView, Tree View, etc ) to benefits from significantly improved performance on tablets and touch-enabled machines as well as none-Tablet machines that have Accessibility clients running (for example: Screen Reader or even have external input device like a pen or Wacom tablet) To use UIA virtualization WPF 4 is taking advantage the Windows Automation API 3.0 (aka "UI Automation API 3.0" or “UIA 3.0”). UIA 3.0 is included by default on Windows 7 & Windows 2008 Server R2. The gotcha is that the Windows Automation API 3.0 are not included on other down-level OS's (such as XP/Vista) and must be installed separately in order to get the full Perf benefits. See more in this blog.
This allows WPF apps that target NET4 and have virtualized elements (such as ListView, Tree View, etc ) to benefits from significantly improved performance on tablets and touch-enabled machines as well as none-Tablet machines that have Accessibility clients running (for example: Screen Reader or even have external input device like a pen or Wacom tablet)
To use UIA virtualization WPF 4 is taking advantage the Windows Automation API 3.0 (aka "UI Automation API 3.0" or “UIA 3.0”). UIA 3.0 is included by default on Windows 7 & Windows 2008 Server R2. The gotcha is that the Windows Automation API 3.0 are not included on other down-level OS's (such as XP/Vista) and must be installed separately in order to get the full Perf benefits. See more in this blog.
B) Optimized event handling
We addressed UI Automation issues mentioned in this blog In .NET 3.5 SP1 or earlier, performance problems (such as CPU consumption and generally sluggishness) were especially noticeable when scrolling within an application that contained many visual elements and if UIA client applications were running. In some cases WPF had to traverse every element in the application tree to check if it need to fire automation event. Depending on machine speed and how many elements are in an application’s visual tree this had significant performance impact. This was typical on Tablet and other touch-enabled machines because the Accessibility client TabTip.exe (the "Tablet PC Input Panel") is running by default. It was also possible on non-tablet machines since any machine can run UI Automation client app (for example, UI Spy, Narrator, Magnifier, etc) or had devices connected that also use UI Automation (for example, Wacom touch & pen input type device) In WPF 4 we fixed these performance issues.
We addressed UI Automation issues mentioned in this blog
In .NET 3.5 SP1 or earlier, performance problems (such as CPU consumption and generally sluggishness) were especially noticeable when scrolling within an application that contained many visual elements and if UIA client applications were running. In some cases WPF had to traverse every element in the application tree to check if it need to fire automation event. Depending on machine speed and how many elements are in an application’s visual tree this had significant performance impact.
This was typical on Tablet and other touch-enabled machines because the Accessibility client TabTip.exe (the "Tablet PC Input Panel") is running by default.
It was also possible on non-tablet machines since any machine can run UI Automation client app (for example, UI Spy, Narrator, Magnifier, etc) or had devices connected that also use UI Automation (for example, Wacom touch & pen input type device)
In WPF 4 we fixed these performance issues.
1. WPF4 now use DirectWrite for much improved text clarity This is not really perf per-se but it worth mentioning here. You can read more in Additional WPF Text Clarity Improvements and Direct2D and DirectWrite posts.
2. Improve text speed WPF4 English text is somewhat faster (~10%) compare to WPF 3.5 SP1
1. Much improved NET4 Full & Client Profile size and deployment performance. See graph comparing NETFX sizes:
2. NET4 Client Profile is now “first class citizen” Unlike NET 3.5 SP1 Client Profile, NET4 Client Profile:
Read more about NET4 Client Profile in this blog.
It is increasingly common for users to run their client application remotely, either connected to another Windows Client machine (Remote Desktop) or to a Windows Server (Terminal Service). In both of these scenarios the sources and the target machines are communicating over a protocol called Remote Desktop Protocol (or RDP).
In this blog, I wanted to share some of our findings while testing Visual Studio 2010 (VS 2010) over RDP as well as provide best practices to improve VS 2010 and your WPF-base app performance over RDP.
You may have seen the announcements (Soma , Jason Zander, Scott Guthris's) for the public release of Visual Studio 2010 RC . Some of the principles mentioned in this blog are also implemented by VS 2010.
While this blog is focusing on Microsoft remoting technologies some of the ideas discussed here should be applicable to other non-Microsoft technologies.
This blog is few pages long, the first part is a summary for folks who just want the short version. More details follow below in the document.
Summary: Best Practices for Improving VS 2010 and WPF Performance with Remote Desktop
A) Tune your Remote Desktop Connection (RDC) settings.
In slow bandwidth connections (such as slow DSL) or in high latency scenarios (such as connecting from US coast-to-coast) below tips can provide huge perf improvement. We for example measured ~4x gain in some scenarios.
Note that by doing above you are improving responsiveness but sacrificing some visual "prettiness" . Here is a summary of what we discussed above:
Connecting From:
Win7/R2
Vista SP+
XP SP3
XP SP2
Default RDC version installed:
RDC 7.0
RDC 6.1
RDC 5.2
For VS10 & WPF in slow network consider: (e.g. slow DSL, or coast-to-coast connection)
1.Use 16-bit color. 2. Use "WAN"/"Satellite" in high-latency cases. 3. User lower window size
Install RDC 7.0. Repeat the Win7 suggestions
Install RDC 7.0. Repeat the Win7 suggestions.
Upgrade to XP3. Repeat XP SP3 suggestions.
B) Optimize your WPF app to be Remote Desktop aware. Detect when you are running in Remote Desktop session and make sure to: 1. Reduce amount of your app UI updates while running over RDP, by:
2. Simplify content that is redrawn frequently so that the RDC compressor can be more efficient. (E.g. use solid colors over gradients or images.) 3. Avoid operations that are slow to render in software. (e.g. BitmapEffects & 3D) 4. Use the new VisualScrollableAreaClip NET4 API if your scenarios include line-scrolling.
C) During development, test your app to verify it is optimized for RDP
History and background
WPF Remoting architectures changes
Until .NET Framework 3.5 SP1 (NET 3.5 SP1) and earlier, remoting between Vista to Vista with DWM on, leveraged a custom WPF primitive remoting protocol. In all other scenarios content was remoted as bitmaps. Starting with the release of NET 3.5 SP1 (including NET 4), WPF renders the application content using a software rasterizer on the server and then remotes the content as bitmaps in all cases. Note:
Bitmaps are highly compressed by the underlying RDC stack and only regions that changed are being updated. Also note that WPF does not currently have efficient occlusion support, so for instance animations that are completely hidden behind other opaque WPF elements will still force invalidation and RDP update.
When apps use GDI (such as many Win32 and Winforms apps do), only the GDI primitives are remoted. In many cases this can be more efficient than remoting WPF apps since WPF apps remotes bitmaps which typically result in more content being sent over the wire than a similar GDI-based app. The additional data may result in slower performance depending on network bandwidth and the size and frequency of updates. However, in most scenarios, on reasonably fast connections, this is not an issue and in some scenarios (e.g. complex 3D scenes) remoting bitmaps can even present an advantage. Noticeable performance issues can appear in low bandwidth situations and when there is significant amount of data that must be remoted. For example, fast scrolling text file, playing video, or lots of animations.
Window 7 & Windows Server 2008 R2 changes
Windows Server 2008 R2 and Windows 7 operating systems includes a much improved Remote Desktop, called RDP 7.0. Read more in the RDP white-paper.
In addition to these improvements, the Windows 7 "Remote Desktop Connection" (RDC) client has few other changes. The interesting ones, which can have big impact on WPF performance and that we will discuss in more details later are:
It turns out that using 32-bit Color Depth, can improve many scenarios, however not all scenarios will improve.
The charts (taken from the RDP white-paper) show that PowerPoint scenarios would produce better RDP performance using RDP 7.0 with 32bpp Color Depth over RDP 7.0/6.1 16bpp. However, you are better off using 16bpp if you care more about better scrolling in Word/IE8.
Visual Studio 2010 over RDP is one of the scenarios that will benefit from switching to 16-bit color on slow connections.
It is important to note that in Remote Desktop scenario, even though the Client can specify that it wants to use 32-bit color, the Server can override this and set a maximum color depth.
By default, Windows 2008 Server/Windows 2008 R2 set the limit to 16-bpp color (On W2k8R2 see: "Start->Administrative Tools->Remote Desktop Services"->Remote Desktop Session Host COnfiguration". Right Click on the connection name listed).
Tuning RDP for optimal Visual Studio 2010 usage
As you may already know, many (but not all) UI components of VS 2010 are built using WPF 4.0 for the very first time. This implies that over RDP, VS 2010 remotes bitmaps for the portions of the UI that are built using WPF and remote GDI primitives for the non-WPF UI. The Editor is one of the VS 2010 UI features which are WPF-based.
During VS 2010 development, we worked really hard to optimize the Editor performance especially during continuous Scroll. By optimizing the Editor for the local scenario, we also improved the RDP scenario. Some of these principles we used are listed below.
We used a network emulator tool to simulate a slow network and measured amount of data transmitted on the wire during Editor scrolling. We also solicited feedback from users on the other side of the world who remoted to VS 2010 on machines in Redmond and compared the experience to Visual Studio 2008 side-by-side.
Some of our key findings were: Over fast network with little latency:
VS 2010 RDP performance approximately matches the performance of VS 2010 on a local machine with average GPU performance.
VS 2010 RDP performance almost matches VS 2008 RDP performance
Over slow network with high latency (we simulated 512 kbps, 75 msec delay each way to imitate a typical coast-to-coast connection):
VS 2010 RDP performance significantly slower than VS08 if the default 32-bit color and the "LAN (10Mbps or higher)" are kept on Windows7-to-Windows7 connection.
VS 2010 RDP performance is only slightly slower than VS08 when we changed to 16-bit color and selected "WAN (10Mbps or higher with high latency)" or "Satellite (2Mbps or higher with high latency)".
The chart and table below show we can improve VS 2010 scrolling perf by ~74% (from 82 sec to 22 sec) on a slow network just by picking the right RDC settings!
Page Scroll Scenario
RDP6/Vista 16bpp LAN Settings
Win7 16bpp - LAN settings
Win7 32bpp - LAN settings
Win7 16bpp - WAN settings
Win7 32bpp - WAN settings
Win7 16bpp - SAT settings
Win7 32bpp - SAT settings
VS 2010
28sec
28
82
22
75
65
We saw similar results in other VS 2010 scenarios, such as using menus, Intelisense, etc
In summary, to improve your VS 2010 perf over RDP consider:
If running over slow connection (e.g. slow DSL connection, for example 768kbs or lower), change RDC setting to use 16-bit color. This could significantly reduce number of bytes sent across the RDP wire. (Windows XP/vista already uses 16-bit color by default)
If running over high latency connection, for example when connecting from coast–to-coast (e.g. 150+ms round-trip latency), set "WAN (10Mbps or higher with high latency)" or "Satellite (2Mbps or higher with high latency)". Consider doing so as long as you have latency, even if the bandwidth is fast! This helps the underlying Remote Desktop client decide how to do its optimizations and improve perf. You can determine your latency by doing "ping <your_server>" from a command line. (Windows XP/Vista do not have these settings by default)
In Windows XP/Vista: Install, "Remote Desktop Connection 7.0 client update" and repeat steps from above. In addition to providing improve performance, installing RDP 7.0 it also allows you to select "high latency" in the "Remote Desktop Connection" Experience Tab UI which is not available in RDC 6.1/5.2.
Disable all check boxes (e.g. Font Smoothing, Visual Styles, etc) other than "Persistence bitmap caching" in the Experience tab. This also helps reduce number of bytes sent across the RDP wire.
Consider selecting lower size for your Remote Desktop window in the RDC settings. This will send smaller size bitmaps across the wire.
The above steps should help especially in low-bandwidth scenarios. As always check if performance actually improves after you made these changes. You may need to revert these changes if you use other apps or connect to another target machine with different network characteristics.
Optimizing your WPF app for RDP
In addition to selecting the correct RDC settings mentioned earlier, reducing the amount of content that needs to be sent across the wire is the key for better performance.
Your app for example, can detect that it is running over RDP and reduce the amount of content that needs to be updated and sent as bitmaps over the wire. It can also use graphic elements that can be compressed more efficiently by RDC bitmap compressor (e.g. use solid colors vs. gradients). In addition, since WPF renders the content on the server in software, the app should avoid using elements that are slow to render in software. Here are some more specific guidelines of what you can do:
Reduce the amount of UI updates while running over RDP. You can even consider doing so only when connection is slow (techniques on how to detect connection bandwidth is not provided here). Some of the common concepts are:
If possible consider turning off all animations during Remote Desktop session. For example: Creating a window background to an animating gradient or a video will cause the entire window to redraw every frame and be transmitted over the wire.
WPF does not currently ignore occluded parts of your app, so turn off all animations that are hidden behind some other opaque element.
For animations that you must keep, use the DesiredFrameRate property to decrease animation frame-rate and reduce traffic.
How we optimized Visual Studio 2010 for Remote Desktop
Visual Studio 2010 uses many of the approaches mentioned above. VS 2010 has a new "Enable rich client visual experience" checkbox in the Tools/Option menu. By default, the "Automatically adjust visual experience based on client performance" option is checked and Visual Studio 2010 will try to choose settings that are optimized for best performance. For example, if Visual Studio 2010 detects that it is running in a Remote Desktop session (as well as for other scenarios such as Virtual Machine environment or on machine w/ low-end graphics where WPF rendering tier return 0 or 1) then some visual effects are turned off. Here is a non-exhaustive list of things that happen in that situation:
In addition, regardless of whether “Enable rich client visual experience” is turned on or off, during rapid scrolling in the text editor, VS 2010: Postpones selected visual updates (e.g. the outlining margin and underline squiggles) until Idle. Reduces the number of layouts during thumb-tracking in the vertical scrollbar (when the scroll thumb is moved rapidly up or down).
In addition, regardless of whether “Enable rich client visual experience” is turned on or off, during rapid scrolling in the text editor, VS 2010:
Resources:
Below are related useful blogs:
Attached sample:
Below (also attached) sample code show how you can listen to the various Remote Desktop events and as discussed earlier you can use these events to trigger your app "RDP" features. In my sample, the window background is comprised of animating gradient. The app detects a Remote Desktop session connection and then switches the window background to be a solid color and vice versa. If I keep the animated background, then the entire window is invalidated and would have to be transmitted over the wire on each frame (e.g. 60 frame-per-seconds on most monitors). With animation removed and by using a solid color instead no network traffic is needed. Here is the network traffic I measured when I was experimenting with my sample:
App runs for 5 seconds (1280x1024)
When background animates
When background uses solid color
Amount of RDP traffic over 5 sec:
11 Mb
5 bytes
As you can see this would make a huge difference in low-bandwidth scenarios.
Figure 1- Animated background when run locally
Figure 2- Solid background when over Remote Desktop
1: <Window x:Class="Animation_Sample_For_RDP.Window1"
2: xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3: xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4: Title="Sample RDP-aware WPF application" Height="600" Width="750"
5: Loaded="Window_Loaded" Unloaded="Window_Unloaded"
6: xmlns:src="clr-namespace:Animation_Sample_For_RDP" >
7:
8: <Window.Resources>
9: <src:RemoteDesktopClass x:Key="myDataSource" />
10: </Window.Resources>
11: <Window.Template>
12: <ControlTemplate TargetType="{x:Type src:Window1}">
13: <Border Name="myBorder">
14: <Border.Background>
15: <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
16: <GradientStop Color="Green" Offset="0"/>
17: <GradientStop Color="LightBlue" Offset="0.2" x:Name="Foo"/>
18: <GradientStop Color="Blue" Offset="1"/>
19: </LinearGradientBrush>
20: </Border.Background>
21: <StackPanel Margin="20,0,0,0">
22: <StackPanel.DataContext>
23: <Binding Source="{StaticResource myDataSource}"/>
24: </StackPanel.DataContext>
25: <StackPanel Margin="20,0,0,0" Orientation="Horizontal">
26: <TextBlock Margin="0,15,0,0" FontWeight="Bold">Remote Desktop Session status:</TextBlock>
27: <TextBlock Margin="5,15,0,0" Name="RD_status"
28: Text="{Binding Path=RemoteDesktopStatus, UpdateSourceTrigger=PropertyChanged}"/>
29: </StackPanel>
30: <StackPanel Margin="20,0,0,0" Orientation="Horizontal">
31: <TextBlock Margin="0,15,0,0" FontWeight="Bold">In Remote Desktop Session:</TextBlock>
32: <TextBlock Margin="5,15,0,0"
33: Text="{Binding Path=IsRemoteDesktopSession, UpdateSourceTrigger=PropertyChanged}"/>
34: </StackPanel>
35: </StackPanel>
36: </Border>
37: <ControlTemplate.Triggers>
38: <EventTrigger RoutedEvent="Window.Loaded">
39: <BeginStoryboard>
40: <Storyboard AutoReverse="True" BeginTime="0" >
41: <DoubleAnimation Storyboard.TargetName="Foo" Storyboard.TargetProperty="Offset"
42: AutoReverse="True" From="0.1" To="0.9" Duration="0:0:3" RepeatBehavior="Forever"/>
43: </Storyboard>
44: </BeginStoryboard>
45: </EventTrigger>
46: <!--Set to Solid background when a Remote Session was triggered -->
47: <DataTrigger Binding="{Binding Source={StaticResource myDataSource},
48: Path=IsRemoteDesktopSession}" Value="true">
49: <Setter TargetName="myBorder" Property="Border.Background" Value="LightBlue"/>
50: </DataTrigger>
51: </ControlTemplate.Triggers>
52: </ControlTemplate>
53: </Window.Template>
54: </Window>
1: using System;
2: using System.Collections.Generic;
3: using System.Linq;
4: using System.Text;
5: using System.Windows;
6: using System.Windows.Controls;
7: using System.Windows.Data;
8: using System.Windows.Documents;
9: using System.Windows.Input;
10: using System.Windows.Media;
11: using System.Windows.Media.Imaging;
12: using System.Windows.Navigation;
13: using System.Windows.Shapes;
14: using System.Windows.Interop;
15: using System.Runtime.InteropServices;
16: using System.ComponentModel;
17: using System.Windows.Threading;
18:
19: namespace Animation_Sample_For_RDP
20: {
21: public partial class Window1 : Window
22: {
23: [DllImport("wtsapi32.dll", SetLastError = true)]
24: static extern bool WTSRegisterSessionNotification(IntPtr hWnd, [MarshalAs(UnmanagedType.U4)] int dwFlags);
25: [DllImport("wtsapi32.dll", SetLastError = true)]
26: static extern bool WTSUnRegisterSessionNotification(IntPtr hWnd); // constants passed in the dwFlags parameter
27: const int NOTIFY_FOR_THIS_SESSION = 0;
28: const int NOTIFY_FOR_ALL_SESSIONS = 1; // message id to look for when processing the message (see sample code)
29: const int WM_WTSSESSION_CHANGE = 0x2b1; // WParam values that can be received:
30: const int WTS_CONSOLE_CONNECT = 0x1; // A session was connected to the console terminal.
31: const int WTS_CONSOLE_DISCONNECT = 0x2; // A session was disconnected from the console terminal.
32: const int WTS_REMOTE_CONNECT = 0x3; // A session was connected to the remote terminal.
33: const int WTS_REMOTE_DISCONNECT = 0x4; // A session was disconnected from the remote terminal.
34: const int WTS_SESSION_LOGON = 0x5; // A user has logged on to the session.
35: const int WTS_SESSION_LOGOFF = 0x6; // A user has logged off the session.
36: const int WTS_SESSION_LOCK = 0x7; // A session has been locked.
37: const int WTS_SESSION_UNLOCK = 0x8; // A session has been unlocked.
38: const int WTS_SESSION_REMOTE_CONTROL = 0x9; // A session has changed its remote controlled status.
39: public enum SystemMetric
40: {
41: SM_REMOTESESSION = 0x1000,
42: SM_REMOTECONTROL = 0x2001,
43: }
44: [DllImport("user32.dll")]
45: static extern int GetSystemMetrics(SystemMetric smIndex);
46: static IntPtr hwnd;
47: static Window1 myClass;
48: public Window1()
49: {
50: InitializeComponent();
51: myClass = this;
52: }
53: private void Window_Loaded(object sender, RoutedEventArgs e)
54: {
55: Window w = Application.Current.MainWindow;
56:
57: WindowInteropHelper wih = new WindowInteropHelper(this);
58: hwnd = wih.Handle;
59:
60: if (!WTSRegisterSessionNotification(hwnd, NOTIFY_FOR_THIS_SESSION))
61: MessageBox.Show("WTSRegisterSessionNotification failure");
62: HwndSource MainWindowHwndSource = PresentationSource.FromVisual(w) as HwndSource;
63: if (MainWindowHwndSource != null)
64: MainWindowHwndSource.AddHook(new HwndSourceHook(MainWindowHwndMessageFilter));
65: else
66: Console.WriteLine("MainWindowHwndSource == null");
67:
68: if (GetSystemMetrics(SystemMetric.SM_REMOTECONTROL) != 0)
69: Console.WriteLine("Session is currently remotely controlled.");
70: else
71: Console.WriteLine("Session is NOT currently remotely controlled.");
72: if (GetSystemMetrics(SystemMetric.SM_REMOTESESSION) != 0)
73: {
74: Console.WriteLine("Process is associated with a Terminal Services client session.");
75: SetRemoteSessionStatus("WTS_CONSOLE_CONNECT");
76: SetRemoteSessionState(true); // we are over Remote Session !
77: }
78: else
79: {
80: Console.WriteLine("Process is NOT associated with a Terminal Services client session.");
81: SetRemoteSessionState(false); // we are connected locally !
82: }
83: }
84: static void SetRemoteSessionStatus(string status)
85: {
86: myClass.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
87: {
88: RemoteDesktopClass db = myClass.FindResource("myDataSource") as RemoteDesktopClass;
89: db.RemoteDesktopStatus = status;
90: }));
91: }
92: static void SetRemoteSessionState(bool b)
93: {
94: myClass.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
95: {
96: RemoteDesktopClass db = myClass.FindResource("myDataSource") as RemoteDesktopClass;
97: db.IsRemoteDesktopSession = b;
98:
99: }));
100: }
101: static IntPtr MainWindowHwndMessageFilter(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
102: {
103: switch (msg)
104: {
105: case WM_WTSSESSION_CHANGE:
106:
107: Console.Write("WM_WTSSESSION_CHANGE ");
108: int param = ((int)wParam);
109: switch (param)
110: {
111: case WTS_CONSOLE_CONNECT:
112: Console.Write("WTS_CONSOLE_CONNECT\n");
113: SetRemoteSessionStatus("WTS_CONSOLE_CONNECT");
114: SetRemoteSessionState(false); // we are connected locally !
115: break;
116: case WTS_CONSOLE_DISCONNECT:
117: Console.Write("WTS_CONSOLE_DISCONNECT\n");
118: SetRemoteSessionStatus("WTS_CONSOLE_DISCONNECT");
119: break;
120: case WTS_REMOTE_CONNECT:
121: Console.Write("WTS_REMOTE_CONNECT\n");
122: SetRemoteSessionStatus("WTS_REMOTE_CONNECT");
123: SetRemoteSessionState(true); // we are over Remote Session !
124: break;
125: case WTS_REMOTE_DISCONNECT:
126: Console.Write("WTS_REMOTE_DISCONNECT\n");
127: SetRemoteSessionStatus("WTS_REMOTE_DISCONNECT");
128: break;
129: case WTS_SESSION_LOGON:
130: Console.Write("WTS_SESSION_LOGON\n");
131: SetRemoteSessionStatus("WTS_SESSION_LOGON");
132: break;
133: case WTS_SESSION_LOGOFF:
134: Console.Write("WTS_SESSION_LOGOFF\n");
135: SetRemoteSessionStatus("WTS_SESSION_LOGOFF");
136: break;
137: case WTS_SESSION_LOCK:
138: Console.Write("WTS_SESSION_LOCK\n");
139: SetRemoteSessionStatus("WTS_SESSION_LOCK");
140: break;
141: case WTS_SESSION_UNLOCK:
142: Console.Write("WTS_SESSION_UNLOCK\n");
143: SetRemoteSessionStatus("WTS_SESSION_UNLOCK");
144: break;
145: case WTS_SESSION_REMOTE_CONTROL:
146: Console.Write("WTS_SESSION_REMOTE_CONTROL\n");
147: SetRemoteSessionStatus("WTS_SESSION_REMOTE_CONTROL");
148: break;
149: }
150: break;
151: default:
152: break;
153: }
154: return IntPtr.Zero;
155: }
156: private void Window_Unloaded(object sender, RoutedEventArgs e)
157: {
158: if (!WTSUnRegisterSessionNotification(hwnd))
159: Console.WriteLine("WTSUnRegisterSessionNotification failure");
160: }
161: }
162: public class RemoteDesktopClass : INotifyPropertyChanged
163: {
164: string _RemoteDesktopStatus;
165: bool _IsRemoteDesktopSession;
166: public RemoteDesktopClass()
167: {
168: }
169: public RemoteDesktopClass(string value)
170: {
171: this.RemoteDesktopStatus = value;
172: }
173: public string RemoteDesktopStatus
174: {
175: get { return _RemoteDesktopStatus; }
176: set
177: {
178: _RemoteDesktopStatus = value;
179: OnPropertyChanged("RemoteDesktopStatus");
180: }
181: }
182: public bool IsRemoteDesktopSession
183: {
184: get { return _IsRemoteDesktopSession; }
185: set
186: {
187: _IsRemoteDesktopSession = value;
188: OnPropertyChanged("IsRemoteDesktopSession");
189: }
190: }
191: public event PropertyChangedEventHandler PropertyChanged; //OnPropertyChanged -update property value in binding
192: private void OnPropertyChanged(String info)
193: {
194: if (PropertyChanged != null)
195: PropertyChanged(this, new PropertyChangedEventArgs(info));
196: }
197: }
198: }
In Microsoft .NET Framework 4, WPF added UI Automation (UIA) virtualization support. This did not exist in WPF in previous .Net releases.
This allows any WPF app that target NET4 and have virtualized elements (such as ListView, Tree View, etc ) to benefits from significantly improved performance on machines that have Accessibility clients running (for example: Screen Reader).
This is typical on Tablet and other touch-enabled machines because the Accessibility clients TabTip.exe (the "Tablet PC Input Panel") is running by default.
It is also common on non-tablet machines since any machine can run UI Automation client app (for example, UI Spy, Narrator, Magnifier, etc) or have devices connected that also use UI Automation (for example, Wacom touch & pen input type device)
Visuals Studio 2010 is an example of a WPF 4 app that uses virtualized WPF elements and can benefit from the UIA Virtualization.
For the UIA virtualization to work, under the covers WPF uses Windows Automation API 3.0 (aka "UI Automation API 3.0").
These APIs are included by default on Windows 7 & Windows 2008 Server R2.
The gotcha is that the Windows Automation API 3.0 are not included on other down-level OS's (such as XP/Vista) and must be installed separately in order to get the full Perf benefits.
These APIs can be installed from this location: http://support.microsoft.com/kb/971513/ Please note that the download site currently do not support XP 64 bit and you musty have the latest SP installed (e.g. Vista SP2, XP SP3)
So in summary: Do you notice VS 2010 or other WPF based app performance issues?
Related blogs: WPF 3.5 SP1 Performance on Tablet & Touch-enabled machines This blog is about improving UI Automation for WPF 3.5 SP1 apps and has no impact on .NET 4 RC apps or later nor Visual Studio 2010 RC or later. The reason is that this optimization is already included in .NET 4 RC or later. Note that we now have a Hotfix for .NET 3.5 SP1, see here.
Intellisense Crashing on VS 2010 RC This blog discusses crashes in VS 2010 RC when using Intelisense which are related UIA but is a separate issue from UIA performance issue above. You would still need to install Windows Automation API 3.0 on XP/Vista to get the optimal perf for WPF 4 and Visual Studio 2010