Scott on Writing

Musings on technical writing...

A .NET Performance Challenge

Every Wednesday I email out the latest article on 4Guys (usually an ASP.NET piece) to those who have signed up for the WebWeekly newsletter.  Last week's article was titled Creating XML Documents with the XmlTextWriter Class, and looked at using XmlTextWriter to create XML documents.  (You can see a live demo of the XmlTextWriter in use here.)  Anywho, after the email went out I got an email from Michael Balloni, the lead software engineer at Steamload

Streamload is a heavily trafficked Web site that acts as a place for users to store digital content.  Users can upload files to Streamload's computers and then download the files or email their files to other Streamload users.  To put it mildly, there's a lot of 1s and 0s flying through those pipes leading into Streamload.  Since Streamload is located here in sunny San Diego, I've had the opportunity to meet with Michael on more than one occasion.  He's showed me around and shown me the code and architecture behind Streamload.  Currently, Streamload is still a classic ASP shop.  Michael has a rich and efficient architecture built up using classic ASP and VB and C++ COM components that emphasizes efficiency over “the latest technology.”  (By the way, Michael has written some articles and user tips on 4Guys...)

Anyway, with that background on Michael and Streamload, you might not be surprised to find out that after reading my article on the XmlTextWriter class, Michael emailed me asking about the performance of XmlTextWriter in comparison to his lightweight XML creating VB6 COM object.  His precise comments:

I reckon if you do a straight port to your bloated/overwrought object mess (.NET) that the code won't fare too well...but I also reckon you're crafty enough to rewrite the code to be at least as fast as my VB6 code.  I should certainly hope so, don't you think?

A challenge?  :-)  Unfortunately, my free time is less than ample as of late, so I decided rather than to take this challenge upon myself, I'd offer it up to the ASP.NET/.NET community at large: can you use .NET to beat Michael's implementation?  You can get your hands on Michael's VB6 component here.  Michael's challenge stands as follows:

Write .NET code to beat my XmlEncode function's "Test Encoding" performance, and use whatever .NET/ASPX method to beat the "Test Throughput" performance (maybe XmlTextWriter will work?)  And man, if nobody can do that, jeez.

Anyone up for the challenge?


Personally, I would wager that Michael will win the challenge.  Consider, for a moment, this article: XSLT Performance in .NET.  In this article author Dan Frumin examines the performance of the MSXML COM component vs. the XslTransform class for performing XSLT transformations.  The only speed advantage XslTransform provides is in creation of the object - there is a significant overhead in initializing the COM component in a .NET environment.  But, after this initial cost, MSXML kicks butt, especially with larger XML files.

Am I surprised?  No.  .NET adds on another layer of abstraction onto a programming paradigm already rife with abstractions.  The .NET Framework serves as a layer of abstraction, just as the Win32 API serves as a layer of abstraction, just as high-level programming languages serve as a layer of abstraction, just as assembly language serves as a layer of abstraction.  .NET, like the Java platform, is another encompassing layer in a slew of layers.  Is this a bad thing?  Taking a “performance-only” view, then, yes, any layer of abstraction robs you from the sheer performance typing in 1s and 0s can afford.  But, from a development standpoint, from looking at the bottom-line not just as how many operations per second, but how many man-hours it takes to create the program to run those operations, layers are a Good Thing.

End conclusion: I expect those who do take on the challenge Michael outlines will have a hard time beating the fine-tuned VB6 COM code.  But, in the long run, it really doesn't matter.

posted on Wednesday, October 01, 2003 11:39 AM

Feedback

# re: A .NET Performance Challenge 10/1/2003 12:02 PM James Avery

I know that performance is important, but if it simply means buying a faster server and more memory than I think 99% of the companies you ask would take the faster, easier, more maintanable approach (.NET) even if it is slightly slower. (Though I am not sure that .NET would be slower than this COM component)

Just like I am sure someone out there could write a much much faster XmlEncode function in C++, or C, or Assembler... but would you really want to maintain that?

# re: A .NET Performance Challenge 10/2/2003 6:32 PM Michael Balloni

To some extent, I agree with you and James Avery that it doesn't really matter, there's already faster ways to do such things (C++, assembly, etc.). And yet...VB6 is pretty high level, in the big scheme of things. Like, most developers would say that VB is higher level than Java or .NET (which came before and after it)...it's certainly lower-tech *and* easier to use than either of those systems. Developer productivity goes down with more complicated systems...nothing could be simpler than component development with VB/VBScript. There are idiosynchracies, sure, but when it comes to laying down objects with properties and methods and developing functionality, VB is simpler and it gets the job done, therefore it's better. Unless...you can show me that .NET knocks its socks off performance-wise...that'd turn the tables a bit.

See, VB probably compiles down to better assembly/machine code than just about anybody could write by hand in most performance-sensitive cases. Certainly C++ does. I reckon the machine code for my little XmlEncode function is pretty decent. And if it's not acceptable, I can hop over to C++ and whip up a COM component that I can use in VB/VBScript. .NET doesn't even have VBScript: simpler is better, and nothing's simpler than VBScript for coding at this level. I bet the same comparos were made between C and C++ 15 years ago, and C probably beat the initial C++ compilers. Eventually compilers got better and C lost favor b/c good C++ libraries/compilers completely negate C's low-level benefit, and yet...C++ is a big frickin' mess compared to Java or even .NET. Its fundamental nastiness (virtual base classes!?!?) is why Java and eventually .NET came into existence.

So I'll take your buy faster computers / productivity argument and turn it on its head: VB is simpler than .NET or C++...if I need more performance, I'll turn to C++ and put up with a measured amount of nastiness, or I'll just buy more computers. I'd only trade VB simplicity/productivity for .NET performance. I've seen the code and the tools, and they don't look any more convenient. Maybe for newbies who like WYSIWYG drag-n-drop application development. But for really writing code, VB seems a lot simpler. And maybe the end-result runs faster, too? So even if .NET is faster maybe I'd just buy more servers to run easier-to-write/maintain VB6 code...

See, I can't make any sort of "we've got to port to .NET" argument to "management" saying that "oh, it'll have this neat object library for free that we've already licensed components to get the functionality of...and it'll be harder to write due to way more programming rope to hang ourselves with...oh, and the end result will be slower executing code so we'll need to buy a bunch more hardware." That argument's not going to convert this shop. If we could get a 50% speedup on exactly this type of operation (getting munged (meta)data out the door), that'd be a good sign as to the Streamload-worthiness of .NET. Otherwise we'll just keep dropping and re-adding binary compatibility (thanks Visual Make) and carry on our merry way.

Title:  
Name:  
Url:
Protected by Clearscreen.SharpHIPEnter the code you see:
Comments   

My Links

Ads Via DevMavens

Archives

Post Categories

 

I am a Microsoft MVP for ASP.NET.
I am an ASPInsider.
<July 2008>
SMTWTFS
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789

Comment Stats

DayTotal% of Total
Sunday 1896.8%
Monday 39014.0%
Tuesday 46916.8%
Wednesday 51518.5%
Thursday 54419.5%
Friday 50818.2%
Saturday 1706.1%
Total 2785100.0%

Hour1Total% of Total
12:00 AM 682.4%
1:00 AM 712.5%
2:00 AM 632.3%
3:00 AM 752.7%
4:00 AM 572.0%
5:00 AM 1093.9%
6:00 AM 1114.0%
7:00 AM 1615.8%
8:00 AM 1756.3%
9:00 AM 1505.4%
10:00 AM 1736.2%
11:00 AM 1826.5%
12:00 PM 1906.8%
1:00 PM 1766.3%
2:00 PM 1605.7%
3:00 PM 1324.7%
4:00 PM 1124.0%
5:00 PM 983.5%
6:00 PM 913.3%
7:00 PM 993.6%
8:00 PM 853.1%
9:00 PM 802.9%
10:00 PM 833.0%
11:00 PM 843.0%
Total 2785100.0%

Comments by Blog Entry Date/Time

Day Entry MadeAvg.Total
Sunday 5.14144
Monday 5.35353
Tuesday 4.35444
Wednesday 7.58644
Thursday 6.87625
Friday 5.45414
Saturday 5.03161
Total 5.802785

Hour1 Entry MadeAvg.Total
12:00 AM 5.0035
1:00 AM 1.002
5:00 AM 0.000
7:00 AM 7.0035
8:00 AM 5.45109
9:00 AM 6.34279
10:00 AM 6.41250
11:00 AM 4.28184
12:00 PM 6.98342
1:00 PM 2.87112
2:00 PM 5.29222
3:00 PM 8.54299
4:00 PM 3.9190
5:00 PM 5.78156
6:00 PM 4.52113
7:00 PM 9.32177
8:00 PM 9.06154
9:00 PM 5.14113
10:00 PM 6.2381
11:00 PM 4.5732
Total 5.802785

Learn More About Comment Stats
1 - All times GMT -8...


Blog Stats

Favorite Web Sites

My Books

My MSDN Articles