[llvm-dev] Efficient Green Thread Context-Switching

Joerg Sonnenberger via llvm-dev llvm-dev at lists.llvm.org
Fri Mar 27 12:29:10 PDT 2020

On Fri, Mar 27, 2020 at 01:51:48PM -0500, Joshua Thomas Wise via llvm-dev wrote:
> The paper shows the results of many benchmarks, all of which show this
> model heavily outperforming existing models of context switching, in
> both speed and memory usage. For example, it mentions that the POSIX
> functions makecontext() and swapcontext() save a structure that’s 936
> bytes in size (768 on my machine), but their model generates context
> switches that save only 8-80 bytes of CPU state, depending on which
> existing optimizations are able to apply to the specific context switch.
> In some cases, the entire context switch is reduced to 1 or 2 instructions.

Take a look at the the setjmp/longjmp intrinsics. IMO it is dishonest to
compare with makecontext/swapcontext, which generally have to save the
full FPU state and that's where the majority of the data is.


More information about the llvm-dev mailing list