<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Angry Richard's WebLog</title><link>http://blogs.msdn.com/angryrichard/default.aspx</link><description>He's not as angry as he looks</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Memory Allocation Profiling is Managed Only!</title><link>http://blogs.msdn.com/angryrichard/archive/2006/12/13/memory-allocation-profiling-is-managed-only.aspx</link><pubDate>Wed, 13 Dec 2006 18:24:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1276194</guid><dc:creator>AngryRichard</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/angryrichard/comments/1276194.aspx</comments><wfw:commentRss>http://blogs.msdn.com/angryrichard/commentrss.aspx?PostID=1276194</wfw:commentRss><description>&lt;P&gt;People have been discovering that the VS Team System profiler can collect allocation data for an application.&amp;nbsp; It isn't long after that they discover that it only works on &lt;EM&gt;managed&lt;/EM&gt; code, not native.&amp;nbsp; Sadly, the documentation is not clear on this.&lt;/P&gt;
&lt;P&gt;The memory alloction profiling support in VSTS uses the profiler API provided by the&amp;nbsp;CLR.&amp;nbsp; This gives us a rich set of information that allows us to track the lifetimes of individual objects.&amp;nbsp; There is no such off-the-shelf support in native memory management, since there are nearly as many heap implementations as there are applications in the world.&lt;/P&gt;
&lt;P&gt;Memory allocation profiling is a much bigger deal for managed code, as the CLR has effectively turned what used to be a &lt;EM&gt;correctness&lt;/EM&gt; issue (leaks, double frees, etc) into &lt;EM&gt;performance&lt;/EM&gt; issues (excessive GCs and memory pressure)*.&amp;nbsp; This does not mean that some kind memory allocation profiling wouldn't benefit the world, but the combination of it being less important and more difficult keeps it out of the product for now.&lt;/P&gt;
&lt;P&gt;If you think you are facing memory issues in &lt;EM&gt;native&lt;/EM&gt; code, there&amp;nbsp;is at least one utility&amp;nbsp;I&amp;nbsp;can&amp;nbsp;offer up: In the server resource kits, the &lt;EM&gt;vadump&lt;/EM&gt; utility can give you information about your virtual address space, including memory allocated by VirtualAlloc.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.microsoft.com/downloads/details.aspx?FamilyID=9d467a69-57ff-4ae7-96ee-b18c4790cffd&amp;amp;DisplayLang=en" mce_href="http://www.microsoft.com/downloads/details.aspx?FamilyID=9d467a69-57ff-4ae7-96ee-b18c4790cffd&amp;amp;DisplayLang=en"&gt;http://www.microsoft.com/downloads/details.aspx?FamilyID=9d467a69-57ff-4ae7-96ee-b18c4790cffd&amp;amp;DisplayLang=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Unfortunately, this is a pale shadow (if that) of what you can get from the managed side.&lt;/P&gt;
&lt;P&gt;&lt;FONT size=1&gt;* The idea that &lt;EM&gt;correctness &lt;/EM&gt;issues become &lt;EM&gt;performance &lt;/EM&gt;issues as we develop more advanced runtimes was something I heard David Detlefs mention somewhere.&lt;/FONT&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1276194" width="1" height="1"&gt;</description></item><item><title>How to shoot yourself in the foot with const (or the lack thereof)</title><link>http://blogs.msdn.com/angryrichard/archive/2006/05/24/606225.aspx</link><pubDate>Wed, 24 May 2006 21:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:606225</guid><dc:creator>AngryRichard</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/angryrichard/comments/606225.aspx</comments><wfw:commentRss>http://blogs.msdn.com/angryrichard/commentrss.aspx?PostID=606225</wfw:commentRss><description>&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;It has long puzzled me why various Win32 functions take non-const string parameters, when clearly they have no business manipulating the string.&amp;nbsp; Take, for instance, GetNamedSecurityInfo:&lt;/FONT&gt;&lt;/P&gt;&lt;FONT face=Tahoma size=2&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;&lt;PRE class=syntax xml:space="preserve"&gt;&lt;B&gt;DWORD&lt;/B&gt; &lt;B&gt;GetNamedSecurityInfo(&lt;/B&gt;
  &lt;B&gt;LPTSTR&lt;/B&gt; &lt;A class=synParam onclick=showTip(this) href=""&gt;&lt;EM&gt;&lt;FONT color=#000000&gt;pObjectName&lt;/FONT&gt;&lt;/EM&gt;&lt;/A&gt;&lt;B&gt;&lt;/B&gt;&lt;B&gt;&lt;EM&gt;,&lt;/EM&gt;
&lt;/B&gt;  &lt;B&gt;SE_OBJECT_TYPE&lt;/B&gt; &lt;I&gt;&lt;A class=synParam onclick=showTip(this) href=""&gt;&lt;FONT color=#000000&gt;ObjectType&lt;/FONT&gt;&lt;/A&gt;&lt;/I&gt;&lt;B&gt;&lt;/B&gt;&lt;FONT color=#000000&gt;&lt;B&gt;,
&lt;/B&gt;  &lt;B&gt;SECURITY_INFORMATION&lt;/B&gt; &lt;I&gt;&lt;A class=synParam onclick=showTip(this) href=""&gt;&lt;FONT color=#000000&gt;SecurityInfo&lt;/FONT&gt;&lt;/A&gt;&lt;/I&gt;&lt;B&gt;&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#000000&gt;&lt;B&gt;,
&lt;/B&gt;  &lt;B&gt;PSID*&lt;/B&gt; &lt;I&gt;&lt;A class=synParam onclick=showTip(this) href=""&gt;&lt;FONT color=#000000&gt;ppsidOwner&lt;/FONT&gt;&lt;/A&gt;&lt;/I&gt;&lt;B&gt;&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#000000&gt;&lt;B&gt;,
&lt;/B&gt;  &lt;B&gt;PSID*&lt;/B&gt; &lt;I&gt;&lt;A class=synParam onclick=showTip(this) href=""&gt;&lt;FONT color=#000000&gt;ppsidGroup&lt;/FONT&gt;&lt;/A&gt;&lt;/I&gt;&lt;B&gt;&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#000000&gt;&lt;B&gt;,
&lt;/B&gt;  &lt;B&gt;PACL*&lt;/B&gt; &lt;I&gt;&lt;A class=synParam onclick=showTip(this) href=""&gt;&lt;FONT color=#000000&gt;ppDacl&lt;/FONT&gt;&lt;/A&gt;&lt;/I&gt;&lt;B&gt;&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#000000&gt;&lt;B&gt;,
&lt;/B&gt;  &lt;B&gt;PACL*&lt;/B&gt; &lt;I&gt;&lt;A class=synParam onclick=showTip(this) href=""&gt;&lt;FONT color=#000000&gt;ppSacl&lt;/FONT&gt;&lt;/A&gt;&lt;/I&gt;&lt;B&gt;&lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#000000&gt;&lt;B&gt;,
&lt;/B&gt;  &lt;B&gt;PSECURITY_DESCRIPTOR*&lt;/B&gt; &lt;I&gt;&lt;A class=synParam onclick=showTip(this) href=""&gt;&lt;FONT color=#000000&gt;ppSecurityDescriptor&lt;/FONT&gt;&lt;/A&gt;&lt;/I&gt;&lt;B&gt;&lt;/B&gt;&lt;/FONT&gt;&lt;B&gt;
&lt;/B&gt;&lt;B&gt;);&lt;/B&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;/FONT&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;I can't imagine why this function should ever need to write to pObjectName.&amp;nbsp; In fact, the SDK documentation explicitly lists it as an [in] parameter.&amp;nbsp; Also note that pObjectName is an LP&lt;STRONG&gt;T&lt;/STRONG&gt;STR.&amp;nbsp; This is important to the shooting of the foot.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;A tidy, const-aware&amp;nbsp;developer might want to do something like this:&lt;/FONT&gt;&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=1&gt;const LPWSTR SomeFile = L"\\somefile.txt";&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=1&gt;[...]&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=1&gt;GetNamedSecurityInfo(Somefile, ...)&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;Of course, this will fail to compile, because SomeFile is const.&amp;nbsp; But casting solves this problem, right?&amp;nbsp; &lt;/FONT&gt;&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;&lt;FONT face="Courier New" size=1&gt;GetNamedSecurityInfo((LPTSTR)Somefile, ...)&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;Yay, this compiles.&amp;nbsp; Why, it even appears to return the correct data.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;Fast forward a year or two, when suddenly the code stops working on Vista.&amp;nbsp; What could be wrong?&amp;nbsp; Why, in the process of casting away const, we've also turned an LP&lt;STRONG&gt;W&lt;/STRONG&gt;STR into an LP&lt;STRONG&gt;T&lt;/STRONG&gt;STR.&amp;nbsp; In this case, TCHAR resolved to char, so the code above was actually returning a security descriptor for "\\".&amp;nbsp; Well, that is until Vista came along.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;So while I hang my head in shame for being lame enough to cast between incompatible types, I will also caution the rest of you to consider whether your string parameters really need to be non-const, and avoid making your clients play casting games to use your API.&amp;nbsp; And yes, using &lt;A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccelng/htm/express_75.asp"&gt;const_cast&amp;lt;&amp;gt;&lt;/A&gt; might have prevented this issue, but I didn't know about it at the time.&amp;nbsp; You, having read this far, have no excuse.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=606225" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/angryrichard/archive/tags/Useless+rants/default.aspx">Useless rants</category></item><item><title>DataCollection at the Global Level</title><link>http://blogs.msdn.com/angryrichard/archive/2005/10/10/479252.aspx</link><pubDate>Mon, 10 Oct 2005 20:41:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:479252</guid><dc:creator>AngryRichard</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/angryrichard/comments/479252.aspx</comments><wfw:commentRss>http://blogs.msdn.com/angryrichard/commentrss.aspx?PostID=479252</wfw:commentRss><description>&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;If you are using the &lt;a href="http://blogs.msdn.com/angryrichard/archive/2005/01/16/354194.aspx"&gt;DataCollection API&lt;/A&gt; (either from native, by linking agains VSPerf.lib, or from managed, by importing Microsoft.VisualStudio.Profiler.dll), and wish to enable or disable collection at the &lt;EM&gt;global&lt;/EM&gt; level, you must pass CurrentId for the elementId parameter:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" color=#000000 size=2&gt;&lt;STRONG&gt;&amp;nbsp; using Microsoft.VisualStudio.Profiler;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" color=#000000 size=2&gt;&lt;EM&gt;&amp;nbsp; [Not so interesting code here]&amp;nbsp;&amp;nbsp;&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" color=#000000 size=2&gt;&lt;STRONG&gt;&amp;nbsp; DataCollection.StartProfile(&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ProfileLevel.Global, &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DataCollection.CurrentId);&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" color=#000000 size=2&gt;&lt;EM&gt;&amp;nbsp; [Interesting code here]&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;Similarly, for native code:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;&lt;STRONG&gt;&amp;nbsp; #include "VSPerf.h"&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;&lt;EM&gt;&amp;nbsp; [Not so interesting code here]&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;&lt;STRONG&gt;&amp;nbsp; StartProfile(PROFILE_GLOBALLEVEL, PROFILE_CURRENTID);&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;&lt;EM&gt;&amp;nbsp; [Interesting code here]&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;Note that both the native and managed versions return zero on success, so it is possible to detect whether the call succeeded:&lt;/FONT&gt;&lt;/P&gt;
&lt;TABLE&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;FONT face="Courier New" size=2&gt;C#&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;FONT face="Courier New" size=2&gt;c++&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;FONT face="Courier New" size=2&gt;Description&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;FONT face="Courier New" size=2&gt;ProfileOperationResult.ErrorNotYetImplemented&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;FONT face="Courier New" size=2&gt;PROFILE_ERROR_NOT_YET_IMPLEMENTED&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;FONT face="Courier New" size=2&gt;API level, id combination not supported&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;FONT face="Courier New" size=2&gt;ProfileOperationResult.ErrorModeNever&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;FONT face="Courier New" size=2&gt;PROFILE_ERROR_MODE_NEVER&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;FONT face="Courier New" size=2&gt;Global mode was "never" when called&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;FONT face="Courier New" size=2&gt;ProfileOperationResult.ErrorLevelDoesNotExist&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;FONT face="Courier New" size=2&gt;PROFILE_ERROR_LEVEL_NOEXIST&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;FONT face="Courier New" size=2&gt;Profile level does not exist&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;FONT face="Courier New" size=2&gt;ProfileOperationResult.ErrorIdDoesNotExist&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;FONT face="Courier New" size=2&gt;PROFILE_ERROR_ID_NOEXIST&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;FONT face="Courier New" size=2&gt;Element id doesn't exist&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=479252" width="1" height="1"&gt;</description></item><item><title>Response Files</title><link>http://blogs.msdn.com/angryrichard/archive/2005/08/07/448841.aspx</link><pubDate>Mon, 08 Aug 2005 05:12:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:448841</guid><dc:creator>AngryRichard</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/angryrichard/comments/448841.aspx</comments><wfw:commentRss>http://blogs.msdn.com/angryrichard/commentrss.aspx?PostID=448841</wfw:commentRss><description>&lt;P&gt;On the forums, someone was using the /INCLUDE option in VsInstr.exe.&amp;nbsp; It is possible to use multiple instances of this option to include different sets of functions.&amp;nbsp; For a big chunk of functions, you might want to use dozens of function specifications.&amp;nbsp; Who the heck wants to do all that typing?&amp;nbsp; You could make a batch file, but a response file would be better.&lt;/P&gt;
&lt;P&gt;Response files are text files where each line in the file is a single command line option.&amp;nbsp; Since each line holds exactly one option, quotes are not necessary.&amp;nbsp; They are much easier to edit than a batch file (which would have single, really long line).&amp;nbsp; To use a response file, simply use @filename on the command line of the tool.&amp;nbsp; For example:&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;VsPerfCmd /start:sample "/output:c:\Documents and Settings\AngryRichard\foo.vsp" "/user:NETWORK SERVICE"&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;can be turned into a response file like this:&lt;/P&gt;
&lt;P&gt;Startup.rsp:&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;/start:sample&lt;BR&gt;/output:c:\Documents and Settings\AngryRichard\foo.vsp&lt;BR&gt;/user:NETWORK SERVICE&lt;BR&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;VsPerfCmd @Startup.rsp&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;All of the command line tools for the profiler accept response files.&amp;nbsp; It beats all that error prone typing, and if you run scenarios from the command line a lot, it can pay to have some response files laying about for common scenarios.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=448841" width="1" height="1"&gt;</description></item><item><title>Off-road Profiling Windows Services</title><link>http://blogs.msdn.com/angryrichard/archive/2005/07/28/444593.aspx</link><pubDate>Thu, 28 Jul 2005 22:36:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:444593</guid><dc:creator>AngryRichard</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/angryrichard/comments/444593.aspx</comments><wfw:commentRss>http://blogs.msdn.com/angryrichard/commentrss.aspx?PostID=444593</wfw:commentRss><description>&lt;P&gt;&lt;FONT face=Garamond&gt;I've just posted an article on the pitfalls of profiling services with the Visual Studio profiler.&amp;nbsp; It includes a sample service with a quick walkthrough.&amp;nbsp; Enjoy.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;&lt;a href="http://blogs.msdn.com/angryrichard/articles/Profiling_Windows_Services.aspx"&gt;&lt;FONT face=Garamond&gt;Profiling Windows™ Services with the Visual Studio Profiler&lt;/FONT&gt;&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=444593" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/angryrichard/archive/tags/Profiling/default.aspx">Profiling</category></item><item><title>Limiting the Data Crunch from Trace Profiling</title><link>http://blogs.msdn.com/angryrichard/archive/2005/01/16/354194.aspx</link><pubDate>Mon, 17 Jan 2005 03:41:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:354194</guid><dc:creator>AngryRichard</dc:creator><slash:comments>7</slash:comments><comments>http://blogs.msdn.com/angryrichard/comments/354194.aspx</comments><wfw:commentRss>http://blogs.msdn.com/angryrichard/commentrss.aspx?PostID=354194</wfw:commentRss><description>&lt;p&gt;&lt;font face="Arial" size="2"&gt;Typically, one can use the sampling profiler to nail down the hot spot in an application.&amp;nbsp; Having done that, what does one do when the sampling data doesn't provide enough information?&amp;nbsp; The trace profiler can offer up more detail, particularly if the issue revolves around thread interaction.&amp;nbsp; However, if you profile a heavily CPU bound application, you may find that you are getting huge trace files, or that the profiler is significantly impacting the performance of your application.&amp;nbsp; The VisualStudio profiler offers a mechanism to stem the avalanche of data.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Arial" size="2"&gt;I'll illustrate the general idea with an example.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Arial" size="2"&gt;Suppose we'd like to run trace profiling on the following highly useful piece of code.&amp;nbsp; We've decided that we only care about profiling in the context of the function "OnlyProfileThis()"&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Arial" size="2"&gt; &lt;hr id="null" /&gt; &lt;/font&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" size="2"&gt;using System;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" size="2"&gt;public class A&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;private int _x;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;public A(int x)&lt;br /&gt;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;_x = x;&lt;br /&gt;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;public int DoNotProfileThis()&lt;br /&gt;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;return _x * _x;&lt;br /&gt;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;public int OnlyProfileThis()&lt;br /&gt;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;return _x + _x;&lt;br /&gt;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;public static void Main()&lt;br /&gt;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;A a;&lt;br /&gt;&amp;nbsp;&amp;nbsp;a = new A(2);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;Console.WriteLine("2 square is {0}", a.DoNotProfileThis());&lt;br /&gt;&amp;nbsp;&amp;nbsp;Console.WriteLine("2 doubled is {0}", a.OnlyProfileThis());&lt;br /&gt;&amp;nbsp;}&lt;br /&gt;}&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Arial" size="2"&gt; &lt;hr id="null" /&gt; &lt;/font&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Arial" size="2"&gt;The VisualStudio profiler provides an API for controlling data collection from within the application.&amp;nbsp; For native code, this API lives in VSPerf.dll.&amp;nbsp; A header (VSPerf.h) and import library (VSPerf.lib) provided in the default Team Developer install allows us to use the profiler control API from native code.&amp;nbsp; For managed code, this API is wrapped by the DataCollection class in Microsoft.VisualStudio.Profiler.dll.&amp;nbsp; We can update the example to the following to control the profiler during our run:&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Arial" size="2"&gt; &lt;hr id="null" /&gt; &lt;/font&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" size="2"&gt;using System;&lt;br /&gt;&lt;strong&gt;&lt;font color="#ff0000"&gt;using Microsoft.VisualStudio.Profiler;&lt;/font&gt;&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" size="2"&gt;public class A&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;private int _x;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;public A(int x)&lt;br /&gt;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;_x = x;&lt;br /&gt;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;public int DoNotProfileThis()&lt;br /&gt;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;return _x * _x;&lt;br /&gt;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;public int OnlyProfileThis()&lt;br /&gt;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;return _x + _x;&lt;br /&gt;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;public static void Main()&lt;br /&gt;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;A a;&lt;br /&gt;&amp;nbsp;&amp;nbsp;a = new A(2);&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp;int x;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;Console.WriteLine("2 square is {0}", a.DoNotProfileThis());&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" color="#ff0000" size="2"&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;DataCollection.StartProfile(&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DataCollection.ProfileLevel.DC_LEVEL_GLOBAL, &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DataCollection.PROFILE_CURRENTID);&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp;x = a.OnlyProfileThis();&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" color="#ff0000" size="2"&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;DataCollection.StopProfile(&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DataCollection.ProfileLevel.DC_LEVEL_GLOBAL, &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DataCollection.PROFILE_CURRENTID);&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp;Console.WriteLine("2 doubled is {0}", x);&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" size="2"&gt;&amp;nbsp;}&lt;br /&gt;}&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Arial" size="2"&gt; &lt;hr id="null" /&gt; We still need to instrument the application as normal.&amp;nbsp; We also have one additional step.&amp;nbsp; When running the code above, data collection will be enabled by default, so the API won't appear to do anything beyond stopping data collection after the call to OnlyProfileThis.&amp;nbsp; We need to disable data collection before running the application.&amp;nbsp; The profiler control tool,&lt;br /&gt;VSPerfCmd, has options to do this.&lt;/font&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Arial" size="2"&gt;To run this scenario from the command line:&lt;/font&gt;&lt;/p&gt; &lt;blockquote dir="ltr" style="MARGIN-RIGHT: 0px"&gt; &lt;p&gt;&lt;font face="Courier New" size="2"&gt;csc /debug- /r:Microsoft.VisualStudio.Profiler.dll Sample.cs&lt;br /&gt;VSInstr Sample.exe&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" size="2"&gt;VSPerfCmd /start:trace /output:SampleTrace.VSP&lt;br /&gt;VSPerfCmd /globaloff&lt;br /&gt;Sample.exe&lt;br /&gt;VSPerfCmd /shutdown&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" size="2"&gt;VSPerfReport /calltrace SampleTrace.VSP&lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt; &lt;hr id="null" /&gt; &lt;font face="Arial" size="2"&gt;There are several control functions in the DataCollection class.&amp;nbsp; Here is a brief rundown.&lt;/font&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" size="2"&gt;StartProfile(ProfileLevel level, UInt32 id)&lt;br /&gt;StopProfile(ProfileLevel level, UInt32 id)&lt;/font&gt;&lt;/p&gt; &lt;blockquote dir="ltr" style="MARGIN-RIGHT: 0px"&gt; &lt;p&gt;&lt;font face="Arial" size="2"&gt;This unconditionally starts or stops profiling.&amp;nbsp; The level parameter indicates whether profiling should be stopped for the current thread, process, or globally.&amp;nbsp; For thread and process level changes, the id specifies thread id or process id to control (respectively), or PROFILE_CURRENTID to control the current thread or process.&lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;&lt;font face="Courier New" size="2"&gt;SuspendProfile(ProfileLevel level, UInt32 id)&lt;br /&gt;ResumeProfile(ProfileLevel level, UInt32 id)&lt;/font&gt;&lt;/p&gt; &lt;blockquote dir="ltr" style="MARGIN-RIGHT: 0px"&gt; &lt;p&gt;&lt;font face="Arial" size="2"&gt;This works very much like StartProfile and StopProfile, however, calls to these functions are reference counted.&amp;nbsp; If you call SuspendProfile twice, you must call ResumeProfile twice to enable profiling.&lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;p dir="ltr"&gt;&lt;font face="Arial" size="2"&gt;&lt;font face="Courier New"&gt;MarkProfile(Int32 markId)&lt;br /&gt;CommentMarkProfile(Int32 markId, String comment)&lt;br /&gt;CommentMarkAtProfile(Int64 timeStamp, Int32 markId, String comment)&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;blockquote dir="ltr" style="MARGIN-RIGHT: 0px"&gt; &lt;p dir="ltr"&gt;&lt;font face="Arial" size="2"&gt;Inserts a 32-bit data value into the collection stream.&amp;nbsp; Optionally, you can include a comment.&amp;nbsp; With the last function, the mark can be inserted at a specific time stamp.&amp;nbsp; The id value and the optional comment will appear in the CallTrace report.&lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;&lt;font face="Arial" size="2"&gt; &lt;hr id="null" /&gt; The profiler control tool provides similar functionality through a command line interface, though the notion of a "current" process or thread id is obviously not relevant.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" size="2"&gt;VSPerfCmd /?&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" size="2"&gt;[...]&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" size="2"&gt;-GLOBALON&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Sets the global Start/Stop count to one (starts profiling).&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" size="2"&gt;-GLOBALOFF&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Sets the global Start/Stop count to zero (stops profiling).&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" size="2"&gt;-PROCESSON:pid&amp;nbsp; Sets the Start/Stop count to one for the given process.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" size="2"&gt;-PROCESSOFF:pid Sets the Start/Stop count to zero for the given process.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" size="2"&gt;-THREADON:tid&amp;nbsp;&amp;nbsp; Sets the Start/Stop count to one for the given thread.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Valid only in TRACE mode.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Courier New" size="2"&gt;-THREADOFF:tid&amp;nbsp; Sets the Start/Stop count to zero for the given thread.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Valid only in TRACE mode.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Arial" size="2"&gt;&lt;font face="Courier New"&gt;-MARK:marknum[,marktext]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Inserts a mark into the global event stream, with&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; optional text.&lt;br /&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;[...]&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Arial" size="2"&gt; &lt;hr id="null" /&gt; &lt;/font&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Arial" size="2"&gt;If you find yourself buried under a ton of trace data, investigate the profiling API to help focus on the important parts of your application.&lt;br /&gt;&lt;/font&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=354194" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/angryrichard/archive/tags/Profiling/default.aspx">Profiling</category></item><item><title>Trying out the profiler on the VPC</title><link>http://blogs.msdn.com/angryrichard/archive/2004/08/06/210178.aspx</link><pubDate>Fri, 06 Aug 2004 21:19:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:210178</guid><dc:creator>AngryRichard</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/angryrichard/comments/210178.aspx</comments><wfw:commentRss>http://blogs.msdn.com/angryrichard/commentrss.aspx?PostID=210178</wfw:commentRss><description>&lt;P&gt;&lt;FONT face=Arial size=2&gt;I've frequently heard the question asked, "Can I use the profiler on a Virtual PC?"&amp;nbsp; It has even come up on the blog feedback a few times.&amp;nbsp; My answer has always been, "Theoretically, yes."&amp;nbsp; I didn't want to post this answer externally until I'd actually gotten around to trying it myself.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial size=2&gt;I've finally been nagged into it.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial size=2&gt;In my limited experience with our VirtualPC product, it has quite impressed me with its functionality.&amp;nbsp; However, it does not emulate the hardware performance counters upon which the profiler implicitly depends.&amp;nbsp; For this reason, you &lt;EM&gt;can not&lt;/EM&gt; run the sampling profiler using a performance counter based interrupt.&amp;nbsp; My collegue Ishai&amp;nbsp;pointed out&lt;SUP&gt;*&lt;/SUP&gt; that you should be able to use page-fault or system-call based sampling, but the VPC has a different problem with these modes that is still under investigation.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial size=2&gt;Instrumentation based profiling &lt;EM&gt;will&lt;/EM&gt; work on the VPC.&amp;nbsp; However, as I've already mentioned, there is a bug check issue with the driver when it unloads.&amp;nbsp; Fortunately, instrumentation based profiling doesn't rely on the presence of the driver.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial size=2&gt;By renaming the driver to prevent the profiling monitor from installing it at startup, I was able to use instrumentation based profiling on the VPC.&amp;nbsp; This is obviously just a workaround,&amp;nbsp; but I hope this will allow you to investigate some of our tools in the comfort of a VirtualPC environment.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial size=2&gt;Here is how you can prevent the driver from loading on your VPC installation.&lt;/FONT&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;FONT face=Arial size=2&gt;Use regedit to delete the key HKLM\CurrentControlSet\Services\VSPerfDrv.&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT face=Arial size=2&gt;Find C:\Program Files\Microsoft Visual Studio\Enterprise Developer Tools\Performance Tools\VSPerfDrv.sys, and rename&amp;nbsp;it to something silly like __VSPerfDrv.sys__, or delete it.&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT face=Arial size=2&gt;Reboot your VPC to ensure that the driver isn't installed&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;FONT face=Arial size=2&gt;Happy hunting!&lt;BR&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial size=2&gt;&lt;SUP&gt;*&amp;nbsp;&lt;/SUP&gt;&lt;FONT size=1&gt;I'm pretty sure Ishai was hired to point out things I do wrong.&amp;nbsp;&amp;nbsp;Fortunately, he usually points out solutions as well.&lt;/FONT&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=210178" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/angryrichard/archive/tags/Profiling/default.aspx">Profiling</category></item><item><title>VPC and the BSOD (part 2)</title><link>http://blogs.msdn.com/angryrichard/archive/2004/06/03/148123.aspx</link><pubDate>Fri, 04 Jun 2004 03:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:148123</guid><dc:creator>AngryRichard</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/angryrichard/comments/148123.aspx</comments><wfw:commentRss>http://blogs.msdn.com/angryrichard/commentrss.aspx?PostID=148123</wfw:commentRss><description>&lt;P&gt;&lt;FONT face=Arial size=2&gt;I had a nice long email chat with members of the Virtual PC team.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial size=2&gt;The good news:&amp;nbsp; The Virtual PC emulates the host processor well enough that&amp;nbsp;our kernel-mode&amp;nbsp;driver can detect what features are enabled.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial size=2&gt;The bad news:&amp;nbsp; The Virtual PC does not emulate an APIC or performance counters.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial size=2&gt;So, if you were planning on running the profiler inside a Virtual PC, the best you can hope to do is get function trace data on an instrumented app.&amp;nbsp; Sampling will not work at all, and collecting perfomance counter data in the instrumentation will fault the application.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial size=2&gt;Bummer.&amp;nbsp; I wish I had better news.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=148123" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/angryrichard/archive/tags/Profiling/default.aspx">Profiling</category></item><item><title>VPC and the BSOD</title><link>http://blogs.msdn.com/angryrichard/archive/2004/06/01/146280.aspx</link><pubDate>Wed, 02 Jun 2004 03:14:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:146280</guid><dc:creator>AngryRichard</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/angryrichard/comments/146280.aspx</comments><wfw:commentRss>http://blogs.msdn.com/angryrichard/commentrss.aspx?PostID=146280</wfw:commentRss><description>&lt;P&gt;&lt;FONT face=Arial size=2&gt;I'm so pleased.&amp;nbsp; Someone did something exciting and dangerous with the profiler.&amp;nbsp; In case you're not reading the newsgroups, an intrepid customer tried to profile on a &lt;A href="http://www.microsoft.com/windowsxp/virtualpc/"&gt;Virtual PC&lt;/A&gt;, and discovered that it only leads to pain and misery via the BSOD.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial size=2&gt;So don't do that.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial size=2&gt;Seriously, is this something people want to do?&amp;nbsp; I mean, VPC is about &lt;EM&gt;the coolest thing ever&lt;/EM&gt;, but we do use hardware performance counters by default, and VPC is not exactly a real life environment for performance analysis and measurement.&amp;nbsp; Still, maybe y'all have good reasons for this.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial size=2&gt;At the very least, we'll fix that BSOD thing.&amp;nbsp; I mean, how 1990's is that?&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial size=2&gt;This is an excellent time to point out that the profiler does in fact install a kernel-mode device driver in order to play with the hardware counters on your Intel and AMD processors.&amp;nbsp; There are some fun implications from this:&lt;/FONT&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;FONT face=Arial size=2&gt;You need to be running as a user who can &lt;EM&gt;install&lt;/EM&gt; a kernel-mode device driver.&amp;nbsp; We currently install the driver dynamically when starting the profiling monitor, and we uninstall it when the monitor shuts down.&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT face=Arial size=2&gt;The kernel-mode device driver is not &lt;A href="http://www.microsoft.com/whdc/winlogo/drvsign/digitsign.mspx"&gt;signed&lt;/A&gt;.&amp;nbsp; If you're one of those cheeky folks who has unsigned drivers shimmed through &lt;A href="http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/q244/6/17.asp&amp;amp;NoWebContent=1"&gt;verifier&lt;/A&gt;, you may discover the joy of a &lt;EM&gt;forced&lt;/EM&gt; BSOD if you exercise the profiler in new interesting ways we hadn't thought of.&amp;nbsp; This is not all bad; just make sure you send us the &lt;A href="http://oca.microsoft.com/en/dcp20.asp"&gt;error report&lt;/A&gt; after you've rebooted.&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT face=Arial size=2&gt;If you're running on Intel Pentium I&amp;nbsp;or&amp;nbsp;AMD K6* (or anything older), expect no love from the sampling based profiler, and some uphill battles with instrumentation.&amp;nbsp; I may post hints on this latter point if a few people speak up about legacy hardware.&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=146280" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/angryrichard/archive/tags/Profiling/default.aspx">Profiling</category></item><item><title>C'mon, all your Friends are Doing it</title><link>http://blogs.msdn.com/angryrichard/archive/2004/05/27/143376.aspx</link><pubDate>Thu, 27 May 2004 22:15:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:143376</guid><dc:creator>AngryRichard</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/angryrichard/comments/143376.aspx</comments><wfw:commentRss>http://blogs.msdn.com/angryrichard/commentrss.aspx?PostID=143376</wfw:commentRss><description>&lt;P&gt;A bunch of the guys on the &lt;A href="http://blogs.msdn.com/profiler"&gt;team&lt;/A&gt; I work for have been starting up blogs.&amp;nbsp; I started feeling left out, &lt;BR&gt;which made me very angry.&lt;/P&gt;
&lt;P&gt;It appears all blogs start with "Hi, I'm a developer who does X and I'm going to talk about Y and maybe Z."&lt;BR&gt;It's all part of Microsoft's new image -- we're transparent now.&lt;/P&gt;
&lt;P&gt;Transparency's good, right?&lt;/P&gt;
&lt;P&gt;Go down to your local German car dealer, or, if you own a newer German car, go out to your driveway.&amp;nbsp; Shiny, pretty, isn't it?&amp;nbsp; Open the hood.&amp;nbsp; Look at that -- a big, fat, intake pipe that goes into a big box that says "BMW" in a 4" Century Gothic font.&amp;nbsp; Cool.&amp;nbsp; Now pop that plastic thing off the top.&amp;nbsp; Go ahead, I dare you.&amp;nbsp; Not so pretty now.&amp;nbsp; Look at all those wires and tubes.&amp;nbsp; Look at all that stuff you could cut yourself on.&amp;nbsp; That's why that plastic thing is there; it makes owning all that power a little less scary.&lt;/P&gt;
&lt;P&gt;Some of us spend all our time under the shiny plastic thing, hands full of wires and tubes and spark plugs.&amp;nbsp; That'd be me and some of my less 'transparent' friends, working on the instrumentation and data collection engine in the profiler.&lt;/P&gt;
&lt;P&gt;Of course, with great power, comes great potential for disaster.&amp;nbsp; Some day you'll have your turn with the profiler.&amp;nbsp; Trust me, something's always too slow.&amp;nbsp; If it works, great.&amp;nbsp; If you find yourself upside down in a ditch, tell us, we want to know where we need to cover up the sharp edges.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=143376" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/angryrichard/archive/tags/Profiling/default.aspx">Profiling</category><category domain="http://blogs.msdn.com/angryrichard/archive/tags/Useless+rants/default.aspx">Useless rants</category></item></channel></rss>