Skip to content

Instructions for profiling Silverlight (Desktop) with VS2010 RTM

Maxim Goldin, from the VSTS team, has an excellent post on how to profile Silverlight 4 desktop with VS2010.

Oren Nachman, our rockstar new perf SDET for Silverlight, is also an excellent source for Silverlight profiling tricks.

Tips for creating massive amounts of shapes

I am often asked how to reduce the creation time for a massive number of shapes.

 

Try a few things:

1)      Use XamlReader.Load when you can (with the mini-language), which allows you to use the native parser and not managed code to create new shapes

2)      Use the mini-language for Paths or lines (whether using Xamlreader or C#) – both Silverlight and WPF optimize the mini-language internally, in different ways. When the mini-language is used, Silverlight does not create managed object for each PathFigure, Point etc– which saves creation time and space:

http://msdn.microsoft.com/en-us/library/cc189041(VS.95).aspx

 

3)      Switch to Bitmaps if appropriate.

4)      Prototype! Prototype! Prototype! Don’t write everything and realize that SL can’t generate 100,000 managed objects every 10msec. =)

 

Generally, for drawing massive number of shapes, you want to reduce the amount of time spent in managed creation time.

-Seema

Video of “Deep Dive into SL Graphics” from Mix 2009 is posted

[this was originally posted on http://blogs.msdn.com/seema, reposting as I am moving hosting sites]

The video for my talk on graphics is now posted, with slides:

http://videos.visitmix.com/MIX09/T17F

Demos:

Note that I deleted the original images from the project — so, before pressing F5, replace trees.jpg and spring.jpg with actual images.
I’ll post detailed steps shortly, but this should get most of you unblocked. Make sure to install the Pixel Shader Build Task before using (see below)

Pixel Shader Resources:

Enjoy!
Seema

Summary of the 20min perf talk at Mix 2009

[this was originally posted on http://blogs.msdn.com/seema, reposting as I am moving hosting sites]

The 20 minute talk is posted here. I spoke till the speaker timer started to flash at me (giant flashing clock), which resulted in having no time for a forum Q&A, but feel free to post your questions/comments down below. I’m always curious about what perf issues people are hitting.

Understanding perf issues gives me an idea of how people are stretching the platform beyond our key scenarios, and which APIs/codepaths we should improve in the next version.

Tim Sneath wrote an excellent writeup of my 20min mix session on writing an optimized SL app. I almost wish that I had his post to read off as a script!

Talk Video & PPT: http://videos.visitmix.com/MIX09/T67M
Tim’s great summary: http://blogs.msdn.com/tims/archive/2009/03/24/building-an-optimized-graphics-intensive-silverlight-application.aspx

Cheers, Seema

Going to Vegas with my Phone…

For those wondering my current project is, I can finally talk about it! I’ll be speaking at Mix, hope to see you there!

SILVERLIGHT PERFORMANCE ON WINDOWS PHONE

http://live.visitmix.com/MIX10/Sessions/CL60

PDC 2009 video, TechEd Iceland, VS2010, profiling, Silverlight 4

(I know I promised this eons ago, so apologies in advance… on the flipside, I’m posting from my vacation in Paris, so hopefully that earns me 1-2 brownie points back.)

First, my PDC slides and the video. This is the same talk that I gave at TechEd Iceland for profiling. 

I was recently reminded to post instructions on profiling Silverlight 4 with VS2010.

At PDC, I announced that Silverlight 4 came with the new CoreCLR capability of being profile-able by the VS2010 profilers: this means that for the first time, we give you the power to profile the managed and native code (user or platform) used by a Silverlight application. woohoo. kudos to the CLR team.

Sidenote: From silverlight 1-3, one could only use things like xperf (see XPerf: A CPU Sampler for Silverlight) which is very powerful to see the layout/text/media/gfx/etc pipelines, but only gives the native callstack.)

However, the version of VS2010 available at PDC unfortunately had a bug: it could not profile Silverlight. My PDC profile demo was saved from a VS2010 build with the fix… thus the delay in my posting instructions. I’m not sure when you’ll get next the public drop of VS2010… but you’ll run into a new problem: SL4 Beta did not publish symbols to the Microsoft Symbol Server.

I’ll be sure to post a status on all of this by Mix (feel free to remind me).

If you happen to read this at a later point, when you have all the drops and symbols, then: Hello! What is the future like? You can use the below instructions:

  1. admin-level VS prompt
  2. cd /
  3. vsperfclrenv /sampleon
  4. set CORECLR_ENABLE_PROFILING=1
  5. set CORECLR_PROFILER=%COR_PROFILER%
  6. vsperfcmd /start:sample /output:myProfile.vsp
  7. vsperfcmd /launch:”c:\Program Files\Internet Explorer\iexplore.exe” /timer:100000
  8. **    navigate, play with app, Shut down.
  9. vsperfcmd /shutdown
  10. before viewing, turn on the symbols server in VS2010 through: Tools–>Options–>Debugging–>Symbols–>check microsoft symbols server.
    (In the video, the symbols just point to a folder where I cache the internal symbols locally… not sure, but I don’t think you guys can do that too.)
  11. Open file in VS2010
    (Double-clicking in explorer will not work. VS2010 –> File –> open –> pick file.)
Cheers, and have fun! 
Seema

Published the Source code for Silverlight 2 Runtime & SDK Controls

[originally posted on http://blogs.msdn.com/seema, I am moving hosting sites -Seema]


Hi all,

We’ve just published the sample source code for the Silverlight 2 Controls as shipped in the runtime and the SDK.

Within the RuntimeControls folder, you’ll see a Solution that contains three projects:

1. SilverlightControls – One can edit the source and default control templates of the controls in order to build a DLL containing custom versions of the controls.

2. Controls Sample – One can take the SilverlightControls DLL from #1 and include it in a project such as this. If you press F5, this app will launch displaying the controls created in #1.

3. System.Windows.Design – This project is here largely for reference, it shows how to build a Design dll for VisualStudio and Expression Blend such that your custom controls would display within the toolbox.

Control Source Explorer

Disclaimer: Note that we did take a small amount of changes in the Runtime Controls to get the project to properly build outside of our internal build environment.

The source for the following controls was released:

Managed Runtime Controls:

o ButtonBase

o Button

o HyperlinkButton

o CheckBox

o RadioButton

o ToggleButton

o RangeBase

o ProgressBar

o Slider

o ScrollBar

o Thumb

SDK classes:

o Calendar

o DatePicker

o DataGrid

o TabControl

o GridSplitter

Unite Tests for the SDK controls

Appropriate sub-types (eventargs/ handlers, etc)

Have fun and let us know what you build!

Seema, Andre Michaud, & Jon Sheller

Some tips from the Silverlight perf PDC 2008 talk

Mike Snow posted a few of the tips from my PDC talk here, it’s a great summary.

You can check it out here.

Cheers!

Seema

Getting to the Media FastPath

[this was originally posted on http://blogs.msdn.com/seema, reposting as I am moving hosting sites]

Earlier this week, us in the Silverlight perf and media teams reviewed Ben Waggoner’s tutorial on how to build fast media players, check it out here:

http://on10.net/blogs/benwagg/Building-high-performance-Silverlight-Media-Players/

Tis a great how to guide.

(now I’m really going home. Seema)

EnableFramerateCounter, Setting your Framerate correctly

[this was originally posted on http://blogs.msdn.com/seema, reposting as I am moving hosting sites]

Debug tool
I posted about EnableFramerateCounter before — it is a simple little debugging setting that you can use when trying to figure out:

  1. Which of these designs hurts my framerate more?
  2. If I add this module in, does it hurt my framerate?

To figure these out, you can:

  1. Set the plugin’s desired framerate at 1000 (silverlightObject.settings.MaxFrameRate OR Silverlight.CreateObjectEx({properties:{framerate:’framerate‘}}))
  2. Turn on the EnableFramerateCounter, which should show up in the status bar (IE/Firefox –> View –> Status Bar).

Desired Framerates
Make sure to reset the framerate to the suggested framerates for your app: Media apps @60fps or RIA/Control apps @20fps before launching your app to the public.
When trying to figure out the desired framerate of an animation or control-heavy app, use real people (not developers/designers) to gauge whether increasing the fps above 20fps makes sense. If you set your framerate at an unnecessarily high value, it will throttle the computer’s cycles — and could result in a jerkier effect than if you just had a lower framerate. So where 60fps might be slick and easy for your devbox, it could be a pain for your customer’s machine — so only use what you need.

The desired framerate of plugin hosting media is always 60fps — this gives the media pipeline the most number of ticks to figure out the optimal timing of presenting a frame. Silverlight will decode at the framerate of the encoded video (this usually is <32fps), and we present the frames in sync with the audio. To summarize roughly, if the platform doesn’t receive a tick in sync with the audio, then the platform will decode the frame, and then just throw it away. If you don’t understand this, just trust me and use framerate=60.

Technically, you could set the framerate dynamically — I haven’t tried this, but it might be a useful thing to try out if your app has both media and heavy controls/animations.

Debugging Settings

So here are the debugging settings that I use (not all at once, of course)

Sys.Silverlight.createObjectEx({

source: “xaml/Scene.xaml”,

parentElement: document.getElementById(“SilverlightControlHost”),

id: “SilverlightControl”,

properties: {

width: “500”, height: “500”,

isWindowless: false,

background: “FF000000”,

framerate: 10000 },

events: { onLoad:onLoadHandler} });

function onLoadHandler() {

agControl = document.getElementById(“SilverlightControl”);

/* To see the framerate displayed in the browser status bar */

agControl.settings.EnableFrameRateCounter = true;

/* To see the redraw regions*/

agControl.settings.EnableRedrawRegions= true;

}

I accidentally dumped the sugar canister into my tea, time to go home.
Seema