-
Notifications
You must be signed in to change notification settings - Fork 176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: (softly) replace Lwt_unix by libuv/uwt #328
Comments
While that might be true, the same certainly cannot be said about |
This sounds like a lot of work if you don't want to break compat. Maybe having |
The arguments why a libuv base should be favored are convincing to me but I agree with c-cube that this does not have to mean removing the classical I'm also a little concerned about the story of Lwt_engine. Today Lwt_engine seems to be the preferred way of supporting various event loops, but that clearly isn't enough to support something like libuv (at least the way uwt does it). Seems strange to have an API for custom event loops that can't support even Lwt's own needs (libuv support). |
On Sun, Mar 26, 2017 at 12:24:09PM -0700, Anton Bachin wrote:
However, libuv is maintained by more people, and has a larger user base, so one can expect it to be of higher quality, especially over time. Also, the Lwt Unix binding's Windows side really doesn't get enough attention.
uwt is to libuv what Lwt_unix is to libev (+ OCaml's Unix on Windows), so the
proper comparison is between libev and libuv (and if you wish uwt to Lwt_unix
to evaluate the complexity of the corresponding bindings and the likelihood of
bugs).
That said yes, libuv is probably already in a better shape nowadays
(e.g. IOCP on Windows) and is likely to improve at a much faster rate given
the attention it gets thanks to Node.js.
This seems relevant: moby/vpnkit#69
I propose that we eventually somehow "bless" [`uwt`](https://github.com/fdopen/uwt), help maintain it, and/or merge it into Lwt, and start discouraging use of the current `Lwt_unix` and the rest of the current Unix binding.
`uwt` already seems to have work-alike modules for most (all?) of the Unix binding, which might make this process easier.
This would, however, introduce a new external dependency.
A merge would be unavoidable I'd say. All current Lwt end-users, except those
targeting the browser or node.js (via js-of-ocaml or bucklescript), use
Lwt_unix. Keeping uwt in good shape would become the Lwt maintainers' business
anyway.
Splitting the Lwt ecosystem in 2/3 wouldn't be a desirable outcome. I believe
the only way the move towards libuv could be successful is by pushing
functorization (or its moral equivalent with lwt.unix, lwt.uwt ... packages)
over Lwt_unix to library developers, and in the process also address
#270
(I believe #270 is probably more important than an hypothetical uwt backend
itself, for it both allows to use libuv via node.js and would at last bring
equal first-class OCaml (atop node.js) support on all platforms, massively
improving the OCaml + Win32 experience -- even if on non-windows we'd still
want to use the trusty OCaml backend -- cf. the stuff bucklescript is doing on
Win32)
This would have to go hand in hand with the development of comprehensive tests
for the Lwt_unix interface to both test the new backends and verify
compatibility.
So I think some good preliminary steps would be:
* to write such tests (useful whether or not a node.js / libuv backend
happens)
* to determine the viability of such "functorization" over lwt.unix
(verify whether all the functionality can be mapped as is, or if there are
unavoidable differences)
There are some other possibilities, like mio, but I haven't really looked at them yet. Discussion very welcome.
libuv is most likely to stay around (well maintained, and with many eyeballs
on it) for a long time, mio is still (too?) young and we don't know yet how
successful Rust will be.
…--
Mauricio Fernández
|
Yes, libuv is basically a c implementation of something very similar to lwt. But there are subtle incompatibilities to
The first model is far more friendly to language likes OCaml. You can wait until something changed with the states of your file descriptors and then you can do most of the work inside Ocaml. The second model forces you to move your data (buffers,etc.) outside the stack and OCaml heap. As long as the operation is not finished, you should obviously not move your buffers, etc. around. A further consequence of this is that under And because libuv tries to abstract away such different mechanisms, things are often more obscure. Something missing under And yes, higher level modules like |
There's also this https://github.com/piscisaureus/wepoll |
@bikallem One pre-req for using Uwt in Lwt should be porting Uwt to dune btw. Another point to consider is the huge amount of C code that's currently in Uwt. I have quite a lot of faith in the competence of the author of Uwt, but we should really look into minimizing the amount of C code through things like Ctypes and automatic binding generation. |
Should be more feasible now with https://github.com/aantron/luv. |
This diagram from the libuv docs sketches the logical structure of libuv.
Lwt_unix
has basically the same structure.(source: https://docs.libuv.org/en/v1.x/_images/architecture.png)
However, libuv is maintained by more people, and has a larger user base, so one can expect it to be of higher quality, especially over time. Also, the Lwt Unix binding's Windows side really doesn't get enough attention.
I propose that we eventually somehow "bless"
uwt
, help maintain it, and/or merge it into Lwt, and start discouraging use of the currentLwt_unix
and the rest of the current Unix binding.uwt
already seems to have work-alike modules for most (all?) of the Unix binding, which might make this process easier.This would, however, introduce a new external dependency.
There are some other possibilities, like mio, but I haven't really looked at them yet. Discussion very welcome.
cc @fdopen
The text was updated successfully, but these errors were encountered: