Feeds:
Posts
Comments

Posts Tagged ‘STL’


Last year, I did a performance comparison for VC7, VC9 (with and without SCL), and STLPort. Now that VC10 is out, I wonder if it is worth the upgrade.

So I dusted off the benchmark code from last year and upgraded the solution to VC10. This time, I would like to see how VC9, VC10, and STLPort 5.2.1.

VC8 and VC9′s Secure SCL “feature” was disastrous to many C++ programmers who cares about performance. So this test is done with Secure SCL disabled.

With all the C++0x language upgrades and performance claims in VC10, I expect improvements.

The Results

Recall: The stress test I wrote last year benchmark against 1. performance under growing container sizes, and 2. running a large number of operation while keeping container size a constant.

Recall:  The test for vector involves three operations – insertion, iterator traversal, and copy.

VC10 actually got a bit slower compare to VC9. Oops..

Performance of vector in STLPort is still leading by a mile.

Recall: The test for string involves three operations – string copy, substring search, and concatenation.

VC10 is performing as well as STLPort in large strings.

VC10 small strings are now better optimized than STLPort. Very impressive!

Recall: The test for map involves insertion, search, and deletion.

It appears that the performance of map in VC9 and VC10 are identical.

Same as above, nothing has changed here.

Recall: The test for Deque comes with a twist. The deque is implemented is as a priority queue through make_heap(), push_heap() and pop_heap(). Random items are inserted and removed from the queue upon each iteration.

VC10 is leading in the deque performance.

STLPort is still leading in small deque size. However, VC10 shows improvement against VC9.

Conclusion

STL implementation in VC10 definitely shows  some improvements over its predecessor. It has shrunk the gap against STLPort. But at the same time, it still have a bit more to go.

There is an average of 2.5% improvement comparing STLPort compiled with VC9 and STLPort compiled with VC10. So upgrading to VC10 will provide a performance gain even for those who don’t use STL.

I wasn’t disappointed or impressed by the improvements. So I guess it was within my expectations.

Source and data sheet can be downloaded here.

Tools: Visual Studio 2008 (VC9), Visual Studio 2010 (VC10), STLport 5.2.1

Machine Specification: Intel i5-750 with 4GB of RAM. Window 7.

Read Full Post »

A Programmer’s Hunch

The product I work on has been migrated from VC71 to VC90. Ever since the upgrade, I feel that the software is taking longer to start up, has become less responsive. I have been working on the software for several years, so I have certain performance expectations . My programmer’s hunch tells me that something just isn’t right.

I did some searches, and found out that Checked Iterator (Secure SCL) for STL has been turned on since VC80. It is enabled by default for Debug and Release build. There are numerous performance complains for VC80 STL implementation. Our product relies extensively on STL, so that could certainly be a contributing factor to the sluggishness.

Time to Test

To see the current state of the system, I wanted to see the performance between VC71 and VC90 with Checked Iterator. I also wanted the difference without Checked Iterator. Lastly, I threw in STLport into the pot, just because I found a blog that says it is the fastest.

Four-Way Comparison

In the test, I chose four commonly used containers in our software – vector, string, map and deque. For each container type, it will be run against two types of test – Iteration and Size. For the iteration test, the container will be benchmarked with a fixed size across a large number of iterations. For the size test, the size of the container grows while the number of iteration remains the same.

Comparison – Vector

The test for vector involves three operations – inseration, iterator traversal, and copy.

Vector Size Test (Iteration = 100000)

VC90 with Checked Iterator runs much slower.

Vector Iteration Test (Num Elements = 10)

Without Checked Iterator, much of the lost performance are regained.

From VC71 to VC90 with SCL, there are 70% – 100% decrease in performance. By turning off Checked Iterator, the performance of VC90 is roughly equivalent to VC71. STLport outperforms all versions of Visual Studio.

Comparison – String

The test for string involves three operations – string copy, substring search, and concatenation.

string_size_small

VC90 performed poorly compare to VC71, regardless of Checked Iterators.

string_iter_small

STLport smoked its competitions in the short string test. (Note: 140 is the maximum character in a Twitter post)

Performance of string in VC90 degrades rapidly as the string grows. It appears that the Checked Iterator feature does not impact the performance of string.[Update: Secure SCL and HID was not turned off in string.  See article.] Again, STLport outperforms all version of Visual Studios. This is likely because of the optimization from Short String Optimization and Template Expression for string concatenation.

Comparison – Map

The test for map involves insertion, search, and deletion.

map_size_small

Minor improvement in VC9 compare to VC71.

map_iter_small

VC90 without Checked Iterator came out slightly ahead.

Surprisingly, the performance came out roughly the same for all, with VC71 to be the slowest.

Comparison – Deque

The test for Deque comes with a twist. The deque is implemented is as a priority queue through make_heap(), push_heap() and pop_heap(). Random items are inserted and removed from the queue upon each iteration.

deque_size_small

As the deque grows, VC90 with Checked Iterator runs at snail pace.

deque_iter_small

VC71 and STLport came out fastest.

The performance for VC90 with Checked Iterator is quite disappointing compare to others.

So.. Now What?

VC90 with Checked Iterator is indeed very slow. Although I see the benefit of iterator validation during debug phase, I fail to understand why it is enabled in release build. I am not convinced by the argument of correctness over performance. Once the iterators are proven correct, Checked Iterator is simply a burden. When the software is in customers’ hand, all these validations are pointless.

On a side note, the string and vector performance of STLport is very impressive. It is more 2x faster than Visual Studio. It’s simply amazing.

Source

The source and the results can be downloaded here.

Tools: Visual Studio 2003, Visual Studio 2008, STLport 5.2.1 (with Visual Studio 2008)

Machine Specification: Core Duo T2300 1.66 GHz with 2GB of RAM. Window XP SP3.

Read Full Post »

Follow

Get every new post delivered to your Inbox.