When storing a value in a Go interface allocates memory on the heap.

Overview

Go interface values

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

Labs

  1. Prerequisites: how to get from here to there
  2. Interface values: whatever you do, do not call it "boxing"
  3. Escape analysis: to malloc or not to malloc
  4. Missing mallocs: there's a heap of missing memory
  5. Lessons learned: key takeaways

FAQ

What does the Q suffix for instructions like MOVQ and LEAQ mean?

Please refer to this answer from the assembly section in the appendix.

What is the x86 assembly instruction CALL actually calling?

Please refer to this answer from the assembly section in the appendix.

Where is the CALL instruction in ARM assembly?

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:

Links

Thanks

  • 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

Appendix

  • Assembly: reference section for go asm
You might also like...
dagger is a fast, concurrency safe, mutable, in-memory directed graph library with zero dependencies
dagger is a fast, concurrency safe, mutable, in-memory directed graph library with zero dependencies

dagger is a blazing fast, concurrency safe, mutable, in-memory directed graph implementation with zero dependencies

My clean Go solution that's faster than 100%, takes up less memory than 100%.

Remove-element My very clean Go solution that's faster than 100% of all solutions on Leetcode. Leetcode Challenge: "Given an integer array nums and an

A Go implementation of an in-memory bloom filter, with support for boltdb and badgerdb as optional data persistent storage.

Sprout A bloom filter is a probabilistic data structure that is used to determine if an element is present in a set. Bloom filters are fast and space

A memory-efficient trie for testing the existence/prefixes of string only(for now).

Succinct Trie A memory-efficient trie for testing the existence/prefixes of string only(for now). Install go get -u github.com/nobekanai/sutrie Docume

ZSet is an in-memory Redis like sorted set datastructure

zset Getting Started Installing To start using hash, install Go and run go get: $ go get -u github.com/arriqaaq/zset This will retrieve the library. U

A thread safe map which has expiring key-value pairs

~ timedmap ~ A map which has expiring key-value pairs. go get github.com/zekroTJA/timedmap Intro This package allows to set values to a map which will

Null Types, Safe primitive type conversion and fetching value from complex structures.

Typ Typ is a library providing a powerful interface to impressive user experience with conversion and fetching data from built-in types in Golang Feat

A threadsafe single-value cache for Go with a simple but flexible API

SVCache SVCache is a threadsafe, single-value cache with a simple but flexible API. When there is no fresh value in the cache, an attempt to retrieve

Decode / encode XML to/from map[string]interface{} (or JSON); extract values with dot-notation paths and wildcards. Replaces x2j and j2x packages.

mxj - to/from maps, XML and JSON Decode/encode XML to/from map[string]interface{} (or JSON) values, and extract/modify values from maps by key or key-

Owner
Andrew Kutz
A father, husband, friend, son, and VMware engineer.
Andrew Kutz
Data Structure Series: Heaps and heap applications

heaps Data Structure Series: Heaps and heap applications Current Updates: GO: heaps.go: max-heap implementation standard add, remove, and restore func

Fatih 1 Mar 17, 2022
A data structure for storing points.

ptree This package provides an in-memory data structure for storing points. Under the hood it stores points in a tree structure where nodes are spatia

Josh 17 Apr 18, 2022
Storing strings without GC overhead

stringbank stringbank allows you to hold large numbers of strings without bothering the garbage collector. For small strings storage is reduced as the

Phil Pearl 67 Nov 17, 2022
Package for indexing zip files and storing a compressed index

zipindex zipindex provides a size optimized representation of a zip file to allow decompressing the file without reading the zip file index. It will o

High Performance, Kubernetes Native Object Storage 37 Nov 30, 2022
Fast in-memory key:value store/cache with TTL

MCache library go-mcache - this is a fast key:value storage. Its major advantage is that, being essentially a thread-safe . map[string]interface{} wit

O.J 86 Nov 11, 2022
An in-memory string-interface{} map with various expiration options for golang

TTLCache - an in-memory cache with expiration TTLCache is a simple key/value cache in golang with the following functions: Expiration of items based o

Rene Kroon 549 Dec 7, 2022
An in-memory string-interface{} map with various expiration options for golang

TTLCache - an in-memory cache with expiration TTLCache is a simple key/value cache in golang with the following functions: Expiration of items based o

Rene Kroon 544 Dec 2, 2022
Recursively searches a map[string]interface{} structure for another map[string]interface{} structure

msirecurse Recursively searches a map[string]interface{} structure for existence of a map[string]interface{} structure Motivation I wrote this package

Fred Moyer 1 Mar 3, 2022
BTree provides a simple, ordered, in-memory data structure for Go programs.

BTree implementation for Go This package provides an in-memory B-Tree implementation for Go, useful as an ordered, mutable data structure. The API is

Google 3k Nov 28, 2022
Package mafsa implements Minimal Acyclic Finite State Automata in Go, essentially a high-speed, memory-efficient, Unicode-friendly set of strings.

MA-FSA for Go Package mafsa implements Minimal Acyclic Finite State Automata (MA-FSA) with Minimal Perfect Hashing (MPH). Basically, it's a set of str

SmartyStreets (Archives) 293 Oct 27, 2022