There are many reasons to be excited about generics in Go. In this article, I’m going to show how, using Go generics, ScyllaDB achieved a 40% performance gain in an already well-optimized package, the https://github.com/google/btree implementation.

For the purpose of this article, it’s sufficient to say that it is a collection.

The initial result: the generics code is faster by 20 to 30 percent according to the Google benchmarks (https://github.com/google/btree/issues/41).

On the other hand, with a generic interface and a generic type definition items are a slice of ints.

Related Articles