Sorting out graph processing
github.com
github.com
Related discussion on twitter: https://twitter.com/roy_amitabha/status/634078514698952704
See Fritz Henglein's "Generic Top-down Discrimination for Sorting and Partitioning in Linear Time" paper for a nice way to extend radix sort's runtime to arbitrary meaningful orderings:
http://www.diku.dk/hjemmesider/ansatte/henglein/papers/hengl...
Beginning of a haskell implementation here: http://ekmett.github.io/discrimination/index.html . Might be doable in rust as well.
Also, for sorting 64-bit integers I like to do a bitwise or of all the integers while computing the histogram. Then if the bits you are looking at are zero (plausible for unsigned 64-bit integers) you can skip to the ones that matter for the next histogram.
You could do the same thing (I think) to avoid TLB limitations, manually staging everything in a contiguous 2MB of memory (backed by one large page, say), in order to keep the radix high and do fewer full scans. If you are hitting memory bandwidth, your performance should be determined by the number of scans you end up doing.
All of this is "caveat: I just read other people's work and haven't done this myself, because I haven't figured out inline asm in Rust yet". If you have more details on engineering radix sort, I'd love to read up! :D
You're writing to one of 256 (presumably far apart) memory locations - why isn't this considered random access?
In this case, 256 cache lines fit in the L1 cache, so while it does look like "random access" to the L1, this can end up looking more like "sequential access" to main memory. There are addition complications, like the L1 data cache being only 8-way associative, a quite small TLB cache sitting in front of the L2 and up, etc. So in practice this ends up somewhere between random access to L1 and random access to L3, with sequential access to main memory, I think.