Engineer finds swap can trigger 40ms Go GC stop-the-world pauses
A developer testing swap space to absorb memory spikes in production discovered that Go's garbage collector can experience severe stop-the-world pauses when its internal bookkeeping metadata gets swapped to disk. In a test on a Hetzner server, a median GC pause of about 51 microseconds ballooned to 40 milliseconds when that metadata resided on NVMe storage, with BPF tracing showing 228 page faults consuming nearly all of the pause time inside the collector's span-set reset routine.
GoKawiil's interpretation of the reporting above, not reported fact.
The finding suggests that Go's garbage collector keeps certain allocator metadata outside the normal heap in memory that never gets freed, meaning it can be swapped out like any other page and cause unexpectedly long pauses when read back during a stop-the-world phase. This could be a concern for teams running memory-constrained containers or cgroups with swap enabled, since latency-sensitive services might see rare but severe tail-latency spikes traceable to GC internals rather than application code. The author has published the test tools and scripts, inviting others to reproduce and investigate the issue further.
- Go's GC metadata lives outside the heap and is never freed, making it swappable.
- A test showed GC pause times jumping from ~51 microseconds to 40 milliseconds when metadata was swapped to NVMe.
- BPF tracing pinpointed 228 page faults inside runtime.spanSet.reset as the cause of the delay.
Source: frn.sh, 2026-10-05
Published there as: “A 40ms Go garbage collector pause caused by swap”
Read the original report → The summary and analysis above are GoKawiil's own, written from reporting by the source above. Facts and quotes belong to the original publisher.