- Last Updated: [[2020-12-28]] - [[2020-12-19]] - - In [[Go]], goroutines are special types of [[User-space thread]]s. They do not correspond 1:1 with [[Kernel thread]]s; in fact, much of [Go's performance]([[Go is built with performance in mind]]) is attributable to the fact that hundreds of thousands of goroutines can run on one kernel thread. - How Goroutines make [Go incredibly performant]([[Go is built with performance in mind]]) - The [[Go Scheduler]] gives Go apps more control and optimization of how programs are executed. It enables goroutines to be [multiplexed]([[Multiplexing]]) into a smaller number of OS threads - Goroutines have a resizable stack that starts at 2 KB. - Goroutines scale in memory only when necessary. - They have a faster startup time than threads - Sources - [[Mihail Stoykov]] - [[Why Should You Learn Go]] - "> Goroutines have growable segmented stacks. That means they will use more memory only when needed. Goroutines have a faster startup time than threads. Goroutines come with built-in primitives to communicate safely between themselves (channels). Goroutines allow you to avoid having to resort to mutex locking when sharing data structures. Also, goroutines and OS threads do not have 1:1 mapping. A single goroutine can run on multiple threads. Goroutines are multiplexed into small number of OS threads. ([View Highlight](https://instapaper.com/read/1369930312/14869441))" -