Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Datadog Engineering 17 min read Deep dive mediumAdept

How Go 1.24’s Swiss Tables saved us hundreds of gigabytes

Go 1.24's new map implementation, based on Swiss Tables and extendible hashing, cut roughly 500 MiB of live heap (about 1 GiB of RSS with GOGC=100) from a 3.5-million-entry routing cache map, enough to more than offset a separate Go 1.24 mallocgc memory regression. Go 1.23 maps use 8-slot buckets with overflow chains, a 13/16 maximum load factor, and incremental growth that keeps old bucket arrays alive. Swiss Tables use 8-slot groups with a control word for SIMD-assisted probing, which removes overflow buckets and allows a 7/8 load factor. Extendible hashing caps each table at 1024 slots, so growth is bounded and splits happen per table. The post works through per-entry and per-bucket memory estimates and then applies struct-level optimizations to the map's values for further fleet-wide savings.

Assumes: Go mapshash tablesGo heap profiling

Related posts

  • How we tracked down a Go 1.24 memory regression across hundreds of pods

    Datadog Engineering mediumAdept

    Upgrading a data-processing service to Go 1.24 raised container memory by about 20% even though Go runtime metrics and heap profiles stayed flat. Comparing `/proc/[pid]/smaps` showed the Go heap's RSS had grown to nearly match its virtual size. Reproducing the workload with heapbench and running `git bisect` traced the cause to a `mallocgc` refactor. That refactor dropped an optimization that skipped re-zeroing fresh OS memory for large (>32 KiB) pointer-containing allocations, so untouched pages were committed to RAM. The fix ships in Go 1.25, and in the worst case RSS should roughly equal Go-reported virtual memory, which is useful when checking memory-limit headroom before rollout.

  • We rewrote large parts of our API in Go using AI: we are now ready to handle one billion databases

    Turso mediumAdept

    Turso's Go API proxy, which maps database URLs to physical servers, ran out of memory as customers created millions of databases programmatically. Bootstrapping was fixed with streaming and pagination. Route memory was cut by interning repeated App and Address strings with Go's unique package and by dropping the region suffix from map keys. With memory still growing about 500MB per week, the in-memory hash map was replaced by a SQLite-backed store behind an LRU cache, so only active mappings stay in memory and restarts fetch only deltas. Planned next steps are Embedded Replicas sync and dictionary encoding of organization names.

  • Hash tables in ClickHouse and C++ Zero-cost Abstractions

    ClickHouse hardMaster

    ClickHouse implements GROUP BY and JOIN with a family of open-addressing hash tables generated from a common zero-cost C++ framework, specialized by key type and workload. Key design choices are CRC-32C-based hashing instead of identity, cryptographic or FNV1a hashes, linear probing with power-of-two resizing and a 0.5 load factor, and a separately stored zero/null cell instead of user-supplied empty or tombstone keys. On real web-analytics data, ClickHouse's HashMap aggregated about 20M unique keys in 7.4s, versus 9.0s for Abseil, 10.1s for Google DenseMap and 44.8s for std::unordered_map, with cache misses explaining the gap. Benchmarks should use real data distributions and real scenarios, not random numbers.

  • Go Turns 17

    The Go Blog easyNovice

    Go's 17th anniversary recap covers Go 1.26 and 1.27. On the language side, it adds generic methods, self-referential constraints, `new` with an initial value, and nested struct literal keys. In the standard library, `encoding/json/v2` reached GA with up to 10× faster unmarshaling and now backs v1, and a GC-based goroutine leak profiler shipped. Performance work includes the Green Tea GC as default (10–40% less GC overhead), experimental SIMD packages, stack-allocated append backing stores and size-specialized allocation. The release also brings post-quantum TLS/HPKE/ML-DSA, a 7.5-hour urgent response to the eMudhra weak-key incident, and tooling built for humans and AI agents: `go fix` modernizers, `//go:fix inline`, gopls MCP and the pkg.go.dev API.

  • Session revocations at scale

    Canva Engineering mediumAdept

    Canva moved its gateway session-revocation cache from per-pod MySQL loads to sorted binary chunks in S3, eliminating the database stampede when hundreds of gateway pods started during deploys. Revocations are packed into 16-byte records in sorted flat arrays split into 30-minute S3 objects. Gateways binary-search the downloaded bytes directly and refresh recent chunks with conditional GETs. A ZooKeeper-elected worker appends new revocations, using conditional PUTs for optimistic concurrency so that racing writers never lose updates. The theoretically O(N^2) rebuild still exceeds 2000 revocations/sec, memory use dropped 87.5%, and read replicas were cut to two.

The quest for software engineering knowledge.

Look:
Layout: