Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

High performance alternatives to STL?

Tags:

c++

stl

What cache friendly high performance alternatives are there to the traditional STL. They should be optimized for the caches of modern 64bit Intel/AMD CPU's.

I'm not looking for official standards based STL implementations necessarily it could be based on that or be an extended STL with high performance data structures. Or simply a library that provides general data structures like list, map etc.

High concurrency and lock free data structures would be a bonus.

I'm interested in a link & a licence.

I've read about EASTL and have used Boost before.

What are game developers and the scientific community using to get the most out of the CPU's at the moment? What is in the pipeline?

like image 913
hookenz Avatar asked Nov 23 '11 01:11

hookenz


People also ask

Is C++ STL slow?

C++ is faster if you chuck the "safety" features of programming languages and avoid things like STL, and Boost. In raw bytes to bytes C++ is faster, but then again so is C. The moment you add the baggage of STL, and Boost you are slower than well written C# code.

Is using STL good?

STL is well tested and reliable but it is not the fastest solution. Some of the containers allocate a lot of small memory blocks rather than one big block. If you really have a speed problem then you may consider making your own fixed-size list. But for many purposes STL is the standard solution.


2 Answers

+1 for EASTL.

Anything based on a C++11 compliant compiler will potentially perform a lot better because of move semantics.

This difference can already be made visible with the GNU libstdc++ implementation with -std=c++0x

For concurrency/lockfree containers I recommend:

  • libCds by Max Khiszinsky
  • TBB from Intel (no hands-on experience)

My central piece of advice would be this:

Optimizing the standard library is mostly a factor of deciding how to use algorithms/containers correctly than looking for the 'perfect' implementation. STL being general purpose, there would never be a perfect implementation.

Just watch your return values/out parameters closely (prefer to use output iterators, and use transform, partial_sum, accumulate into a container that had reserve or resize called on it appropriately; Define swap for your element types etc.)

like image 98
sehe Avatar answered Oct 05 '22 13:10

sehe


I believe the Standard Template Adaptive Parallel Library STAPL, may well be one of the most important research collaborations at the moment.

Microsoft are investing significant effort into the Asynchronous Agents Library, which has a number of well tested high performance containers for message passing.

Intel have their own offering, Thread Building Blocks that contains a number of containers and algorithms for parallel processing.

like image 31
Andrew Walker Avatar answered Oct 05 '22 11:10

Andrew Walker