Closed kevinburkesegment closed 2 years ago
For completeness, adding a snapshot for a run on a x86:
goos: linux
goarch: amd64
pkg: github.com/segmentio/asm/qsort
cpu: Intel(R) Xeon(R) CPU @ 2.60GHz
BenchmarkSort8/100000
BenchmarkSort8/100000 625 1916996 ns/op 417.32 MB/s
BenchmarkSort8/1000000
BenchmarkSort8/1000000 49 24289400 ns/op 329.36 MB/s
BenchmarkStdlibSort8/100000
BenchmarkStdlibSort8/100000 86 11709887 ns/op 68.32 MB/s
BenchmarkStdlibSort8/1000000
BenchmarkStdlibSort8/1000000 7 144533331 ns/op 55.35 MB/s
These will let us be more confident that the qsort makes sense to use, especially when e.g. the Go standard library introduces a new sorting algorithm, we can compare the two.
On my Mac, using the pdqsort from Go 1.19, the relevant timings are:
Compared to the Go 1.18 sort algorithm:
So the Go standard library sort performance is improving but we are still about 40% faster than the benchmark.