<p>I'm working on a project were we need more performance. Over time we've continued to evolve the design to work more in parallel(both threaded and distributed). Then latest step has been to move part of it onto a new machine with 16 cores. I'm finding that we need to rethink how we do things to scale to that many cores in a shared memory model. For example the standard memory allocator isn't good enough.</p>

<p>What resources would people recommend? </p>

<p>So far I've found Sutter's column Dr. Dobbs to be a good start.
I just got The Art of Multiprocessor Programming and The O'Reilly book on Intel Threading Building Blocks</p>

[{'answer_id': 6846, 'author': 'John Downey', 'author_id': 200, 'author_profile': 'https://Stackoverflow.com/users/200', 'pm_score': 2, 'selected': False, 'text': '<p>You might want to check out <a href="http://code.google.com/p/google-perftools/wiki/GooglePerformanceTools" rel="nofollow noreferrer">Google\'s Performance Tools</a>. They\'ve released their version of malloc they use for multi-threaded applications. It also includes a nice set of profiling tools.</p>\n'}, {'answer_id': 6853, 'author': 'axk', 'author_id': 578, 'author_profile': 'https://Stackoverflow.com/users/578', 'pm_score': 2, 'selected': False, 'text': '<p>Jeffrey Richter is into threading a lot. He has a few chapters on threading in his books and check out his  blog:</p>\n\n<p><a href="http://www.wintellect.com/cs/blogs/jeffreyr/default.aspx" rel="nofollow noreferrer">http://www.wintellect.com/cs/blogs/jeffreyr/default.aspx</a>.</p>\n'}, {'answer_id': 6873, 'author': 'pauldoo', 'author_id': 755, 'author_profile': 'https://Stackoverflow.com/users/755', 'pm_score': 1, 'selected': False, 'text': '<p>The allocator in FreeBSD recently got an update for FreeBSD 7.  The new one is called <a href="http://people.freebsd.org/~jasone/jemalloc/bsdcan2006/jemalloc.pdf" rel="nofollow noreferrer">jemaloc</a> and is apparently much more scaleable with respect to multiple threads.</p>\n\n<p>You didn\'t mention which platform you are using, so perhaps this allocator is available to you.  (I believe <a href="http://blog.pavlov.net/2008/02/05/jemalloc-now-on-the-trunk/" rel="nofollow noreferrer">Firefox 3 uses jemalloc</a>, even on windows.  So ports must exist somewhere.)</p>\n'}, {'answer_id': 6929, 'author': 'Chris Hanson', 'author_id': 714, 'author_profile': 'https://Stackoverflow.com/users/714', 'pm_score': 4, 'selected': True, 'text': '<p>A couple of other books that are going to be helpful are:</p>\n\n<ul>\n<li><a href="https://rads.stackoverflow.com/amzn/click/com/0131972596" rel="noreferrer" rel="nofollow noreferrer" title="Synchronization Algorithms and Concurrent Programming">Synchronization Algorithms and Concurrent Programming</a></li>\n<li><a href="https://rads.stackoverflow.com/amzn/click/com/0321228111" rel="noreferrer" rel="nofollow noreferrer" title="Patterns for Parallel Programming">Patterns for Parallel Programming</a></li>\n<li><a href="http://www.usingcsp.com/" rel="noreferrer" title="Communicating Sequential Processes">Communicating Sequential Processes</a> by C. A. R. Hoare (a classic, free PDF at that link)</li>\n</ul>\n\n<p>Also, consider relying less on sharing state between concurrent processes.  You\'ll scale much, much better if you can avoid it because you\'ll be able to parcel out independent units of work without having to do as much synchronization between them.</p>\n\n<p>Even if you need to share some state, see if you can partition the shared state from the actual processing.  That will let you do as much of the processing in parallel, independently from the integration of the completed units of work back into the shared state.  Obviously this doesn\'t work if you have dependencies among units of work, but it\'s worth investigating instead of just assuming that the state is always going to be shared.</p>\n'}, {'answer_id': 6947, 'author': 'Michael Neale', 'author_id': 699, 'author_profile': 'https://Stackoverflow.com/users/699', 'pm_score': 2, 'selected': False, 'text': '<p>As monty python would say "and now for something completely different" - you could try a language/environment that doesn\'t use threads, but processes and messaging (no shared state). One of the most mature ones is erlang (and this excellent and fun book: <a href="http://www.pragprog.com/titles/jaerlang/programming-erlang" rel="nofollow noreferrer">http://www.pragprog.com/titles/jaerlang/programming-erlang</a>). May not be exactly relevant to your circumstances, but you can still learn a lot of ideas that you may be able to apply in other tools.</p>\n\n<p>For other environments: </p>\n\n<p>.Net has F# (to learn functional programming).\nJVM has Scala (which has actors, very much like Erlang, and is functional hybrid language). Also there is the "fork join" framework from Doug Lea for Java which does a lot of the hard work for you.</p>\n'}, {'answer_id': 7195, 'author': 'graham.reeds', 'author_id': 342, 'author_profile': 'https://Stackoverflow.com/users/342', 'pm_score': 0, 'selected': False, 'text': '<p>Take a look at <a href="http://www.hoard.org/" rel="nofollow noreferrer">Hoard</a> if you are doing a lot of memory allocation.</p>\n\n<p>Roll your own <a href="http://www.boyet.com/Articles/LockfreeFreeList.html" rel="nofollow noreferrer">Lock Free List</a>. A good resource is here - it\'s in C# but the ideas are portable. Once you get used to how they work you start seeing other places where they can be used and not just in lists.</p>\n'}, {'answer_id': 7230, 'author': 'Matt Price', 'author_id': 852, 'author_profile': 'https://Stackoverflow.com/users/852', 'pm_score': 0, 'selected': False, 'text': "<p>I will have to check-out Hoard, Google Perftools and jemalloc sometime. For now we are using scalable_malloc from Intel Threading Building Blocks and it performs well enough.</p>\n\n<p>For better or worse, we're using C++ on Windows, though much of our code will compile with gcc just fine. Unless there's a compelling reason to move to redhat (the main linux distro we use), I doubt it's worth the headache/political trouble to move.</p>\n\n<p>I would love to use Erlang, but there way to much here to redo it now. If we think about the requirements around the development of Erlang in a telco setting, the are very similar to our world (electronic trading). Armstrong's book is on my to read stack :)</p>\n\n<p>In my testing to scale out from 4 cores to 16 cores I've learned to appreciate the cost of any locking/contention in the parallel portion of the code. Luckily we have a large portion that scales with the data, but even that didn't work at first because of an extra lock and the memory allocator.</p>\n"}, {'answer_id': 139013, 'author': 'Alex Miller', 'author_id': 7671, 'author_profile': 'https://Stackoverflow.com/users/7671', 'pm_score': 0, 'selected': False, 'text': '<p>I maintain a concurrency link blog that may be of ongoing interest:</p>\n\n<p><a href="http://concurrency.tumblr.com" rel="nofollow noreferrer">http://concurrency.tumblr.com</a></p>\n'}]
['https://Stackoverflow.com/questions/6817', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/852/']