Stream: compiler development

Topic: async + coroutines


view this post on Zulip Brendan Hansknecht (Oct 20 2025 at 00:24):

Not really compiler development... more platform theorizing. I was chatting with @Richard Feldman and one thing we discussed is the tradeoff between being in async land and being in coroutine land. As roc stands today (and for the planned future), we like nice synchronous apis. As such, we do not play nicely with async.

This can be seen very clearly in basic-webserver. We have an sync platform and it is calling into roc. At that point, we are a blocking workload in an async world and we don't have a clean way to run requests in the async system. This is pretty awful. We literally spawn_blocking and all of the effects that roc calls are sync. This essentially ruins most of the reasons you would use async rust.

That said, depending on the platform language, we still want to be able to integrate with their async ecosystem (e.g. the most robustly tested web servers in many languages are built on async). This is a pure rust prototype looking into bridging that gap. It is a lot of vibe coding, but the core is definitely something we could build out if wanted: https://github.com/bhansconnect/hyper-may-async-bridge

It is a really basic webserver with a sample set of endpoints that all just hit simulated delay (sleep instead of real io). I tried to model a handful of situations that map reasonably to real workloads. The system is implemented in 100% async, 100% coroutines, and a hybrid that uses channels and condvars to syncronize between the two systems. Note, the coroutines are cooperative.

This is just a prototype. The perf seems to be reasonable, but definitely falls short of both fully async and fully coroutine. The cost is expected due to the forcing these two systems to communicate and share resources. That said, I definitely think there is room to squash a lot of the overhead. Technically speaking, the go runtime is a well integrated for the this kind of a perf hybrid.

I think for a next version of basic webserver that properly cooperates with async rust, this would be interesting to build off of.

view this post on Zulip Luke Boswell (Oct 20 2025 at 01:51):

Real cool exploration @Brendan Hansknecht, thank you for sharing.


Last updated: Nov 08 2025 at 12:13 UTC