Is there an updated version of “Writing Faster Man

2020-06-03 03:21发布

问题:

The MSDN "Writing Faster Managed Code: Know What Things Cost" is pretty nice, but it was written for CLR v1 in 2003. Is there an updated version of this somewhere?

回答1:

No. I never updated it, but I think taken with appropriate grains of salt, the general advice and most rules of thumb in the article still hold up well today.

(That said, it would be interesting to repeat the experiment today to see how primitive times have changed, how the generated code has changed, and how microprocessors have changed.)

The relative overheads of most primitives won't have changed much, but some will have changed dramatically. For example, the mediocre performance of non-static delegate invoke was dramatically improved (in .NET 2.0, if I recall correctly). I would hate to think that a practitioner today would go out of her way to avoid delegate invoke because I reported it as very expensive in 2003.

Since .NET 1.1, I would expect many compiled code sequences to have changed; there would be new JIT compiler optimizations (which doesn't show up so well in microbenchmarks); different mixes of JIT'd and NGEN'd code (and NGEN was not explored in my article); and key subsystems like the garbage collector have been continually tuned over the years.

I reiterate my cautionary advice about the potential of memory system effects to drown out the costs of any number of individual managed code primitive operations -- and again note that a lot has changed. For example, a great deal of CLR performance work in 03-04 went into better working set behavior (such as minimizing dirty private pages) of NGEN'd system assemblies.

Of course the theme of the article is the imperative to thoughtfully and vigilantly measure the performance of your code, and that theme is timeless.

By the way, I always wanted to do a follow up article on the expected/typical time and space costs of the top few hundred or so most used .NET BCL methods, and to showcase as cautionary tales a few of the horror stories we found working on the .NET performance. That led to some very interesting thinking about how to characterize the empirical performance of a class library / framework as actually used by real practitioners in the wild...

Thanks for reading it back then, and thank you for your ongoing interest.

p.s. I see Vance Morrison subsequently wrote a great two part MSDN series on this subject -- if you enjoyed my article you'll love these:

http://msdn.microsoft.com/en-us/magazine/cc500596.aspx

http://msdn.microsoft.com/en-us/magazine/cc507639.aspx



回答2:

I don't think so, and I don't think that an updated version would be that much different.

The timing figures would be different as the testing machine would probably be newer and faster, but the relation between the tests would be pretty much the same.

The article is about the low level effects of common operations in managed code, and that hasn't changed much since the artice was written. The new versions of the framework has added a lot of functionality, but it's all built on the primitives that has been available since C# 1.0.



回答3:

I don't know of one that replaces that but the book CLR via C# will provide you with a lot of deep and relevant knowledge for how the CLR works and where it consumes a lot of time and resources.