This site is being rebuilt and some pages are out of date. For current details, write to [email protected]. This notice goes away when the rebuild is done.

No analytics unless you allow it, no tracking. This site keeps in your browser the language you pick, the theme, its colour, which site you chose, the currency on the pricing page and that you closed this notice; signing in adds session cookies. The legal page has the details.

Sign in

Radar · Go · Archive · Week 9 · Feb 24 – Mar 2, 2025

Faster Go maps with Swiss Tables

Nice to knowecosystem

What changed
Go 1.24 introduces a new map implementation that improves performance.
Production impact
The source does not say.
Try it
Benchmark a map in Go 1.24 versus an older version.
Source
go.dev/blog/swisstable

Understand it, then run it

Run it now

Todaygo
// This program demonstrates the new Swiss Table map implementation in Go 1.24.
// It creates a map, inserts many entries, and measures lookup speed.
// The code runs unchanged in Go 1.27.1, which already includes the Swiss Tables.

package main

import (
	"fmt"
	"math/rand"
	"time"
)

func main() {
	const n = 1_000_000
	m := make(map[int]int, n)

	// Fill the map with random keys.
	start := time.Now()
	for i := 0; i < n; i++ {
		m[rand.Int()] = i
	}
	fmt.Printf("Insertion time: %v\n", time.Since(start))

	// Look up all keys to exercise the new map internals.
	start = time.Now()
	sum := 0
	for k := range m {
		sum += m[k]
	}
	fmt.Printf("Lookup time: %v, sum: %d\n", time.Since(start), sum)
}

What it printed when we ran it on Go 1.27.1

Insertion time: 191.088174ms
Lookup time: 23.684702ms, sum: 499999500000

Run sends this program (for Solidity, the contract and its tests) to our own sandbox, where it is compiled and run once, with no network, and what it printed or the test report comes back here. Nothing is kept. Runs are counted per visitor for the day so everyone gets a turn; the details are on the legal page.

Written by gpt-oss-20b from the linked source · claims checked against the sources · archive, not individually reviewed