<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/rqw1rnfqm" -->

---
title: A 40ms Go GC pause caused by swap · Fernando Simões
description: A deep investigation into why running swap in production under memory pressure caused a 40ms stop-the-world garbage collection pause in a Go service. The...
canonical: https://daily.dev/posts/rqw1rnfqm
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: A 40ms Go GC pause caused by swap · Fernando Simões | daily.dev
og:description: A deep investigation into why running swap in production under memory pressure caused a 40ms stop-the-world garbage collection pause in a Go service. The...
og:url: https://daily.dev/posts/rqw1rnfqm
og:image: https://api.daily.dev/og/posts/RQw1rnFQm.png
og:image:alt: Post cover image
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# A 40ms Go GC pause caused by swap · Fernando Simões

**[Go Developers](https://daily.dev/sources/golangnuts)** · [@func25](https://daily.dev/func25) · 20 upvotes · 4 comments

## Summary

A deep investigation into why running swap in production under memory pressure caused a 40ms stop-the-world garbage collection pause in a Go service. The author traces the cause to Go's GC reading its bookkeeping metadata (spanSet reset and mark bit arena epoch tracking) during sweep and mark termination, and finding those pages evicted to swap by the kernel's per-cgroup, age-based eviction. Using bpf tracing, they isolate 228 major page faults accounting for 39 of the 40ms pause. They also observe that building a message jumped from 3-5ms to 105ms (NVMe) or 903ms (network volume) when its backing pages were swapped, though this cost is localized to a single goroutine rather than global. A follow-up update notes that Go 1.26's Green Tea garbage collector has negligible impact on this metadata-read cost.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://frn.sh/go-gc>

## Community discussion

Top comments from developers on daily.dev.

**@judevector** · 3 upvotes

> Its yet another the old classic Go's GC pause, No matter how optimize Go is the GC pause will always add an overhead on any infrastructure using it

**@bob72** · 1 upvotes

> When low latency is very important, just do not use swap.

**@jenueldev** · 1 upvotes

> The BPF trace is the key result here: 228 major page faults accounting for 39 of the 40 ms pause shows this was an OS memory-residency problem, not simply a collector algorithm problem. Monitoring cgroup swap-in pressure may be more actionable than tuning GOGC, especially since Green Tea barely changes this metadata-read path.

**@ristotoldsep** · 0 upvotes

> Nice write-up. The page-fault breakdown was especially useful.

## Similar posts on daily.dev

- [Go 1.26 turned on a new garbage collector. Whether it helps you depends on how your heap is shaped.](https://daily.dev/posts/go-1-26-turned-on-a-new-garbage-collector-whether-it-helps-you-depends-on-how-your-heap-is-shaped--4agvnc3q3) · Medium · 8 upvotes · 0 comments
- [Blog: Go 1.25 and 1.26: The Production Features Your Team Should Be Using Now](https://daily.dev/posts/blog-go-1-25-and-1-26-the-production-features-your-team-should-be-using-now-es16mx4y6) · Wawandco · 80 upvotes · 0 comments

---

Tags: [#linux](https://daily.dev/tags/linux), [#golang](https://daily.dev/tags/golang)

[View this post on daily.dev](https://daily.dev/posts/rqw1rnfqm)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"DiscussionForumPosting","mainEntityOfPage":"https://daily.dev/posts/rqw1rnfqm","headline":"A 40ms Go GC pause caused by swap · Fernando Simões","text":"Shared: A 40ms Go GC pause caused by swap · Fernando Simões","url":"https://daily.dev/posts/rqw1rnfqm","datePublished":"2026-09-21T01:43:44.809Z","dateModified":"2026-09-21T01:44:39.707Z","author":{"@type":"Person","name":"Phuong Le","url":"https://daily.dev/func25","image":"https://media.daily.dev/image/upload/s--HbVBqLGd--/f_auto,q_auto/v1697862633/avatars/avatar_s1rxG2e5sEfVSY1wCzdr8","interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"EndorseAction"},"userInteractionCount":8485}},"image":"https://media.daily.dev/image/upload/s--qPvKM23u--/f_auto/v1722860399/public/Placeholder%2009","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":20},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":4}],"sharedContent":{"@type":"WebPage","url":"https://api.daily.dev/r/6zuxGUCal"},"comment":[{"@type":"Comment","text":"Its yet another the old classic Go’s GC pause, No matter how optimize Go is the GC pause will always add an overhead on any infrastructure using it","datePublished":"2026-09-21T09:38:43.808Z","url":"https://daily.dev/posts/RQw1rnFQm#c-Lg75Ck9Kl","author":{"@type":"Person","name":"Jude Ndubuisi","url":"https://daily.dev/judevector","image":"https://media.daily.dev/image/upload/s--o64XhcS1--/f_auto/v1755785732/avatars/avatar_cV501Yh0AJJILSw4Y8yFm?_a=BAMClqZW0"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":3}},{"@type":"Comment","text":"When low latency is very important, just do not use swap.","datePublished":"2026-09-21T20:09:09.441Z","url":"https://daily.dev/posts/RQw1rnFQm#c-99Yud0cub","author":{"@type":"Person","name":"Bob","url":"https://daily.dev/bob72","image":"https://avatars.githubusercontent.com/u/193962566?v=4"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1}},{"@type":"Comment","text":"The BPF trace is the key result here: 228 major page faults accounting for 39 of the 40 ms pause shows this was an OS memory-residency problem, not simply a collector algorithm problem. Monitoring cgroup swap-in pressure may be more actionable than tuning GOGC, especially since Green Tea barely changes this metadata-read path.","datePublished":"2026-09-22T03:34:11.058Z","url":"https://daily.dev/posts/RQw1rnFQm#c-JH2ZLZsxd","author":{"@type":"Person","name":"Jenuel Oras Ganawed","url":"https://daily.dev/jenueldev","image":"https://media.daily.dev/image/upload/s--BadmiNyj--/f_auto/v1787625077/avatars/avatar_JJtZr4Sjm?_a=BAMAMicg0"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1}},{"@type":"Comment","text":"Nice write-up. The page-fault breakdown was especially useful.","datePublished":"2026-09-23T14:18:24.607Z","url":"https://daily.dev/posts/RQw1rnFQm#c-YjfLDlkzm","author":{"@type":"Person","name":"Risto Tõldsep","url":"https://daily.dev/ristotoldsep","image":"https://lh3.googleusercontent.com/a/ACg8ocLDWc6mZn0JwNmXXw6WY0L_HJ6pegzRttooC5VgtXESHSj3MNYx=s96-c"}}],"isPartOf":{"@type":"WebPage","url":"https://daily.dev/squads/golangnuts","name":"Go Developers"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Go Developers","item":"https://daily.dev/squads/golangnuts"},{"@type":"ListItem","position":3,"name":"A 40ms Go GC pause caused by swap · Fernando Simões"}]}
```

