We have already written about Go maps and their old runtime implementation in Go Maps Explained: How Key-Value Pairs Are Actually Stored. Go 1.24 replaced that implementation with a design based on Swiss Tables, so it is time for an update.
You do not need to go back and read the old article. We will review how maps behave and the concepts needed here before moving into the new runtime internals.
The Go blog also has an excellent article, Faster Go maps with Swiss Tables. It goes deeper and assumes a little more background knowledge. We take a different approach. We will discuss the same implementation more gradually and in a visual way, so you can relax your brain a little and still understand what Go is doing.
What is a map at runtime?
#
Let’s start with what a map actually is.
m := make ( map [ string ] int )
make initializes the map. map[string]int is the language-level type, which tells us that the map uses strings as keys and integers as values. Underneath that type, the runtime representation of m is a pointer to internal/runtime/maps.Map .
type Map struct { used uint64 seed uintptr dirPtr unsafe . Pointer dirLen int ... }
We can easily inspect this with println , which prints that pointer:
... continue reading