Oct 27, 2026

Go 1.27 adds size-specialized allocation for small objects of 80 bytes or fewer

The Go runtime uses generated allocation functions per size class, making small allocations up to 20-30% faster.

The Go team has explained how Go 1.27 speeds up small heap allocations. The runtime now includes specialized allocation functions for objects of 80 bytes or fewer, with one variant for each combination of size class and whether the object contains pointers.

According to the post, individual allocations can be up to 20-30% faster, which translates to allocation-heavy programs running up to 1% faster. The largest gains come from clearing memory with inlined instructions when the size is a known constant, and from skipping some calculations and function calls.

The authors chose 80 bytes as the cut-off after benchmarking, because larger specialized functions take up instruction cache space and can cancel the benefit. The variants are produced by a generator so the copies do not drift apart. The change was held back from Go 1.26 for more tuning.

No code changes are needed: programs get the improvement when built with Go 1.27. If a regression is suspected, the post says the feature can be disabled at build time with GOEXPERIMENT=nosizespecializedmalloc, and asks developers to file an issue in that case.

Sources

Verified Oct 27, 2026 (official source). goruntimeperformancedevelopertools