Skip to content
Snippets Groups Projects

Smooth out thread unparking spikes

Closed Peter Cai requested to merge p5cai/libfibre:patch-thundering-herd into master
  1. May 17, 2022
    • Peter Cai's avatar
      Smooth out thread unparking spikes · b8d6be0d
      Peter Cai authored
      Currently, the scheduler unparks new threads (processors) as long as
      there is any incoming task to be executed. This can cause unwanted
      spikes in thread unparking, which leads to unnecessary work stealing
      especially when the number of worker threads is greater than the number
      of physical CPU threads.
      
      Smooth this out by implementing a technique similar to what's done in
      Golang and Tokio -- only wake new threads up if an idle-spininng thread
      finds new work and there are still incoming work left to be taken. This
      does not apply if no thread is idle-spinning, of course. The IdleSpinMax
      value is also increased to make this approach actually useful.
      
      The current implementation relies on a global mutex and an atomic, which
      causes some inconsistency in performance that probably needs to be
      investigated. However, when trying to benchmark with more worker threads
      than physical CPU threads, this now enables libfibre to perform on the
      same level as Golang and Tokio.
      b8d6be0d
    • Peter Cai's avatar
      Set up gitignore file · dcfecc58
      Peter Cai authored
      ...so that we don't end up with a bunch of annoying untracked object
      files
      dcfecc58
Loading