Go Mechanical Sympathy Workshop

A hands-on workshop about writing Go that works with the machine instead of against it. Every module explains a mechanism inside the Go compiler, runtime or the hardware, and then you measure the before and after yourself with benchmarks and profiles.

This workshop uses stock Go 1.27. You don't need to build Go from source.

Prerequisites

Workshop Overview

This workshop has 19 modules that build on each other. You start by learning to measure, then remove allocations, then tune data for the CPU caches and branch predictor, and then work with the GC and scheduler. Every module pairs one concept with a lab where you measure the before and the after.

Part I · Measure first

Part II · Allocations and the compiler

Part III · The GC and the runtime

Part IV · Memory and the hardware

Getting Started

  1. Start with Module 0 to set up your environment
  2. Do modules 1 and 2 first. Every other module relies on benchmarking and profiling
  3. Each lab lives in labs/NN-name/. You edit after.go, and solution.go is the reference

Workshop author

Start with Module 0 →