r/cpp • u/germandiago • Jun 30 '26
Stackful fibers with 3.6ns context switch. Silk fibers.
https://clickhouse.com/blog/silkI just read an article about Silk, the new stackful fibers engine from Clickhouse. It can switch stackful fibers at an amazing 3.6ns and does not allocate on steady state.
Maybe asio could reuse some of the knowledge for the linux/io_uring backend (not sure it applies to the specific case since Boost.asio focuses nowadays on stackless, though it has a fibers and a stackful coros backend also).
53
Upvotes
View all comments
Show parent comment
15
u/not_a_novel_account cmake dev Jun 30 '26
That's why I linked the code, it's literally
boost::context, as in, a vendored copy of the code which says "this isboost::context".You could achieve identical performance for switching using
boost::contextsince Kowalke wrote the code 14 years ago.That's the first thing I checked because there haven't been any new ISA changes which would make this faster, so I was curious what innovation they could have found. I figured maybe they were on some architecture I wasn't familiar with, or were violating the calling convention in order to shave off register spills. Nope,
boost::context.The rest is a lot of work, good allocators are hard, io_uring from scratch is not a cakewalk, so on and so forth. But there's nothing here you won't find equivalent versions of in Seastar or implemented at any high-performance Linux shop east of the Mississippi.