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 38 · Sep 14 – 20, 2026

Size‑Specialized Memory Allocation

Nice to knowruntime

What changed
Go 1.27 introduces size‑specialized allocation functions that improve performance of small allocations.
Production impact
The source does not say.
Try it
Run a benchmark that allocates many small objects and observe any change in allocation time.
Source
go.dev/blog/size-specialized-allocations

Understand it, then run it

Run it now

Todaygo
// This program demonstrates that allocating many small structs is fast
// in Go 1.27.1 thanks to size‑specialized allocation. It measures the
// time to allocate 10 000 000 structs of 16 bytes each and prints the
// average time per allocation in nanoseconds.
package main

import (
	"fmt"
	"time"
)

type small struct {
	a, b uint64 // 16 bytes
}

func main() {
	const n = 10_000_000
	start := time.Now()
	// Allocate a slice of small structs. The runtime will use the
	// specialized allocator for 16‑byte objects.
	s := make([]small, n)
	// Touch the slice to keep the compiler from optimizing away the
	// allocation.
	for i := range s {
		s[i].a = uint64(i)
		s[i].b = uint64(i) * 2
	}
	elapsed := time.Since(start)
	avg := float64(elapsed.Nanoseconds()) / float64(n)
	fmt.Printf("Allocated %d small structs in %v (%.2f ns each)\n", n, elapsed, avg)
}

What it printed when we ran it on Go 1.27.1

Allocated 10000000 small structs in 152.207314ms (15.22 ns each)

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