Comment by measurablefunc
6 hours ago
How does this compare to Mojo?
Edit: nevermind. I answered the question for myself w/ vibe coding: https://pastes.io/mojo-event.
Workers: 1 | 2 | 4 | 8
Time: 12.01s | 8.01s | 5.67s | 5.49s
Events/sec: 16.7M | 25.0M | 35.3M | 36.4M
Obviously just a first pass & not optimized b/c I'm not a mojo expert.
I am not familiar with Mojo, so I do not know.
Compared to the coroutine implementations I do know, none of them quite met what I as looking for. The «trampoline» has been mentioned. I also needed a calling convention that fit the higher-level process model with a self pointer and a context, and a signal return value from each context switch. It also has to be thread safe to survive the pthreads. Not very difficult to do, but needs to be designed in from the beginning.
Same thing with random number generators. It will not work very well to keep state between calls in a static local variable or some global construction, needs to be kept thread local somewhere. Not difficult, but needs to be there from the start both for the basic generator and for the distributions on top of it.
Quite a bit more here: https://cimba.readthedocs.io/en/latest/background.html#