Memory management in Go or To GC or not to GC
Hybrid Meetup #49 took place 2025-03-25 19:00 at CHECK24 Leipzig Office and we had a great introduction to memory management with Go by Fabian.
Slides and quiz can be found at mentimeter.com.
Some rules to program by:
- Stack allocation are better then heap allocation
- Number of heap allocations are more important than size of heap allocations
- Reduce the number of pointers in heap to reduce mark phase costs
- Be aware of the memory layout of you structs
- Make sure that every goroutine returns at some point (to avoid leaks)
- Use pprof to determine problems in you program
There is a great GC guide at: doc/gc-guide, and a few SO questions tagged with Go and GC
A tool for visualizing is structlayout.
$ go install honnef.co/go/tools/cmd/structlayout@latest
$ go install github.com/ajstarks/svgo/structlayout-svg@latest
You can then generate struct layout diagrams.
$ structlayout -json runtime slice | structlayout-svg -t "runtime.slice" > /tmp/struct.svg
$ structlayout -json bufio Reader | structlayout-svg -t "bufio.Reader" > /tmp/struct.svg
$ structlayout -json net/http Response | structlayout-svg -t "net/http.Response" > /tmp/struct.svg
Some more memory related types:
- sync.Pool
- memory arenas (experimental, but likely be declined)
Thanks again Fabian for the great presentation!
VPN and any of those problems
Run your own VPN mesh with headscale (or ionscale) as the tailscale control server.
Slides: LGO49-RYOVPN.pdf.
Where does the name tailscale come from? From the 2013 Google paper The tail at scale.
The long tail of products are never going to be that big [ie. as a hyperscaler] — almost everybody building almost everything doesn’t have any of those problems. – Avery Pennarun at 45:56…
PS. Find great gifs for your next presentation at gifcities.org.
Misc
- LLM use case snapshot: documentation navigation (using an LLM feels like using SO in the 2010s), writing 5-10 lines functions, writing narrow types, e.g. a helper to fill a type with random values; build tool scripts adjustments; emacs has gptel (example RAGmacs), a workflow that takes a URL and summarizes the content directly in emacs is easy; also great tool use in elisp or beyond; LLM as brainstorming/research tool
- Waterfall style systems building seems to be hard to follow these days (a grand plan seldom survives contact with reality), preferring throwaway code over design docs may be a better way, as designs can be discovered with code while throwing away code is part of building a theory around the requirements and forces surrounding software
Join our meetup to get notified of upcoming events.