Skip to content
Tech News
← Back to articles

How Swiss tables work in Go built-in map

read original get Learning Go by Jon Bodner (O'Reilly) → more articles
Why This Matters

Go 1.24 swapped out the long-standing runtime map implementation for one based on Swiss Tables, and this piece walks through the new internals in a gradual, visual way. For Go developers, it explains what actually changed under one of the language's most-used data structures — including how the runtime Map struct stores entry counts and a per-map seed — and complements the official Go blog's denser treatment.

Key Takeaways
Worth a Look

Learning Go by Jon Bodner (O'Reilly) — If this deep dive into Go's Swiss Table map internals hooked you, Jon Bodner's Learning Go is the natural companion for building idiomatic Go from the ground up. It covers maps, slices, interfaces and concurrency with the same practical, example-driven style, making it a great desk reference while you explore the runtime.

See Learning Go by Jon Bodner (O'Reilly) on Amazon → Affiliate link — we may earn a commission on purchases, at no extra cost to you. Product picked by AI based on this article; it is not a tested recommendation.

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