Ideally the cost of a coroutine call should be comparable to the cost
of an indirect function call. Currently Boost.Coroutine, at least on
Linux-x86-GCC come close to 150% of the speed of Boost.Function,
itself comparable to the cost of an indirect function call. The Win32
implementation has not been benchmarked, but it might be slightly slower
because of the need to switch exception contexts and some missed
optimization opportunities. The
makecontext based implementation is
at least three orders of magnitude slower than the others due to the
need to perform a system call per context switch.
To get good performance on
Win32 systems, a call to
ConvertThreadToFiber should be performed on each thread that
invoke coroutines. Else a much slower code path will be used that may
potentially make context switches extremely expensive.
|Copyright © 2006 Giovanni P. Deretta|