Shaving 40% off Google's B-Tree implementation with Go Generics

Click for: original source

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 Google B-Tree implementation. By Michal Matcczuk.

The work covered in this article was part of ScyllaDB’s long-standing partnership with the Computer Science Department at the University of Warsaw. We’ve worked on a number of projects together: integrating Parquet, an async userspace filesystem, a Kafka client for Seastar, a system for linear algebra in ScyllaDB and a design for a new Rust driver.

The article then describes and explains well:

  • Making faster B-Trees with Generics
  • The additional allocation
  • Why is it faster?

By shifting from an implementation using interfaces to one using generics, we were able to significantly improve performance, minimize garbage collection time, and minimize CPU and other resource utilization, such as heap size. Particularly with heap size, we were able to reduce HeapObjects by 99.53%. You will find all the code and performance testing described in the article as well. Very interesting!

[Read More]

Tags golang app-development performance programming