Faster Go Interpreters: Closing the Gap with C++

2025-04-05
Faster Go Interpreters: Closing the Gap with C++

Vitess, the open-source database powering PlanetScale, initially used an AST-based interpreter for its SQL engine. Over the past year, this has been replaced with a Go-based virtual machine that performs comparably to MySQL's native C++ code, while being significantly easier to maintain. The VM achieves remarkable speed improvements—up to 20x faster in some cases—through static type checking and clever instruction dispatch. This article details the design and implementation, including leveraging Go's closures to simplify the VM and handling SQL's dynamic typing challenges.

Development