Skip to content

Instantly share code, notes, and snippets.

@twotwotwo
twotwotwo / go-links.md
Last active July 19, 2016 00:54
Go links
@twotwotwo
twotwotwo / sorts.md
Last active December 9, 2023 08:41
Sorting 5x faster with Go: how it's possible, what didn't work so well, and what I learned

github.com/twotwotwo/sorts is a Go package with parallel radix- and quicksorts. It can run up to 5x faster than stdlib sort on the right kind of large sort task, so it could be useful for analysis and indexing/database-y work in which you have to sort millions of items. (To be clear, I don't recommend most folks drop stdlib sort, which is great, and which sorts depends on.)

While the process of writing it's fresh on my mind, here are some technical details, some things that didn't make the cut, and some thoughts about the process:

Concretely, what this looks like inside:

  • Both number and string versions are in-place MSD radix sorts that look at a byte at a time and, once the range being sorted gets down to 128 items, call (essentially) the stdlib's quicksort.

  • The [parallelization code

@twotwotwo
twotwotwo / gist:68f8d133c665a07e2b67
Last active August 29, 2015 14:09
'net' with deepest occurrence of each pkg only
If you take the full `net` tree, for each package find the deepest
level of tree where it appears, and delete other imports of that
package that are nearer the root, you get something like:
net
os
io
errors
time
syscall