Fiberus - a new Haxe target with a native, fiber-based runtime for multiprocessing

Thanks for the love, but you give me way too much credit. Im not talented, just a little relentless :smiley:

In essence it’s a new a compiler target (similiar to hxcpp, in fact I use the same buildXml system) that emits C-code. The compiler transforms the Haxe AST to a C AST & code emission with some tweaks (e.g. escape analysis, shadow stack frames) to play into the nature of fibers. The runtime is built around a central lock-free scheduler + work stealing + work submission and fast IO (io_uring).

Some years ago I watched https://gdcvault.com/play/1022186/Parallelizing-the-Naughty-Dog-Engine and fell in love with the idea. But raw C & memory management sucks and I wondered if this could work with Haxe using a special GC.

But I never had the time available to start or even think of making it work (like I would have to learn and master Ocaml first). That changed with the advent of AI Tooling. I was finally able to make this a multi-month long experiment in my free time instead of a multi-year full-time endeavor.

If you wanna know more about fibers and the nitty-gritty low-level details, I can recommend reading the code on GH or the amazing blogpost Fibers, Oh My!