6.824 Lecture 5 - Go, Threads, and Raft

Go

  • Use threads when they make code easier to reason about, not for performance

  • Closures don’t pass-by-value unless you pass a non-pointer argument explicitly

  • Conditions

    Cond implements a condition variable, a rendezvous point for goroutines waiting for or announcing the occurrence of an event.

    Each Cond has an associated Locker L (often a *Mutex or *RWMutex), which must be held when changing the condition and when calling the Wait method.

    A Cond must not be copied after first use.

    • Calling Broadcast or Wait requires holding the lock to prevent the lost wakeup problem, where Broadcast may be called when the other thread is checking the condition and hasn’t called Wait yet.
  • Suggests that channels should be used sparingly in favor of locks, which seems antithetical to Go’s stated goals with channels.

Raft

  • Deadlocks when peers are waiting on each other’s response
Edit