Sorting 1000-2000 elements with many cache misses

Posted by Soylent Graham on Stack Overflow See other posts from Stack Overflow or by Soylent Graham
Published on 2010-06-01T18:50:43Z Indexed on 2010/06/01 18:53 UTC
Read the original article Hit count: 181

Filed under:
|

I have an array of 1000-2000 elements which are pointers to objects. I want to keep my array sorted and obviously I want to do this as quick as possible. They are sorted by a member and not allocated contiguously so assume a cache miss whenever I access the sort-by member.

Currently I'm sorting on-demand rather than on-add, but because of the cache misses and [presumably] non-inlining of the member access the inner loop of my quick sort is slow.

I'm doing tests and trying things now, (and see what the actual bottleneck is) but can anyone recommend a good alternative to speeding this up? Should I do an insert-sort instead of quicksorting on-demand, or should I try and change my model to make the elements contigious and reduce cache misses? OR, is there a sort algorithm I've not come accross which is good for data that is going to cache miss?

© Stack Overflow or respective owner

Related posts about c++

Related posts about sorting