Avoiding high GC overhead with large heaps | Gopher Academy Blog
The Go Garbage Collector (GC) works exceptionally well when the amount of memory allocated is relatively small, but with larger heap sizes the GC can end up using considerable amounts of CPU. In extreme cases it can fail to keep up. The GC’s job is to work out which pieces of memory are available to be freed, and it does this by scanning through memory looking for pointers to memory allocations. To put it simply, if there are no pointers to an allocation then the allocation can be freed. This works very well, but the more memory there is to scan the more time it takes. Suppose you’ve written an in-memory database, or you’re building a data pipeline that needs a huge lookup table. In those scenarios, you may have Gigabytes of memory allocated. In this case, you may be losing quite a bit of potential performance to the GC. How much of a problem? Let’s find out! Here’s a tiny program to demonstrate. We allocate a billion (1e9) 8 byte pointers, so approximately 8 GB of memory. We then forc
Avoiding high GC overhead with large heaps | Gopher Academy Blog Gopher Academy Blog Share Phil Pearl Dec 25, 2018 11 min read Avoiding high GC overhead with large heaps The Go Garbage Collector (GC) works exceptionally well when the amount of memory allocated is relatively small, but with larger heap sizes the GC can end up using considerable amounts of CPU. In extreme cases it can fail to keep up. What's the problem? The GC's job is to work out which pieces of memory are available to be freed, and it does this by scanning through memory looking for pointers to memory allocations. To put it s
Explore this link on the map →related reading
- Memory Allocation in Go | Melatoninghiant3223.github.io
- A Guide to the Go Garbage Collector - The Go Programming Languagego.dev
- abseil / Performance Hintsabseil.io
- Frequently Asked Questions (FAQ) - The Go Programming Languagego.dev
- CS107E Assignment 4: Stack and Heapcs107e.github.io
- Fundamentals of garbage collection - .NET | Microsoft Learnlearn.microsoft.com
- Untangling Lifetimes: The Arena Allocator - by Ryan Fleurydgtlgrove.com
- Profiling Go programs with pprofjvns.ca
- Why (most) High Level Languages are Slow // A Random Walk Through Geek-Spacesebastiansylvan.com
- Making a Go program run 1.7x faster with a one character change • Harry Marrhmarr.com
- Working With SGen | Monomono-project.com
- Mechanical Sympathymechanical-sympathy.blogspot.com