Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cache friendliness in C#

Tags:

I've just seen a very interesting talk by Herb Sutter at the Build Conference 2014, called "Modern C++: What You Need to Know". Here's a link to the video of the talk: http://channel9.msdn.com/Events/Build/2014/2-661

One of the topics of the talk was on how std::vector is very cache-friendly, mainly because it ensures that its elements are adjacent in the heap, which has a great impact on spatial locality, or at least that's what I think I've understood; this is the case even for inserting and removing items. Clever use of std::vector can bring dramatic performance improvements by exploiting caching.

I'd like to try something like what with C#/.Net, but how to ensure that the objects in my collections are all adjacent in memory?

Any other pointer to resources on cache-friendliness on C# and .Net is also appreciated. :)