Back to Devoured - September 04, 2026
DEVOURED
How Swiss Tables Work in Go's Built-in Map

How Swiss Tables Work in Go's Built-in Map

DevOps VictoriaMetrics
Go's internal map implementation has adopted a Swiss Table design, utilizing control bytes and SIMD to drastically improve key lookup performance and cache locality.
What: The new implementation organizes map entries into blocks, using 8-bit metadata (control bytes) to quickly check multiple candidate slots before falling back to full key comparisons. This approach leverages SIMD instructions to parallelize metadata scanning, reducing CPU cycles during map operations.
Why it matters: Data structure optimization is increasingly relying on hardware-specific features like SIMD to overcome the limitations of traditional, memory-intensive pointer-chasing patterns in high-concurrency environments.
Deep dive
  • Control Bytes: Each bucket contains metadata that allows for quick rejection of non-matching keys.
  • SIMD Usage: Compilers can use vector instructions to compare 16 or more control bytes in a single cycle.
  • Memory Layout: By grouping data into blocks, the structure improves the chances of hitting CPU caches (L1/L2).
  • Growth strategy: Optimized for smaller memory footprints during resizing compared to legacy implementations.
Decoder
  • Swiss Table: A hash table design pioneered by Google that optimizes for cache efficiency and lookup speed using a 'control byte' array.
  • SIMD (Single Instruction, Multiple Data): A CPU capability that allows a single instruction to operate on multiple pieces of data simultaneously, common in modern chips.
Original article

Go's newer map implementation uses a Swiss Table design that groups entries in small blocks with compact control bytes, allowing many candidate slots to be checked before doing full key comparisons. SIMD can compare multiple control bytes at once on supported CPUs, while the layout and growth strategy improve cache locality and lookup performance.

Explore all 57 articles in today's digest

Fresh dev news, AI-digested daily. Never miss a trend at devoured.fyi