Go 1.26 e o Green Tea GC (agora default)


Go 1.26 traz mudanças significativas para sistemas de altíssima vazão, com concorrência pesada e pressão de memória. É o tipo de mudança que pode oferecer ganhos "de graça" — mas só se você souber o que está acontecendo por baixo dos panos e como medir o impacto real.
O Go 1.26 saiu em 10 de fevereiro de 2026 e a mudança mais impactante pra performance é silenciosa: o coletor de lixo experimental Green Tea, introduzido no Go 1.25, agora vem habilitado por padrão. Junto disso vieram outras coisas práticas pra quem roda serviço de verdade: o overhead base de cgo caiu ~30%, e o compilador agora consegue alocar o backing store de slices na stack em mais situações.
O Green Tea é o destaque. A ideia é reduzir o tempo gasto em GC em ~10% na maioria dos workloads, com alguns casos chegando a 40%.
O GC clássico do Go é um mark-sweep concorrente que "anda pelo grafo": ele segue ponteiro por ponteiro, objeto por objeto, espalhados pela heap. O problema é o hardware moderno:
A analogia que mais gosto: o GC antigo dirige por ruas da cidade com semáforo em cada esquina (cache miss = parada de centenas de ciclos). O Green Tea pega a rodovia.
A mudança central: o Green Tea muda a unidade de trabalho do GC de "objeto" para "página de memória" (blocos de 8 KiB no Go). Em vez de enfileirar objetos individuais, ele enfileira páginas inteiras contendo objetos recém-alcançáveis, e quando uma página é desenfileirada ele varre todos os objetos acumulados dela numa única passada sequencial. Ele troca a fila de trabalho em nível de objeto por uma fila em nível de span.
Isso resolve dois gargalos de uma vez: acessos sequenciais de memória (ótimos pro cache da CPU) e melhor escalabilidade em sistemas many-core e arquiteturas NUMA (através de um novo mecanismo de work-stealing). Bônus que vem por aí: como objetos dentro de um span têm layout previsível, dá pra usar instruções SIMD (tipo AVX512) no scan — um protótipo já mostrou potencial de reduzir o overhead de GC em mais 15-20%.
Se você atualizar pro Go 1.26, já está ligado — não precisa fazer nada. Mas o útil pra você é saber medir o impacto e poder reverter:
# Forçar ligar/desligar o Green Tea (controle explícito) GOEXPERIMENT=greenteagc go build ./... # liga (default no 1.26) GOEXPERIMENT=nogreenteagc go build ./... # desliga, pra comparar # Medir o efeito real no seu serviço — rode os dois e compare GODEBUG=gctrace=1 ./seu-servico # imprime stats de cada ciclo de GC
Para benchmark honesto, use o pacote testing com -benchmem e rode com e sem o experimento, comparando com benchstat:
go test -bench=. -benchmem -count=10 > old.txt # sem green tea go test -bench=. -benchmem -count=10 > new.txt # com green tea benchstat old.txt new.txt
E observe runtime/metrics (/gc/cycles/..., /gc/pauses) — que você pode exportar via OpenTelemetry, já que você usa Datadog/OTel. Esse é o jeito de provar ganho em produção, não em microbenchmark.
O Green Tea GC não é uma solução mágica para todos os cenários, mas ele brilha intensamente em arquiteturas específicas. Aqui estão alguns exemplos de onde você verá o maior impacto:
E o reality-check que vale ouro: o time do DoltHub testou no banco deles e não viu ganho — os próprios benchmarks do time de Go indicam que muitos programas reais não veem muita diferença; o resultado geral é positivo, mas inclui uma mistura de melhorias e regressões.
Conclusão prática: não trate como bala de prata. Trate como hipótese a medir. A ideia de uso mais valiosa pra você é adotar uma cultura de "GC profiling" no pipeline: comparar gctrace e runtime/metrics antes e depois de subir pro 1.26 nos seus serviços de maior vazão, e usar isso como argumento técnico. Onde der ganho, ótimo; onde não der, você documenta e segue.
Bônus: como o Green Tea premia localidade de dados, isso reforça boas práticas que você provavelmente já busca — structs contíguas, evitar ponteiro desnecessário, slices de structs em vez de slices de ponteiros em hot paths.
Go 1.26 brings significant changes for ultra-high throughput systems with heavy concurrency and memory pressure. It's the kind of change that can offer "free" gains — but only if you understand what's happening under the hood and how to measure the real impact.
Go 1.26 was released on February 10, 2026, and the most impactful change for performance is silent: the experimental Green Tea garbage collector, introduced in Go 1.25, is now enabled by default. Along with this came other practical things for those running real services: the base cgo overhead dropped by ~30%, and the compiler can now allocate the backing store of slices on the stack in more situations.
Green Tea is the highlight. The goal is to reduce the time spent in GC by ~10% in most workloads, with some cases reaching 40%.
Go's classic GC is a concurrent mark-sweep that "walks the graph": it follows pointer by pointer, object by object, scattered across the heap. The problem is modern hardware:
The analogy I like most: the old GC drives through city streets with a traffic light at every corner (cache miss = stall of hundreds of cycles). Green Tea takes the highway.
The core change: Green Tea changes the GC's unit of work from "object" to "memory page" (8 KiB blocks in Go). Instead of enqueuing individual objects, it enqueues entire pages containing newly reachable objects, and when a page is dequeued, it sweeps all accumulated objects in it in a single sequential pass. It replaces the object-level work queue with a span-level queue.
This solves two bottlenecks at once: sequential memory accesses (great for CPU cache) and better scalability in many-core systems and NUMA architectures (through a new work-stealing mechanism). Bonus coming up: since objects within a span have a predictable layout, we can use SIMD instructions (like AVX512) in the scan — a prototype has already shown the potential to reduce GC overhead by another 15-20%.
If you upgrade to Go 1.26, it's already on — you don't need to do anything. But the useful part for you is knowing how to measure the impact and be able to revert:
# Force enable/disable Green Tea (explicit control) GOEXPERIMENT=greenteagc go build ./... # enables (default in 1.26) GOEXPERIMENT=nogreenteagc go build ./... # disables, to compare # Measure the real effect on your service — run both and compare GODEBUG=gctrace=1 ./your-service # prints stats for each GC cycle
For honest benchmarking, use the testing package with -benchmem and run with and without the experiment, comparing with benchstat:
go test -bench=. -benchmem -count=10 > old.txt # without green tea go test -bench=. -benchmem -count=10 > new.txt # with green tea benchstat old.txt new.txt
And observe runtime/metrics (/gc/cycles/..., /gc/pauses) — which you can export via OpenTelemetry, since you use Datadog/OTel. This is the way to prove gains in production, not in microbenchmarks.
Green Tea GC isn't a magic bullet for every scenario, but it shines brightly in specific architectures. Here are a few examples of where you will see the biggest impact:
And the golden reality-check: the DoltHub team tested it on their database and saw no gain — the Go team's own benchmarks indicate that many real programs don't see much difference; the overall result is positive, but includes a mix of improvements and regressions.
Practical conclusion: don't treat it as a silver bullet. Treat it as a hypothesis to measure. The most valuable idea for you is to adopt a culture of "GC profiling" in the pipeline: comparing gctrace and runtime/metrics before and after upgrading to 1.26 in your highest throughput services, and using this as a technical argument. Where it yields gains, great; where it doesn't, document it and move on.
Bonus: since Green Tea rewards data locality, this reinforces best practices you probably already seek — contiguous structs, avoiding unnecessary pointers, slices of structs instead of slices of pointers in hot paths.