Go 1.24 replaces its legacy bucket-based map runtime with Swiss Tables, yielding up to a 60% improvement in microbenchmarks and a 1.5% geometric mean CPU time reduction. The architecture organizes storage into 8-slot groups managed by 8-byte control words, enabling parallel SIMD-accelerated key filtering via hashed control bytes (H1 and H2). Incremental scalability is achieved using directory-backed tables, local and global depth tracking, triangular probe sequences, and an 87.5% load factor threshold. Furthermore, Go 1.27 introduces an experimental split group layout (GOEXPERIMENT=mapsplitgroup) that optimizes cache locality by separating key and value arrays.
Key Points
Swiss Table Migration: Go 1.24 discards bucket-based overflow chains in favor of contiguous 8-slot groups, eliminating dependent pointer chases during lookups.
Hash Partitioning (H1 and H2): Keys are hashed using a map-specific random seed. Upper bits (H1) dictate group and table selection, while the lower 7 bits (H2) occupy control bytes to facilitate rapid screening.
SIMD Parallel Filtering: On AMD64 architectures, SIMD instructions compare an H2 target against all 8 control bytes concurrently, creating a candidate bitmap that bypasses full equality checks for non-matching slots.
Triangular Probe Sequence: When a starting group lacks empty slots, Go probes subsequent groups using triangular offsets (+1, +2, +3, wrapping around power-of-two group bounds) to locate keys.
Directory-Based Table Splitting: Tables scale up to 1024 slots across 128 groups before splitting. A directory layer tracking global depth and local depth permits individual tables to split without requiring global directory or map rebuilds.
Load Factor Enforcement: Go enforces a maximum load factor of 7/8 (87.5%), combining live entries and deleted slots to prevent probe sequence degradation caused by high occupancy.
Deletion State Management: Group deletions clear slots immediately if empty slots exist; otherwise, a tombstone marker (11111110) is applied to signal lookups to continue along the probe sequence.
Experimental Split Layout: Go 1.27 adds GOEXPERIMENT=mapsplitgroup, separating key arrays from value arrays in group memory to improve CPU cache line density and reduce struct padding (e.g., saving 56 bytes per group for map[int64]struct{}procedures).
Discussion Highlights
Google Office Origins: Commenters note that Swiss Tables were originally developed by engineers at Google’s Zurich office, prompting discussions on why Go—also a Google-backed project—did not adopt them earlier.
Adoption Challenges: Integrating Swiss Tables into Go required resolving unique runtime constraints and memory layout challenges detailed in official Go engineering disclosures.
Language Evolution and Context: Participants observe that Go's core map primitive predates Swiss Tables by design, established during Go 1.0 under a lightweight, scripting-language-influenced runtime philosophy.
External Resources: Commenters shared Matt Kulukundis's CppCon 2017 talk, "Designing a fast, efficient, cache-friendly hash table, step by step" (https://youtu.be/ncHmEUmJZf4), as the foundational reference for Swiss Table design principles.