Exception Cost: When to throw and when not to

The Cost of Exceptions I wish I could speak intelligently on the exact cost but it’s really quite difficult to project for any given usage, it’s best measured for your specific cases.  However there are a couple of different kinds of cost and they’re both worth at least a few words. The first kind of…

24

More StringBuilder advice

I first wrote about this here, but I’ve since received several requests for more prescriptive advice on the subject.  Again you can never be sure without understanding the exact usage pattern because the results really do vary widely but here’s some general guidelines that may be useful. The choice (String vs. StringBuilder) usually turns not…

14

Designing for Performance

I wrote this article back in July and it ended up being the basis of this video (scroll to where it says “Thinking about Performance” and choose a speed) I was going to have the article edited and published seperately but somehow that never happened, so here it is now… the content isn’t terribly new but…

5

Another bad lock pattern

A while ago I asked Dr. GUI to post an MSDN article about the perils of using lock(typeof(Foo)), you can still find that article here. But recently I’ve started seeing another pattern that’s just as bad: class MyClass {     private static String myLock = “MyLock“;     public void Foo()    {     lock(myLock) { … }   …

13

Mid-life crisis

This particular problem (I call it mid-life-crisis) seems to come up fairly often so I thought I’d write up some general advice on it.  The symptoms go something like this:  There is a server process (usually a web server) and that process has a high percentage time spend in the garbage collector, like say 30%,…

35

My new home

Well here I am in my new home, feels comfy already. I copied my old postings here for easy reference, the originals with comments are still on http://blogs.gotdotnet.com/ricom, but there won’t be any new articles there. Happy Holidays!

0

Locality of reference and performance

Eric Gunnerson told me he had some requests for information on how to get good locality of reference when using the CLR. This is a topic that’s near and dear to me so that’s all the provocation I needed to blog about it. I think first it’s important to understand just how significant locality of…

2

Two things to avoid for better memory usage

OK, I never give rules, because they always have exceptions, and I won’t start today, but I’m gonna give a couple things that look like rules but aren’t. I’ll leave it as an exercise to the reader to decide when they should break these almost-rules 🙂 Almost-rule #1: Never call GC.Collect() If you think you…

23

Good talk on performance culture

Plugging my own video, I think it’s pretty entertaining for a talk a performance, even has some content. 🙂 http://gotdotnet.com/team/clr/about_clr_performance.aspx The points from the key slides are  Rule #1: Measure Just thinking about what to measure will help you do a good job If you don’t measure you can be sure it will be slow,…

7

Concatenating with StringBuilders vs. Strings

I would never make a statement so bold as “Use Stringbuilders to concatenate” without having a deeper understanding of the concatenation pattern.  I tend to give advice like “Many users find Stringbuilders useful for their concatenation pattens, consider using them and measure to see if they help you”.  Wussy but safe 🙂OK, now for some…

9