Author Archives: Tobint

Improving code performance

Recently, an old co-worker contacted me to ask me a question about code performance. Specifically, he was emitting IL from his code and had some questions about some of the opcode usage he witnessed when viewing the IL of some compiled assemblies.  The question was based on a simple application he wrote in C#, compiled, and disassembled.  He did this to see how the C# compiler produced IL and give him clues in how he should emit IL.  The function in question was as follows:


public object GetProp(string name)
{   if (name == “X”
   {    return this.X;
   }
   return null;
}

Now, the code obviously isn’t meant to do anything other than lend some insight into the IL.  Compiling to ‘debug’ the following IL was produced.

.method public hidebysig instance object
        GetProp(string name) cil managed
{
// Code size       35 (0x23)
.maxstack  2
.locals init ([0] object CS$1$0000,
          [1] bool CS$4$0001)
IL_0000:  nop
IL_0001:  ldarg.1
IL_0002:  ldstr      “X”
IL_0007:  call       bool [mscorlib]System.String::op_Equality(string, string)
IL_000c:  ldc.i4.0
IL_000d:  ceq
IL_000f:  stloc.1
IL_0010:  ldloc.1
IL_0011:  brtrue.s   IL_001d
IL_0013:  nop
IL_0014:  ldarg.0
IL_0015:  call       instance string class TestApp.TClass`1::get_X()
IL_001a:  stloc.0
IL_001b:  br.s       IL_0021
IL_001d:  ldnull
IL_001e:  stloc.0
IL_001f:  br.s       IL_0021
IL_0021:  ldloc.0
IL_0022:  ret
} // end of method TClass`1::GetProp

The question was, why was the stloc.1 and ldloc.1 needed after the ceq instruction at IL_000d (there are actually other issues in this small snippet, but I’ll focus on this particular one) . I, too, tried to resolve the issue and batted a few guesses around.  I proffered two ideas, and then ultimately suggested that the JIT compiler would likely be modifying this code anyway (particularly once it was recompiled in ‘release’ with optimization).

Still curious as to why the compiler produced the stloc and ldloc opcodes, I asked around internally until Vance set me straight with this blog post.

Introduction: What does ‘foreach’ actually do?
http://blogs.msdn.com/vancem/archive/2006/02/20/535807.aspx


Essentially, he states what I initially felt — that the JIT transformations on the IL are so dramatic, that you cannot judge an application’s performance based on the IL.  He also gives some great information on how to view your JITed code — with release optimizations and everything.  The other side to this is, that after further review, the inefficiencies of the IL were fixed in the optimized IL anyway once the code was set to ‘release’. 

Sometimes, it’s really easy to get side-tracked by these discussions in your quest for software glory.  I’m glad to know we have people like Vance around to set me straight when I do.


IIS 7 on a MacBook !

The IIS 7 Commander-in-chief, Bill Staples , has just released a screenshot of his new 17″ MacBook running IIS 7!  I simply must get one now!

Beta 2 Live – IIS.NET now open!

Now that Beta 2 has been announced and IIS 7 is now publicly available to beta testers on both the Vista and Longhorn platforms, our new portal, IIS.NET is now open and live!  Many long hours were spent on this by some great guys here at Microsoft.  Be sure to stop by and tell them what you think of the site!

IIS 7.0 UE team is hiring!

We’re hiring!  Take a look at the details below

“Do you love Internet and Web server technologies? Join the IIS UE team and work on the coolest version of Internet Information Services (IIS) ever. IIS 7.0 joins forces with ASP.NET to deliver a Web application development platform that’s getting rave reviews from customers.

We’re looking for a programmer writer to define and deliver essential developer-focused, solution-based documentation for a programming audience. Your responsibilities will include writing API reference topics, conceptual topics about IIS, and code examples that demonstrate product features. You’ll be responsible for multiple feature areas, so good organizational skills and the ability to prioritize your workload are a must.”


(continue)

Online Training: Beginners Guide to VB.NET

Microsoft Learning has put together a great series of training courses which are available now at a substantial discount.  Take advantage of the deal while it lasts (sale ends June 30th)!

https://www.microsoftelearning.com/visualstudio2005/#upgradingfromVB60

Also, don’t forget to check out the free training videos for VB.NET Express Edition. They provide a great starting point for anyone looking to break into the Visual Basic .NET market.

http://msdn.microsoft.com/vstudio/express/vb/learning/

What technology actually improves your life?

Nearly a year ago, I blogged about the fact that I had no “cool” technologies in my house.  I didn’t own a single gadget that anyone would consider to be “up to date” by any standard. I didn’t own a PDA, a laptop, or even a modern cell-phone.  I didn’t have flat-panel monitors or anything other than a standard 27″ television — with a broken power button at that.  I had several computers in the house, but all of them were at least a year and a half old. 

I decided after posting that complaint that things were going to change.  I released my death grip on my cash that I had been hording and sprung for a new, improved, gadget-savvy image.

Flash forward to today — 11 months after that post.  As I got ready to head into work, I closed up my 17″ widescreen HP media center ready laptop and turned off my HP printer/copier/fax.  I packed up my Gateway Tablet PC and shoved it into my Microsoft backpack along with my 60GB video iPod, assorted USB flashdrives, bluetooth adapters, folding headphones, and the like.  I strapped my 8.1 MegaPixel Nikon digital camera and Audiovox Smart Phone to my belt.  I put my Motorola bluetooth hands-free headset on my ear.  I walked into the living room and turned off my 50″ Plasma TV and shoved the wireless controllers for my Xbox 360 under the TV stand.  I walked out to my car and looked at the windshield cluttered with an XM SkyFi2 satelite radio, a Sirius satelite radio, and a Microsoft Streets and Trips GPS device.  Now, I say all of this to point out that I’ve gone from one extreme to another and at no small expense.  I sometimes wonder if I should have just hung onto my cash, but in other instances, I really enjoy my products.

I asked myself as I traveled to work this morning “Have I gotten my money’s worth out of these devices? Have they made my life better — or just more expensive?”  It seems that many of today’s top technological gadgets are great at overcoming technological problems, but do they really enrich our lives?  My Smartphone is one device that I just couldn’t live without.  I keep track of my appointments, birthdays, phone numbers and so much more on that little thing.  I also keep a copy of Microsoft Pocket Streets and Trips on there — which is a great little tool for getting around.  There is no question that this device makes my life easier in today’s society that requires that I know how to contact any number of people, keep track of appointments and schedules that change every hour, or keep me up to date with birthdays of family members all the way on the other side of the country.  My camera is great. Photos are so hard for me to keep track of.  I keep a few but they are usually buried in boxes that I have to dig for if I want to view them again.  I can snap pictures of the mountains out here in the Pacific Northwest and immediately send them to my parents.  The camera is a great addition to my “technical family.” That said — there are other devices that just seem to be excessive (Who needs XM and Sirius and an iPod?  Could I do without them? Most likely.)

I could go on and on talking about my devices.  Instead, I’d like to hear from you.  What technologies have made your life better?  These could be services, pieces of hardware, or even websites in general.  I want to know what technologies make a difference in your everyday life and what technologies have you invested your hard-earned money into that haven’t been worth it.

Snagged from Sahil: Bad programmer diseases

Sahil has once again shown true insight and provided a list of common diseases found in our industry. Do you have any of these symptoms?


http://codebetter.com/blogs/sahil.malik/archive/2006/05/03/64255.aspx

Mort, Elvis and Einstein don’t exist

Much has been said about the Mort, Elvis and Einstein controversy over the past few years (yes, years).  The past few days have been no exception.  One of our MVPs is apparently upset about them, and apparently some employees are not too happy about it either.  I’ve waited several days to comment until the screaming stopped.  Now that it has, it’s my turn to weigh in.  Most of this content about this topic is completely off-base and unfounded.  “Why?”, you might ask.  That’s because Mort, Elvis, and Einstein don’t exist.  That’s right, there is no one person on this planet that is meant to be exhibited by these personas.  The names depicted here are meant to represent behaviors — not people.  Trying to pigeon-hole people into one of these areas is just a misrepresentation of what the persona was meant to portray. 

Mort is not a VB developer, Elvis is not a C# developer, and Einstein is not a C++ developer.  Sure, the personas use these analogies because they do fairly closely resemble a large stereotypical audience, but it doesn’t “fit” to anyone. Then again, no description fits more than one developer.  These personas don’t drive features and they don’t do anything but serve as reminders that we have different types of developers who need different types of features, documentation, and applications.  Don’t think this is true?  Ask the average VB developer what a thread is and they may get the “word for word” answer, but a large part of that audience never has wanted to understand the intricate details of thread local storage, differences between the stack and the heap and why those are important in the context of application development.  Does that mean that all VB developers don’t care about threading? NO. Once again, there is plenty of evidence that einsteins exist in the VB community as well  — “Einsteins” meaning people who want detail!  Mort behaviors exist in the C++ community as well. I’m one of the people have have a mort mentality with C++. I know so little about C++ I’m amazed I’m allowed to breath the same air as the folks here at Microsoft.  That, indeed, is the Mort side of me.

Several people have asked “Why are there no definitions for these from Microsoft.” And they are hopping mad about it!  Quite frankly, its because the personas were not meant to be public information.  They were used to help mold and categorize functionality internally, and nothing more.  Because of that, the actual documents for these personas are not available externally.   If they were, they would also likely be taken out of context.

That said, this won’t be the last discussion about these fictional characters.  I imagine we’ll be hearing about them for some time.  Just remember to take everything you hear with a grain of salt, and if you think the way we construct software is wrong, by all means RESPOND!  Speak up, tell us how you would approach it. Better yet, apply to the team that interests you most and come implement those changes yourself! 

Free Training CDs from AppDev

AppDev is apparently giving away free training CDs.  I have not personally seen the training, but free is not typically a trait in a product that I hate, so AppDev already “has me at hello” with this offer!
http://www.appdev.com/promo.asp?page=SN00009

What’s wrong with MSDN documentation?

A large part of my job at Microsoft is to provide developers with the knowledge they need to make use of the IIS 7.0 SDK.  While the information about IIS 7.0 is not out yet for review, there are plenty of docs provided in other areas, such as the .NET Framework SDK and ASP.NET sections, which can be used as a benchmark.   In order to make the IIS 7.0 SDK a success, we must do more than just put out a good product. We must also describe how to use it properly or it just will not be used.  So I pose a question to anyone who has ever looked something up in MSDN, what is wrong with the documentation you have used so far?  What is good about it?  What would you like to see to a greater/lesser extent in our documentation?   Feel free to flame us, or praise us.  If you have suggestions, comments, or ideas, feel free to express them here.

Your feedback will help me understand how to increase your satisfaction with MSDN and Microsoft in general.

Or better yet, if you have some desire to play with new technology that isn’t documented yet and provide that content to a worldwide audience, why not apply