Trying to implement fiber in C++20 coroutine
https://github.com/felixaszx/coro-fiber
I did some experiments with this. The result is very surprising. I tested this on my Ryzen 7700X (8c/16t) Windows 11.
This is barely optimized. But, its is able to outperform boost::fiber in single-thread context switching (\~20ns vs \~60ns, LLVM 21, std=c++20, the timer takes \~20ns). And even with the work stealing algorithm across all 16 threads trying to steal 1 fiber, it can still maitain at \~22ns of context switching.
I guess this is really uncommon since most of the time we expect our fiber to have some real workload rather than infinitely yielding to some other fibers. I am looking for some advices about how to improve the scheduler, right now it is just doing round robin locally or steal from other thread's queue if empty.
https://redd.it/1sbkbei
@r_cpp
Post #24916
20