Am I Affected?

I l @ ve RuBoard

"Am I Affected?"

If you're using libraries built for possible multithreaded use and performance matters to you, you can and should do the same thing we did. Run profiles of your code to determine the data structures you use most. Do this by member function hit count, not necessarily by time spent in the function. Create sample programs that manipulate those data structures in a loop, and time those programs running with single- and multithreaded versions of the corresponding libraries. If there's a substantial difference, tell your vendor, especially if you can tell from the size of the difference whether it's less efficient than it needs to be.

Library implementers are generally reasonable people. Certainly, all those I've met are. It's their business to provide the highest-quality code to their customers. If there's a competitive advantage they can gain over other library vendors , they're usually happy to hear about it and provide it. Getting rid of COW implementations falls into the "good optimizations" category in most cases (and general-purpose libraries care most about "most cases").

So why have COW and similar "optimizations" been so prevalent historically? Probably the biggest reason is inertia and the weight of years . COW has traditionally been a common optimization for decades. Even at the end of the 1990s, despite the volume of trade press about multithreaded code, it was far from clear how much we as an industry were really writing multithreaded business applications. That is finally changing. Now that it is becoming clearer to library vendors that a significant portion of their customers are using multithreaded builds of their libraries, a few major vendors have already decided to abandon possible false optimizations like copy-on-write . To me, and to many, this is a Good Thing. It is to be hoped that the rest of the vendors will follow suit.

The performance penalty COW exacts in a multithreaded program can be startling. Remember, though, the problem isn't just with COW. Any shared-information optimization that joins two objects in some way "under the covers" will have the same problems.

I l @ ve RuBoard


More Exceptional C++
More Exceptional C++: 40 New Engineering Puzzles, Programming Problems, and Solutions
ISBN: 020170434X
EAN: 2147483647
Year: 2001
Pages: 118
Authors: Herb Sutter

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net