Friday, February 27, 2009

The Visual Studio 2008 Profiler is....

in nice words....

complete crap.

I just upgraded my Visual Studio Professional 2008 Version to a 2800 USD Team Edition. Of course I installed SP1 first. The reason behind was that our WCF Service project is getting to a point where performance is getting relevant, so we needed to get some profiler results on our code.

So if you think you can install Visual Studio Team or Developer Edition and just hit a "Profile Code" button and get some results you are wrong.

For some reason the profiler does not collect any data

"PRF0025: No data was collected"

is all I got the first day. No matter whether I used the "Sampling" or "Instrumentation" method. All I got was straight nothing.

The documentation seems to be close to nothing as well. But then I stumbled into some web page and found out that the whole profiler thing is located in

%PROGRAMFILES%\Microsoft Visual Studio 9.0\Team Tools\Performance Tools

There is a little batch called VSPerfCLREnv.cmd which then can called with various options.
But when you check out this little tool you find out that the whole profiler thing is based on enviroment variables. And guess what you have to do if you set one of the /global parameters...

Yes reboot. Every time.

After that at least could do some profiling with Instrumentation method.

Linq/Lambda Expressions are not handled appropriately

But if the profiler did not collect any data before, now a single service function call collected more than 600MB of data. That's quite a lot if you think that the service function has not more than 100 lines of user code.

It took a while to find out what happened.


foreach (var item in items)
item.StaticInstrument = fullStatics.Find(fs => fs.ID == item.StaticInstrument.ID);

results in 600MB profiler data.

Rewriting the code to use a dictionary instead the List extension method Find(this List)

var itemDic = new Dictionary<string, StaticInstrument>();

fullStatics.ForEach(singleStatic => itemDic[singleStatic.ID] = singleStatic);

items.ForEach(item => item.StaticInstrument = itemDic[item.StaticInstrument.ID]);

results in 2MB of profiler data.

Functions are not displayed appropriatly in the reports.

But then the next disappointment is right behind the door.

In the report I have various multiple summaries like

Function Name:
0x2B000015
0x2B0000oE

This is not really helpful. Especially as the values for function called by the disguised functions are not displayed at all. Everything just gets summed up.

I took me another half day to find out what is the reason behind this.

In the above mentioned directory you find a tool called
VSPerfReport.exe

if you pass call it like

VSPerfReport.exe PATHTO\Report.vsp

I at least got

Warning VSP2701 : Symbol Engine: File '.....dll' could not be found when looking for debug information. Full symbol/type resolution may not be possible

But when you look at the location there is of course the DLL's symbol or pdb file right next to the dll. Why it still fails to load it, I don't know. I did not find any resolution for this problem yet.

So for most of DLL's the report fails to load the symbols. The resulting report is really useless.

I tried to write some mails to the guys from the Microsoft Profiler Team but it took a while to get some answer. See the comment for some suggestions from Marc Popkin-Paine. Unfortunately his suggestions don't work for me and meanwhile the profiler refuses again to collect any data at all.

Here is what happens...

Successfully attached to process: 4828
VSPerformance Automation warning: Warning VSP2348 : 2 buffer(s) lost in association with process 4828.
Exited from process: 4828
Collection file exited: C:\Development\WCFServices\SCDService\SCDServices090305.vsp
Profiler exited
PRF0025: No data was collected.

So if you ever thought about about spending money on Team or Developer Edition to use the profiler.... Save the money. The profiler is complete crap. You even have to be careful with it. I might crash your system with a blue screen of death. The reason behind this is that they obviously access the bios to get the exact number of clock cycles. Because of the different BIOS this is the reason, why it sampling does work for a certain number of systems. But this raises another question. Why the heck can a user process in Windows still read/write the bios and crash the system?

So in short...

With the Microsoft Profiler I wasted a lot of money and time without getting any useful results.

I have evaluated the current ANTS 4.3 profiler. ANTS works right out of the box and here I can see all functions but the disadvantage is a huge overhead. ANTS tries to eliminate the overhead in the calculation but is not totally succesful with this task.

Wednesday, February 18, 2009

Screw Silverlight

The thought behind evaluating Silverlight 2 was to check whether Silverlight is suited to build rich office applications, that can be handled just like common GUI applications but just in IE. Another central question was to verify that I can use my Xaml controls from WPF applications seamlessly in Silverlight 2.
So I am really not interested in fancy design, multimedia and other special effects that seems to be the general target audience for Silverlight 2.

First thing you have to do when you try to evaluate Silverlight 2 with Visual Studio you have to download a whole bunch off applications. Most important it seemed to install the Silverlight Tools for Visual Studio 2008 SP1 .

After downloading some 70 megs of data the the first frustration is right around the corner, if you have to use an authenticating proxy to get Internet access.

Though you have to download some 70 megs the package needs to download more data. And of course there is nowhere a full package. Even more unfortunate it seems that until today Microsoft has never heard anything of a thing called authenticating proxy and consequently the install fails. Sigh.
Call it a act of despair and interest I programmed my own little authenticating proxy bridge that acts as proxy and forwards each request to the real proxy plus adding the required authentication information. So finally I was able to install the tools.

Ok, so I created a new Silverlight project, opened the toolbox, took a button and dropped it onto the designer and...

the designer won't let me do that.

Although we have a fully fledged Xaml designer in WPF, there is absolutely no way to add a control in the designer in Silverlight. You are supposed to drag the items out of the toolbox into the Xaml text editor where it does nothing but adding the following code

<
Button></Button>


Wow, what an awesome and intuitive feature for my 1500 USD Visual Studio.

Ok, lets hand code my button. After setting the button properties width and height you would like some text on your button.

So you code

<Button Width="100" Height="20">Press me</Button>

This is perfect Xaml, even Expression Blend will code it that way, it works fine for WPF, but .....

that is not good enough for Silverlight.

"Button does not support text content" is the error. It turns out that if you want to get it to work with Silverlight you have to code it

<Button Width="100" Height="20" Content="Press me"/>

So let me get this straight.

  • You have to download at least 4 packages to start with silverlight.
  • Even then these packages need to download more data and neither there are full packages available nor does the setup support simple things like authenticating proxies.
    No Internet access means no Silverlight.
  • The nice Xaml designer shipped with WPF had been crippled for Silverlight to be absolutely useless.
  • The Xaml for Silverlight is incompatible with other Xaml.
  • If you do not want to hand code every GUI element and if even if you have the 1500 USD Team Edition of Visual Studio 2008 you need to buy Expression Blend 2 for just another 699 USD.

Ok guys,

this is where my evaluation comes to an abrupt end after just 60 minutes and tell you what....

Screw Silverlight 2.