ocaml-multicore / eio

Effects-based direct-style IO for multicore OCaml
Other
561 stars 72 forks source link

Eio 1.0 progress tracking #388

Closed talex5 closed 7 months ago

talex5 commented 1 year ago

Status of major features needed for Eio 1.0 (a tick means would be OK to ship in its current state):

Backends:

Non-essential backends (but would be good to check that the cross-platform API works for them before 1.0 if possible):

Features:

Integrations:

Testing:

avsm commented 1 year ago

I'd really like to see if we can get @patricoferris' GCD backend integrated for a 1.0 as well.

anmonteiro commented 1 year ago

What’s Lwt_async?

patricoferris commented 1 year ago

I'd really like to see if we can get @patricoferris' GCD backend integrated for a 1.0 as well.

I have a much better understanding of Eio and concurrency/async IO now, so I'll see if I can bring this backend into shape and see how it's performance is.

What’s Lwt_async?

Possibly a typo :)) and was supposed to be async_eio https://github.com/talex5/async_eio ?

talex5 commented 1 year ago

Possibly a typo :)) and was supposed to be async_eio https://github.com/talex5/async_eio ?

Yes! Fixed :-)

kayceesrk commented 1 year ago

js_of_ocaml is is merged now. What would js_of_ocaml support look like?

patricoferris commented 1 year ago

I think there are two backends that would be needed for good jsoo support, one for node and one for the browser. For a quick win in the browser, I think just taking the mock backend's scheduler might be a good place to start and adding whatever things from the standard environment make sense e.g. jsoo has a notion of a fake filesystem which could be the backend for the fs parts of jsoo but jsoo would probably never have a network capability (or not now https://github.com/WICG/direct-sockets)

For node, we just need to wrap the node bindings which are basically libuv. I made a start over here: https://github.com/patricoferris/eio/tree/node/lib_eio_js

talex5 commented 1 year ago

For a quick win in the browser, I think just taking the mock backend's scheduler might be a good place to start and adding whatever things from the standard environment make sense

Yep (actually, this is a good place to start for any backend). Eio_main.run is intended for Unix-type systems and it's completely OK for JS applications to use a separate Eio_js.run with a different set of resources.

For node, we just need to wrap the node bindings which are basically libuv. I made a start over here: https://github.com/patricoferris/eio/tree/node/lib_eio_js

Excellent!

BTW, you might want to rebase your node backend on Eio 0.7, as there have been quite a few changes to the error handling since the commit it's based on.

Lupus commented 1 year ago

Is it practical to hand-roll node bindings using jsoo ffi directly nowadays? ts2ocaml can generate bindings out of TypeScript definitions. Bindings will use gen_js_api to actually compile to something that will work on jsoo. For simple libraries ts2ocaml can produce compileable bindings that you can use straight away. For more complex ones like Node API it can save you 80% of work.

How fast can jsoo be with effects? So far the consensus is that it's slow and as an optimization they suggest to avoids CPS transformaton for code that does not use effects. Will Eio code (that is 100% on effects) run fast enough on jsoo to be practical to be used anywhere in production?

patricoferris commented 1 year ago

Is it practical to hand-roll node bindings using jsoo ffi directly nowadays?

It's a fair point, but yes I think it is still practical as there's not that many. I am also firmly in the camp of hand-rolling a bit even if you eventually automate (like hand-writing C stubs before reaching for ctypes) so you are in full control over the bindings to avoid hard to debug problems (e.g. for effects to work the calling convention must use the underlying caml_js_wrap_callback_strict otherwise it won't be registered and I knew Brr made this update fairly quickly, I don't know if gen_js_api and ts2ocaml have ensured this (maybe they already did?)).

How fast can jsoo be with effects?

See the latest PR https://github.com/ocsigen/js_of_ocaml/pull/1384.

As an update for this thread, there's a PR open for the browser backend. https://github.com/ocaml-multicore/eio/pull/405