Mechanical Sympathy in Go

Teiva Harsanyi
Nov 20, 2020

A couple of months ago, I wrote a post about Go and CPU Caches: https://teivah.medium.com/go-and-cpu-caches-af5d32cc5592

Then, I wanted to extend the scope of this post. Following this idea, I had the chance to give a talk to GopherCon Turkey 2020. The topic is the following: Mechanical Sympathy in Go.

I tried to cover the following topics:

  • CPU architecture introduction
  • Locality of reference principles: temporal vs spatial locality, predictability, striding
  • Data-oriented design: introduction, slice of structs vs struct of slices, etc.
  • Pitfalls due to a bad utilization of CPU caches: cache associativity, critical stride
  • Concurrency: false sharing

Here is the video of my talk:

https://www.youtube.com/watch?v=cetmDfqr2BU

The beginning of the talk was unfortunately ousted. Yet, you can find the slides here for the missing introduction:

Follow me on Twitter @teivah

--

--

Teiva Harsanyi

Software Engineer @Google | ๐Ÿ“– 100 Go Mistakes author | ๆ”นๅ–„