GopherCon 2019 - Controlling the Go Runtime

conference, golang, gophercon2019, notes

These are some notes from my experiences at the GopherCon 2019. I don’t expect these will be laid out in any particularly useful way; I am mostly taking them so I can remember some of the bits I found most useful in the future.


How can we control the Runtime?

What is the Runtime?

  • garbage collection
  • goroutine scheduling
  • profiling / observation

Garbage Collection

  • GC()
  • KeepAlive(obj)
  • SetFinalizer(obj, f)

Scheduling

  • GOMAXPROCS(n)
  • Goexit() – terminate the goroutine
  • Gosched() – useful to yield in tight loops!
  • LockOSThread() / UnlockOSThread()
  • plus more in runtime/debug

Why should we control the Runtime?

  • some good reasons for testing etc.
  • some other speculative reasons