title: Why does ucontext have such high overhead?
body: <p>The documentation for Boost.Context in Boost v1.59 reports the following performance comparison results:</p>
  
  <pre><code>+----------+----------------------+-------------------+-------------------+----------------+
  | Platform |      ucontext_t      |    fcontext_t     | execution_context | windows fibers |
  +----------+----------------------+-------------------+-------------------+----------------+
  | i386     | 708 ns / 754 cycles  | 37 ns / 37 cycles | ns / cycles       | ns / cycles    |
  | x86_64   | 547 ns / 1433 cycles | 8 ns / 23 cycles  | 16 ns / 46 cycles | ns / cycles    |
  +----------+----------------------+-------------------+-------------------+----------------+
  </code></pre>
  
  <p><a href="http://www.boost.org/doc/libs/1_59_0/libs/context/doc/html/context/performance.html" rel="nofollow">[link]</a></p>
  
  <p>I believe <a href="https://github.com/boostorg/context/tree/master/performance" rel="nofollow">the source code for these experiments is hosted on GitHub</a>.</p>
  
  <p>My question is, why is the overhead for <a href="https://en.wikipedia.org/wiki/Setcontext" rel="nofollow">ucontext</a> 20x higher than the Boost library's implementation?  I can't see any obvious reason why there would be such a big difference. Is the Boost implementation using some low-level trick that the ucontext implementers missed, or is something else happening here?</p>