Implementing parallelism: how we added threading and multicore support in TinyGo

Day 1 | 17:00 | 00:30 | UD2.120 (Chavanne) | Ayke van Laethem


Note: I'm reworking this at the moment, some things won't work.

The stream isn't available yet! Check back at 17:00.

Parallelism is hard. So until recently, TinyGo (the alternative Go compiler for small systems) simply did not implement it. Instead, we used a simple single threaded scheduler that provides concurrency, but not parallelism. This made all programs act like GOMAXPROCS=1, which caused some practical issues.

Over the past few months we added support for running multiple goroutines in parallel on Linux, MacOS, and on the dual-core RP2040 chip. This required changes in many parts of TinyGo that previously assumed single threaded operation.

This talk will cover a variety of topics that may be interesting to anybody who wants to learn about low level primitives:

  • Which parts of Go are affected by parallelism.
  • Futexes: the building block of concurrency primitives on modern operating systems.
  • How some synchronisation primitives like channels and sync.Mutex are implemented in TinyGo.
  • How parallelism is implemented in TinyGo on Linux, MacOS, and the RP2040 chip.