Full Byte Developer.

Is Go slower than Rust, or is your Go the problem?

Go is not slow on the clock in our run; it pays for memory in CPU and RAM, and Discord's careful Go still spiked.

Published here , updated · 8 sources

Go is not slow on the clock in the run behind the video. Wall time matched Rust closely, while Go paid nearly 3x CPU and about 1.7x memory. That gap is the real "Go is slow" argument. Discord's careful Go still spiked every two minutes on a huge live cache [1].

Quick start: separate wall time from CPU and memory

Is Go slow? On wall time, not in the video notes dated 2026-11-16: that timed loop of 10 million messages was about 228 ms in Go 1.27.1 and about 236 ms in Rust (rustc 1.74.1, -O, system allocator), each described as the mean of 3 runs on an Apple M-series Mac. The bill came elsewhere in those notes: Go used 1.11 s of CPU against 0.38 to 0.40 s for Rust, and peaked at about 305 to 313 MB of memory against 180 MB.

Is it your code? For Discord, no. Their engineers wrote: "we had written the Go code very efficiently and had very few allocations. We were not creating a lot of garbage" [1]. They also tried GC settings: "no matter how we configured the GC percent nothing changed" [1]. The cost came from the runtime's design meeting a very large live cache.

This is one micro-benchmark on one machine. It shows where Go pays for memory management. It does not show that either language is faster in general.

See where Go puts a value

Go's compiler decides at compile time whether a value can live on the stack or has to go to the heap. A value that never leaves its function can live on the stack and is gone for free when the function returns; one that is still referenced afterwards escapes to the heap [3]. In the benchmark, each message is stored in a global recent list, so the compiler puts it on the heap from the start.

bash
cat > /tmp/escape.go <<'EOF'
package main
type Message struct{ Body string }
var recent []*Message
func main() {
  m := &Message{Body: "x"}
  recent = append(recent, m)
}
EOF
go build -gcflags=-m -o /tmp/escape_bin /tmp/escape.go

Captured escape output on this host (Go 1.22.2, 2026-12-03):

text
./escape.go:5:8: &Message{...} escapes to heap

Good Go mostly means reading this output and keeping short-lived values off the heap. It does not help with data that has to stay alive, which was Discord's problem [1][3].

Watch the collector work

A heap value stays allocated after nothing points at it, until the garbage collector finds it. Go's collector starts from the roots (globals and goroutine stacks), marks everything it can reach, then sweeps what was not marked. Most of the marking runs at the same time as your code, with short stop-the-world phases [2].

bash
cat > /tmp/tinygc.go <<'EOF'
package main
import "time"
func main() {
  s := make([][]byte, 0)
  for i := 0; i < 200000; i++ {
    s = append(s, make([]byte, 1024))
  }
  _ = s
  time.Sleep(10 * time.Millisecond)
}
EOF
go build -o /tmp/tinygc /tmp/tinygc.go
GODEBUG=gctrace=1 /tmp/tinygc

Captured trace lines on this host (first cycles):

text
gc 1 @0.000s 9%: 0.011+0.14+0.019 ms clock, 0.044+0.097/0.099/0.080+0.076 ms cpu, 3->4->3 MB, 4 MB goal, 0 MB stacks, 0 MB globals, 4 P
gc 5 @0.011s 6%: 0.013+0.66+0.022 ms clock, 0.055+0.038/0.46/0.45+0.089 ms cpu, 53->56->53 MB, 57 MB goal, 0 MB stacks, 0 MB globals, 4 P

The pauses stay small while CPU for marking shows up in the cpu field. In the video benchmark, the longest stop-the-world phase across 15 collections was 0.055 ms, and summed marking CPU dominated the Go process CPU. Under load the Go runtime aims to give marking about 25% of CPU plus assists from your goroutines [2].

Memory follows the same logic. With the default GOGC=100, Go lets the heap grow to about twice the live data before the next cycle [2]. That is why a process with a large live set peaks well above "bytes of useful data."

Go heap allocate GC marks live sweep garbage Rust owner holds value scope ends / overwrite drop frees Wall time can match while Go pays mark CPU on a large live heap.

Go reclaims unreachable heap later through GC; Rust frees when ownership ends on that line.

Reproduce the two-minute spike idea

Go also forces a collection at least every two minutes, even when nothing is allocating. Discord's Read States service kept tens of millions of entries alive in an LRU cache, so every forced cycle had to mark all of it: CPU went up and latency spiked roughly every two minutes [1][2].

Run a long-lived Go binary with GODEBUG=gctrace=1 and leave it idle after it fills a large live set. You should eventually see a GC forced line around the two-minute mark [2]. Discord's Rust rewrite of that service did not show those latency spikes [1].

Compare what Rust does with the same message

In Rust every value has exactly one owner. When the owner goes out of scope, or when the place holding the value is overwritten, Rust runs drop and frees the memory on that line [4][5]. In the benchmark that is the slot assignment into a fixed ring buffer: the old message is freed right there. There is no collector and nothing to scan, so a big live cache costs nothing per GC cycle.

The price is the borrow checker. Keep a reference past the owner's lifetime and the program does not compile:

text
error[E0597]: `m` does not live long enough

That is error E0597, "borrowed value does not live long enough" [8]. For the plain-words lifetime story behind that error, read Rust lifetimes in plain words. Related Go concurrency vocabulary sits in goroutines vs coroutines and Go without async await. For another Rust rewrite story in this catalog, see Anthropic Rust rewrite of the Messages API.

Check what Go 1.26 changed

Green Tea is the default garbage collector in Go 1.26 [7]. It marks small objects page by page instead of following pointers from object to object across memory, and the Go team expects a 10 to 40% reduction in GC overhead in real programs that use the collector heavily [6]. A big live cache still gets marked, just more cheaply: the idle forced cycle in the video-era notes still cost tens of milliseconds of CPU with Green Tea on.

Pick by what you need

Shipping a service fast, with tiny pauses and a CPU and memory budget to spare: Go. Tail latency on a huge live heap, tight memory, or no collector at all: Rust. If someone says Go is slow, ask them which number they mean: wall time, CPU, or memory.

Mistakes in the language war

Quoting wall time alone after a GC-heavy workload, then declaring a winner.

Blaming "bad Go" when Discord already said allocations were few and GOGC changes did nothing [1].

Ignoring escape analysis (-gcflags=-m) while chasing micro-optimizations that never leave the heap [3].

Calling Rust free because there is no GC: you still pay in design time and in Arc/Mutex when ownership gets shared [4][5].

Treating Green Tea as "no more forced cycles." Forced collections still exist; they get cheaper to mark [2][6].

Browse the Dev explainers topic.

Send this to the friend who keeps saying Go is slow and Rust is the only fast choice.

Dark grid with a diagonal rail; a glowing cyan cube under a gray ring on the left faces a glowing amber cube on a taller pedestal under a gold ring, with small pucks between them.
Same track, two different cubes: wall time can look close while CPU and memory costs diverge.

Keep this guide

By Full Byte Developer

Filed under Dev explainers

Questions about this guide

Why did Discord's Go service spike every two minutes?

Go forces a garbage collection at least every two minutes, and each forced cycle had to mark Discord's huge live LRU cache. Discord says the spikes came from that scan, and that changing the GC percent did not help.

Does Go stop the program for long during garbage collection?

Marking runs concurrently with the program and only short phases stop the world. In the run behind the video, the longest stop across 15 collections was 0.055 ms; the cost showed up as CPU spent marking.

When does Rust free memory?

When the owner of a value goes out of scope or its place is overwritten, Rust runs drop on that line. There is no tracing collector.

What does Green Tea change in Go 1.26?

Green Tea is the default collector in Go 1.26. It marks small objects page by page instead of chasing single objects, and the Go team expects 10 to 40% less GC overhead in programs that use the collector heavily.

Sources

Next in this stack