3 ms·
> Goroutines are now asynchronously preemptible. As a result, loops without function calls no longer potentially deadlock the scheduler or significantly delay
by jhoechtl 7y ago
> Goroutines are now asynchronously preemptible. As a result, loops without function calls no longer potentially deadlock the scheduler or significantly delay garbage collection.
What does that mean in practice? Can I perform expensive calculations in parallel exhausting all cores?
- diegobernardes 7y agoThis means that the threads can't be blocked forever. The way Go scheduler work is to check during function calls if the current goroutine has executed for some period of time, after that the scheduler will remove the goroutine from the thread and open space for other goroutines to execute. But if you're doing a loop without function calls, imagine a for {}, in this case, the thread will be locked forever. Now with 1.14, this don't happen anymore. In my opinion the expected result will be better tail latencies.
- pansa2 7y agoGo has supported running goroutines in parallel since before 1.0, and it’s been the default behaviour since version 1.5, released in 2015.
- tapirl 7y agoIt means the following program will happily exit now. package main import ( "time" "runtime" ) func main(){ for i := runtime.NumCPU(); i > 0; i-- { go func() { for {} }() } time.Sleep(time.Second) println("bye") }