The Pragmatic Engineer
The Pragmatic Engineer

Distributed databases with Peter Mattis

September 30, 2026

AI Summary

5 min read

Peter Mattis, co-founder and CTO of Cockroach Labs, built the GIMP image editor in college, designed the original storage system behind Gmail, and co-created Colossus, Google's second-generation distributed file system. But the most striking fact from this conversation is his current output: after stepping away from hands-on coding between 2022 and 2024, he is now writing more production code than ever, using AI agents to produce database-quality code at a pace he describes as "a bit insane." This is not vibe-coded slop, he insists, but high-performance, production-ready code that passes the same bar Cockroach DB requires.

B-trees, B-trees everywhere

A thread running through Mattis's entire career is his repeated use of B-trees. He estimates he has implemented them "like a dozen times." The data structure first appeared in Gmail's threading system, where it tracked unread counts and thread IDs. It showed up again when a colleague at Google noticed that the STL map (a red-black tree) was consuming too much memory and cache bandwidth in an internal user-mapping system. Mattis and his colleague replaced it with a B-tree, which packed more data per node, reduced pointer overhead, and improved spatial locality. The same logic applies to Cockroach DB's distributed metadata index: "you squint and everything is either a B-tree or a hash table." The lesson is not that every engine

Continue reading the full summary in the app — free to try.

Read Full Summary →

Free • No credit card required

What you'll learn

  • 1 (00:07) **Peter Mattis: From GIMP to Cockroach Labs** - Introduction to Peter Mattis, his prolific coding history, and the episode's focus on why he's back to writing high-quality, production-ready code using AI.
  • 2 (02:04) **Early Career and the GIMP's Lesson** - Peter explains his entry into tech and the key lesson learned from nearly abandoning the GIMP because of a competitor's announcement.
  • 3 (06:40) **Google, Gmail, and the Economics of Free** - Peter recounts his path to Google, working on Gmail's backend, and the innovative economics that made 1GB of free email possible.
  • 4 (14:17) **Building Google's Build System (Blaze/Bazel)** - Peter explains the limitations of Make at Google scale and the rationale behind creating a higher-level build file system.
  • 5 (16:44) **Colossus: Google's Second-Gen File System** - Peter details the design of Colossus, the successor to GFS, focusing on scalability and erasure coding.
  • 6 (29:39) **The Ubiquitous B-Tree and Cache-Optimized Data Structures** - Peter explains why he keeps reaching for B-trees, including a story about replacing STL maps at Google with a custom B-tree for better performance.
  • 7 (34:28) **Contributing Swiss Tables to Go** - Peter describes how he contributed a new, faster hash table implementation to the Go standard library from outside of Google.

+ Full timestamped outline available in the app

Show Notes

Brought to You By:

• turbopuffer – a vector and full-text search engine built on object storage. It’s fast, cheap, and extremely scalable

• Linear – the product development system for teams and agents

• WorkOS – everything you need to make your app enterprise ready.

—

How is it that a software veteran who regularly shipped ~100K of database-grade code to production each year, pre-AI, feels like he’s even more productive today, with no drop in quality? Peter Mattis is co-founder and CTO of Cockroach Labs, and an original creator of GIMP. He also worked on Gmail and distributed storage at Google.

In this episode, Peter reflects on his journey from open source to Google to founding a database company, and we explore how to keep systems fast, reliable, and correct at scale, from Gmail’s early storage challenges to the tradeoffs in building distributed databases.

Peter tells us how AI has brought him back to writing code after his work shifted toward management, and why he believes AI can improve quality and multiply the impact of domain experts. We also consider the future of code review, and Peter has some advice about how to level up our engineering skills.

Timestamps

00:00 Intro

02:42 Peter’s path into tech

04:00 Building GIMP

09:30 Working on Gmail at Google

14:51 Google’s infra: google3, build files, Bazel, and Colossus

21:30 Distributed storage bottlenecks

23:59 Latency, throughput, and availability

30:04 Contributing to libraries

41:52 Google Spanner

46:10 CockroachDB

52:00 Manual vs. automatic sharding

55:28 Consistency models and strong consistency

1:00:03 Raft consensus

1:06:15 How AI brought Peter back to coding

1:19:12 Peter’s tools and agentic workflows

1:23:08 How AI can improve quality

1:26:39 Code reviews: are they done?

1:29:17 100x engineers

1:35:33 Peter’s advice for leveling up your engineering skills

—

The Pragmatic Engineer deepdives relevant for this episode:

• Inside Google’s Engineering Culture

• Resiliency in distributed systems

• How to debug large, distributed systems: Antithesis

• The Pragmatic Engineer