explaingit

dgryski/go-perfbook

10,900Audience · developerComplexity · 2/5Setup · easy

TLDR

A community-written guide on making Go programs run faster, covering general optimization strategies and Go-specific profiling tools, garbage collection, algorithms, and data structures, available in four languages.

Mindmap

mindmap
  root((go-perfbook))
    General concepts
      Optimization workflow
      Algorithm choice
      Data structures
    Go specific
      GC and memory
      Runtime internals
      Profiling tools
    Advanced topics
      Assembly code
      CGO usage
      Service level perf
    Languages
      English Chinese
      Spanish Portuguese
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Learn a systematic workflow for profiling and optimizing a slow Go service in production

USE CASE 2

Find Go-specific performance pitfalls in standard library usage before deploying

USE CASE 3

Study how the Go garbage collector works to reduce GC pauses in a latency-sensitive application

USE CASE 4

Write meaningful Go benchmark tests that avoid common measurement mistakes

Tech stack

Go

Getting it running

Difficulty · easy Time to first run · 5min

In plain English

This repository is a community-written guide on how to make Go programs run faster. Go is a programming language developed by Google and is widely used for building backend services and tools. Performance optimization means identifying where a program spends unnecessary time or memory, then changing the code to fix it. The guide is organized as a single long document (with a table of contents) split into two broad halves. The first half covers optimization ideas that apply to any programming language, such as how to think about optimization as a workflow, how to pick better algorithms, how to structure data so it is faster to access, and how to write meaningful benchmark tests. The second half focuses specifically on Go: how Go handles memory cleanup (called garbage collection), how its runtime and compiler work under the hood, how to use profiling tools to find slow spots in a running program, and when to use lower-level techniques like writing in assembly language. There are also sections on common mistakes when using Go's standard library, how to call C code from Go (a feature called CGO), and how to think about performance at the level of an entire service rather than a single function. The document is available in English, Chinese, Spanish, and Brazilian Portuguese. It is described as a work in progress, and contributions are welcome through the Gophers community Slack channel. The README is short, the main content lives in the linked markdown files inside the repository.

Copy-paste prompts

Prompt 1
Using go-perfbook as a reference, help me profile my Go HTTP server with pprof to find where it spends the most time and suggest concrete fixes
Prompt 2
Based on go-perfbook advice on data structures, review this Go struct and suggest how to reorder fields to improve cache locality
Prompt 3
Using go-perfbook guidance on benchmarking, help me write a Go benchmark for my string processing function that avoids common measurement pitfalls
Prompt 4
Apply the go-perfbook recommendations for reducing garbage collector pressure to this high-throughput Go service code
Open on GitHub → Explain another repo

← dgryski on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.