From Gmail storage to CockroachDB: Peter Mattis on B-trees, Raft and coding with AI
Key points
Key takeaways from The Pragmatic Engineer interview with Cockroach Labs CTO Peter Mattis (September 2026):
From GIMP to Google. Mattis built the GIMP image editor with college roommate Spencer Kimball, half-jokingly aiming to clone Photoshop; the first Google logo was even made in GIMP,which is how Larry Page and Sergey Brin knew of them. He first turned down Google in 2001 (a three-year-old company —and the Mountain View commute) before joining in 2002 to build Gmail's storage back-end.
Gmail shock-and-awe storage. At launch in April 2004, Gmail offered about 1GB free storage against ~4MB at Hotmail and Yahoo Mail, built on Google's GFS filesystem with fast indexed search and an invite system that constrained demand while drumming up excitement. Paul Buchheit's idea to reuse the existing ad stack made the economics work.
B-trees, over and over. Mattis has implemented B-trees roughly a dozen times across his career —from Gmail's message-threading and unread-count lookups to CockroachDB—calling them central to building fast, correct databases at scale.
Distributed systems tradeoffs. The episode runs from Google's monorepo build system (google3 through the build files era and Bazel)and Colossus storage to the latency, throughput and availability tradeoffs that shaped Spanner,the precursor insights behind Cockroach Labs' founding in 2015 by Mattis, Spencer Kimball and Ben Darnell.
Strong consistency and Raft. CockroachDB stresses strongly consistent,horizontally scalable SQL,and the conversation covers manual versus automatic sharding and Raft consensus —a quorum of five among nine copies reconstructs data,so the system can lose any four replicas and keep serving.
AI brought him back to coding. A prolific coder for ~30 years—peakingat about 100,000 lines of production code in a year pre-AI — Mattis stopped writing code between 2022 and 2024 as his work shifted to management; strong coding models got him coding again,andhe describes his current output as unusually high-quality,database-grade code produced much faster with AI assistance.
Agents are lazy about testing. He argues AI agents tend to skip testing their output,butcalls tha an easier fix than it looks — a workflow problem rather than a fundamental limitation—andthinks AI should push the ambition of software engineering upwards.
Don't be spooked by competitors. Weeks before GIMP's first public release,someone announced a similar graphics program with even more features—andwas never heard from again. His lesson: others will almost always be working on the same idea,butmost never ship,so keep building and put it out there.
Read more: YouTube · The Pragmatic Engineer