TL;DR: I built
benchfmt.rs
, a zero-dependency Rust benchmark runner andCriterion
converter for Go’sbenchstat
. It adds/key=value
projections, heap tracking for allocated bytes (B/op
) and objects (allocs/op
) per op, andpprof
profiling.In this post, I am benchmarking
varint
and Prometheus Remote Write 2.0 decoding across Go and Rust to showcase the benefits ofbenchstat
-like flow in Rust. I’m also sharing some fun learnings on the way (e.g., yes Rust is faster).
Recently, I’ve been working on a few Rust projects across Google and open source. I came to Rust after years of writing performance-sensitive Go in Prometheus, Thanos, and teaching Go in the “Efficient Go” book. For me, much of Rust’s performance story is really good, until…. I wanted to run A/B microbenchmarks.
Perhaps I was spoiled by the Go benchmarking ecosystem, with the go tool -bench
and benchstat
in the center. To me, Rust standard benchmarking tools are lacking:
- Standard format for case comparison projections.
- Standard heap allocation measurements.
- Standard
pprof
support. - Simple to understand reliability scoring.
DISCLAIMER: A
standard
here means something that…