skip to Main Content

How CockroachDB Wrote a Massive & Complex Go Application

Garbage Collection in Go

In this talk Ben Darnell, the CTO and Co-Founder of Cockroach Labs, discusses the decision to utilize Go in CockroachDB. Ben shares how CockroachDB optimized its memory usage to mitigate issues related to garbage collection and improved its use of channels to avoid deadlocks. Ben also shares creative techniques to integrate non-Go dependencies into the Go build process.

Garbage collection in Go can cause an application to pause which is a concerning issue, but Go also makes a lot of manual tweaks available that allow contol of what actually ends up on top of the garbage heap. Here are two of the optimizations made by CockroachDB to mitigate garbage collection issues:

  • Combining Allocations
  • sync.Pool

By vitrue of these two practices (which you can see examples of in the video) CockroachDB sees in Go's benchmarking tools that no new allocations are done per iteration. Everything is allocated up front and cached. 

CockroachDB Community Slack 

This is a long, dense video with that covers a lot of ground. If you have followup questions you can join our CockroachDB Community Slack channel to chat with CockroachDB users and engineers about Go and CockroachDB.

 

Introduce CockroachDB to your team or meetup!

Request a deep-dive into CockroachDB’s architecture and capabilities presented by a CockroachDB engineer. Tech talks can be in-person or virtual, depending on availability and location.

Request a Tech Talk

Additional Resources

Learn how to use
CockroachDB

Need help? Get answers on the CockroachDB forum

What are you building with CockroachDB?

Back To Top