Skip to content

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

Datadog Engineering 9 min read Case study mediumAdept

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

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.

Related posts

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

    Datadog Engineering mediumAdept

    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.

  • The effect of switching to TCMalloc on RocksDB memory use

    Cloudflare mediumAdept

    Quicksilver's memory roughly doubled after its storage moved to RocksDB, climbing from about 15GB to 30GB over several days. Heap profiling showed the heap was about a third of RSS, which pointed to the allocator rather than a leak. glibc malloc gives threads independent per-thread arenas (60-80 arenas for about 25 threads), and memory cannot move between them, so fragmentation multiplies. Mitigations such as MALLOC_ARENA_MAX, periodic malloc_trim and M_MMAP_THRESHOLD each cost lock contention or syscalls, while TCMalloc's middle-end moves freed memory between per-core caches and cut memory use by 2.5x.

  • Size-Specialized Memory Allocation

    The Go Blog hardMaster

    Go 1.27 adds size-specialized variants of the runtime's mallocgc for allocations of 80 bytes or fewer, one per span class (size class plus pointer/no-pointer), making these allocations 20-30% faster and allocation-heavy programs up to 1% faster. The compiler calls a specialized function directly when the size is known at compile time; otherwise mallocgc dispatches to it dynamically. Most of the gain comes from clearing memory with constant-size inline instructions instead of calling memclrNoHeapPointers, plus precomputed span classes, cheaper pointer bookkeeping and forced inlining. The functions are produced by a go/ast-based generator to keep copies in sync, and the 80-byte cutoff balances speed against binary size and instruction cache pressure. It can be disabled with GOEXPERIMENT=nosizespecializedmalloc.

  • Bun v1.2.1

    Bun mediumAdept

    Bun v1.2.1 fixes 32 bugs and adds S3 storage class support, X25519 key generation in crypto.generateKeyPair, Node's --zero-fill-buffers flag, indented inline snapshots in bun test, and a bunfig option to disable minification for HTML imports. The most technical change fixes GC memory accounting: WebKit reports a ref-counted string's cost as its byte length divided by its reference count, so Bun's Zig bindings, which briefly held an extra reference, under-reported string memory (a 64 KB file read reported as 32 KB). A new single-step createUTF8ForJS pattern avoids that extra reference. Other fixes cover fs.Stats and bigint fstat parity with Node, EINTR retries in fs reads and writes, a child_process spawn race, Worker reliability, and memory leaks in Bun.serve() and Bun.pathToFileURL caused by refcount mistakes.

  • May 18 Replit downtime

    Replit mediumAdept

    A latent Go bug leaked RWMutex read-locks whenever a configuration kind had no handler. The first write-lock attempt, during a configuration push to all clusters at once, deadlocked every Repl VM and caused about two hours of total downtime. Recovery was slowed by liveness probes that failed open, a rollback that took two tries and reset the added capacity, and an autoscaler that ignored request volume and shrank instance groups. Fixes include fast, reliable rollbacks, staggered config rollouts with jitter, self-healing health and liveness logic, and more static analysis.

The quest for software engineering knowledge.

Look:
Layout: