This repository deep dives Go interface values, what they are, how they work, and when storing a value in a Go interface allocates memory on the heap.
- Labs: a step-by-step walkthrough of the topic
- FAQ: answers to frequently asked questions
- Links: links to related reference material
- Thanks: it takes a community
- Appendix: in-repo reference material
- Prerequisites: how to get from here to there
- Interface values: whatever you do, do not call it "boxing"
- Escape analysis: to malloc or not to malloc
- Missing mallocs: there's a heap of missing memory
- Lessons learned: key takeaways
- What does the
Q
suffix for instructions likeMOVQ
andLEAQ
mean? - What is the x86 assembly instruction
CALL
actually calling? - Where is the
CALL
instruction in ARM assembly? - What is the
hack
directory and the files inside of it?
Please refer to this answer from the assembly section in the appendix.
Please refer to this answer from the assembly section in the appendix.
Please refer to this answer from the assembly section in the appendix.
What is the hack
directory and the files inside of it?
The hack
directory is a convention I picked up from working on Kubernetes and projects related to Kuberentes. The directory contains scripts useful to the project, but not a core piece of the project itself. For example:
hack/
asm2md.py
: parses the output ofgo tool compile -S -wb=false ./tests/mem/*.go
and produces a markdown tableb2md.py
: parses the output ofgo test -v -count 1 -benchtime 1000x -bench BenchmarkMem -run Mem -benchmem ./tests/mem
and produces a markdown tablegen.py
: generates./tests/mem/bench_test.go
and./tests/mem/types_test.go
- ARM developer documentation
- x86 and amd64 instruction set
- A quick guide to Go assembly
- Go internal application binary interface (ABI) specification
- Logging, interfaces, and allocation
- Go introduction to escape analysise
- Type definitions for leaks
- Enums for escape
- Type definition for a Go stack frame
- Many thanks to reddit user nikandfor for their response to my post on this topic. Without that initial work, I am not sure this repository would exist today.
- My gratitude to Crypto Jones from Gopher Slack for keeping me honest about "boxing." 😃
- My colleague Michael Gasch who spent a lot of time proofreading this repository. Hear that y'all? Any mistakes you find? Totally Michael's fault! 😃
- Andrew Williams, another co-worker, who did not judge me when he helpfully explained cache lines.
- The first person who offered to help me dig into the assembly, Kevin Grittner!
- Several of my colleagues who directed me to a Trie structure for the repository's bespoke test framework:
- Michal Jankowski
- Zhanghe Liu
- Yiyi Zhou
- Mayank Bhatt
- Arunesh Pandey
- Assembly: reference section for go asm