Go
Go's scheduler, channels and garbage collector — read from the runtime sources and from the proposals where those decisions were made.
- Sections
- 4
- Articles
- 5
- SOURCES
- 41
Sections
Articles
AdvancedPublishedChannels in Go: a buffer, a mutex and two queues — and which of them is working whenA channel has three parts: a ring buffer, an ordinary mutex, and two queues of waiting goroutines. Nearly everything surprising about it is about which of the three is working at a given moment. When it is the queue: the value bypasses the buffer and len(ch) stays zero. When it is the buffer: bigger is not faster, and the best size measured is not the largest. When it is only the mutex: a channel costs ten times an atomic, because it is a mutex plus bookkeeping.gochannelsselectconcurrencyruntime45 MIN6 SOURCESRead →AdvancedPublishedMaps in Go: the language contract, the Swiss Table, and four consequences of the designThree parts and one order: first what a map promises as a language construct — a zero value instead of an error, the two-result form, an unspecified iteration order and synchronisation; then how lookup is built in Go 1.24 — a fingerprint, a group of eight and the stopping rule; and only then four consequences with measurements: a miss costs more than a hit, the order is rotated rather than shuffled, an element's address cannot be taken, and len(m) == 0 does not mean the memory came back.gomapsswiss-tableruntimememory60 MIN9 SOURCESRead →AdvancedPublishedSlices in Go: three words, a shared array, and capacity growth by a rule other than the one everyone remembersA slice is a three-word header over somebody else's array. From that follows both the fact that append sometimes changes a neighbouring slice, and the fact that a ten-byte piece keeps fifty megabytes alive. And the rule “×2 up to 1024, then ×1.25” describes the runtime before Go 1.18 — and was not exact even then.goslicesappendmemoryruntime30 MIN8 SOURCESRead →AdvancedPublishedRange over a function in Go: the loop body is a function the iterator calls, and everything else follows`for x := range f` looks like sugar over an ordinary loop. It is not: the body becomes a separate function, `break` turns into `return false`, and a `return` from the body does not leave immediately — which is exactly why a `defer` inside the iterator always runs. Four iterator mistakes are caught by the runtime, and a traversal costs either nothing or a call per element, decided not by the iterator but by whether the compiler can see the function at the loop.goiteratorsrange-over-funcitercompiler40 MIN6 SOURCESRead →AdvancedPublishedGenerics in Go: eleven types, six code bodies, and a method still reached through a dictionaryThe language first: a constraint defines a type set, a type set defines the operations, and no interface can preserve the relation between an input type and an output type. Then the compiler: Go emits a version not per type but per shape — eleven types gave six code bodies, three different pointers gave one. And only then the measurement: a generic over a constraint with methods gives no direct call and trails fourfold, but four fifths of that four is lost inlining rather than indirection, and here that is measured rather than supposed.gogenericstype-parameterscompilergcshape55 MIN12 SOURCESRead →
Knowledge graph
NON-LINEAR · PREREQUISITE AWARETopics are connected, and the connections here were not drawn by hand — they were counted: every article states what it builds on and what it sits next to, and the picture is assembled from those statements. A dashed circle is a topic the articles already call related but that has not been written yet.
5 · 0 nodes and edges
Edges as a list
No connections yet: no article in this domain names another as related.
No connections: channels, maps, slices, range-over-func, generics