proomt

Search

Search posts, papers, and topics

All posts

The Go BlogMichael Matloob7 min readintermediate

Size-Specialized Memory Allocation

Summary

Go 1.27 adds a set of span‑class‑specific malloc functions for allocations ≤ 80 bytes. By generating a tiny, constant‑size allocator per span class the runtime can inline size‑dependent work (e.g. zero‑clear) and skip span‑class lookup, yielding 20‑30 % faster small allocations and ~1 % overall speed‑up for allocation‑heavy programs. The implementation is generated automatically via an AST inline…

  • Specialized malloc functions are generated for each span class (size class + pointer‑ness) up to 80 bytes.
  • Constant‑size clears let the compiler emit inline zeroing instead of calling `memclrNoHeapPointers`.
  • The compiler can emit direct calls to the specialized allocator when the span class is known at compile time, otherwise it falls back to a dynamic dispatch.
  • Code‑size and icache pressure were the primary limits; the team stopped at 80 bytes after benchmarking.

Small allocations dominate Go workloads (e.g. interface values, strings, slice headers). Even a modest per‑allocation speed‑up translates into measurable end‑to‑end gains for services that allocate heavily, without requiring any code changes from users.

6/10

Related reading

  1. What Go Taught Us About Java Garbage Collection

    ParparVM’s GC was tuned by lowering the allocation‑trigger floor, adding configurable thresholds, parallel marking, mutator assistance, and proper weak/soft reference handling. These changes cut RSS from 98 MB to 38 MB, reduced worst‑case GC pauses from seconds to sub‑second, and improved cache hit rates with a recency‑based eviction policy.

    CodeName Onecodenameone.com7 min
  2. 1 points

    Saving another 100TB of RAM with math (and Rust)

    Cloudflare reduced the memory footprint of its Pingora Backend Router by re‑examining the consistent‑hashing implementation in the pingora‑ketama library. By increasing the number of virtual hash points per server from the default 1 to the standard 160 (and applying weighted hashing based on disk capacity), they cut the per‑node overhead enough to reclaim >100 TB of RAM across the fleet. The post…

    Hacker News front pagecloudflare.com13 minHN478120lobste.rs33
  3. Lies, Damn Lies and Benchmarks

    Codename One engineers dissect why benchmark numbers can be misleading, then share concrete work on GC tuning, proper weak/soft references, and a new probing sequence for their open‑addressed HashMap that cuts miss‑probe counts from >16 k to ~1.5 per lookup.

    CodeName Onecodenameone.com20 min
  4. Vectorized and performance-portable Quicksort (2022)

    Google’s Highway library now includes a fully portable SIMD‑vectorized quicksort that runs 9‑19× faster than C++ std::sort. By using compress‑store (or permute‑based emulation) for partitioning, the same C++ code targets AVX2, AVX‑512, NEON, SVE and RISC‑V V. Benchmarks show 0.5 GB/s on an Apple M1 and >1 GB/s on a 3 GHz Skylake, beating prior architecture‑specific sorts. The implementation and a…

    Hacker News front pagegoogleblog.com3 minHN460142