Aff and Promise event queues?

I have some questions about Aff.

V8 has an asynchronous completion queue. This is how JavaScript Promises are completed. https://v8.dev/blog/fast-async

Aff has its own completion queue, by @natefaubion : https://github.com/purescript-contrib/purescript-aff/blob/v5.1.2/src/Effect/Aff.js

Why does Aff need its own completion queue? What do we get from that approach that we can’t get from just using the V8 queue, as in promises?

Having two async completion queues going in the same runtime strikes me as susceptible to starvation and strange race conditions? Do we have to attend to how they interact? Is aff-promise really as effortless as it looks, @nwolverson ?

4 Likes

I guess React also has its own asynchronous completion queue. https://indepth.dev/posts/1008/inside-fiber-in-depth-overview-of-the-new-reconciliation-algorithm-in-react

So using Aff in a React app, we have three asynchronous completion queues in the runtime, each scheduling work for the one OS thread. Does this work out well in practice? In my limited experience… yes, it seems fine?

1 Like

Maybe Aff needs its own async completion queue because JavaScript Promise.resolve() flattens nested promises?

1 Like