Sorting improvement

Moved from GitHub dgraph/4045

Posted by jfcg:

Experience Report

My experience with Go standard library’s sort is that it is not a concurrent implementation (does not utilize multiple goroutines). This bid me once before when I tried to sort a very long array of ints. However I did not assess its affects on dgraph. Dgraph database also uses it extensively:

grep -Pr 'sort\.(?:IsSorted|Search|Float64s|Ints|Sort|Slice|Strings)' . | grep -c .

gives 252 results. I decided to open this issue to determine how it affects dgraph and how it can be improved.

Why that wasn’t great, with examples

It took literally hours to sort the very long array I was interested in. Then I decided to implement my concurrent sorting implementation.

Any external references to support your case

Please see my concurrent implementation and benchmarks there. It is almost api-compatible with sort.

campoy commented :

Thanks for the report, @jfcg

We’ll consider working on it soon, feel free to send a PR too!