Skip to content
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

Replace libuv #434

Closed
talex5 opened this issue Feb 2, 2023 · 7 comments · Fixed by #485
Closed

Replace libuv #434

talex5 opened this issue Feb 2, 2023 · 7 comments · Fixed by #485

Comments

@talex5
Copy link
Collaborator

talex5 commented Feb 2, 2023

libuv is not suitable for an Eio backend. Problems include:

The main reason to use it was to get Windows support for free. However, that doesn't fully work (aantron/luv#142) and we hope to provide a native Windows backend instead.

On other systems, we now use the much simpler Eio_posix backend.

@talex5 talex5 mentioned this issue Feb 2, 2023
25 tasks
@patricoferris
Copy link
Collaborator

In case it is useful I have a mostly working (but needs more testing and of course reviewing!) kqueue-based backend https://github.com/patricoferris/eio/tree/kqueue/lib_eio_kqueue. I'm a little more confident in this backend for macOS than GCD at the moment and we might get BSDs out of it too (although kqueue implementations vary between them all it seems)

@tmcgilchrist
Copy link

Out of interest @patricoferris what is the issue with using macOS GCD? Are there technical limitations or is it a matter of developer time?

@patricoferris
Copy link
Collaborator

Out of interest @patricoferris what is the issue with using macOS GCD? Are there technical limitations or is it a matter of developer time?

Good question! I've been hacking away without really completing both a kqueue-based backend and a GCD backend whilst reading quite a bit about both, and here's my opinionated thoughts on that matter:

  • From the outside it would seem GCD is not the best option for something like macOS -- I think it can still make sense for some applications (e.g. iOS) but after scouring many a forum, this is the general picture I'm getting from devs working in the Apple ecosystem. Have a read of this forum discussion https://forums.swift.org/t/task-safe-way-to-write-a-file-asynchronously/54639/ (I find it quite compelling that SwiftNIO did not choose GCD for macOS, they do have an extension to support more Apple devices that does use GCD for some things https://github.com/apple/swift-nio-extras).
  • I feel like GCD is an all or nothing approach when used how we want to use it. GCD is supposed to be clever enough to manage how many threads are spawned to handle your queues (in the case of concurrent queues it may even thread explode), I'm worried how this will play with a domainslib-style domain pool mechanism.
  • All callbacks, just like luv, have to be wrapped and are then called in another thread so there's a price to pay for acquiring the runtime lock and then this opens us up to strange behaviour I think similar to some of the issues talex5 mentioned above.

In the long run, on macOS, I think we'll benefit from being in total control of the OS resources ourselves. We can use kqueues for networking and then do some systhread worker pool magic for File I/O, this way we only have to fight with ourselves and not some other library too! I don't think the GCD backend is completely dead, but I think the kqueue support in Eio_posix is probably the first most important thing to do :))

@talex5
Copy link
Collaborator Author

talex5 commented Mar 7, 2023

Status update: we now have an Eio_posix backend (#448) that fixes these issues (though there are a few things to improve: #456). Eio_luv is now only used on Windows.

@samwgoldman
Copy link

we hope to provide a native Windows backend instead

The Flow team at Meta would be interested in this. We current use Lwt but have run into a number of Windows-related issues, so we're looking closely at Eio as we move to OCaml 5. I'm happy to help contribute to this.

@avsm
Copy link
Contributor

avsm commented Mar 21, 2023

@samwgoldman, glad to hear it! Just to help scope out your use of Windows here, are you primarily interested in a CLI to generate a flow.exe, or other Win32 API integration points?

@avsm avsm mentioned this issue Mar 21, 2023
9 tasks
@avsm
Copy link
Contributor

avsm commented Mar 21, 2023

The direct issue to supporting Windows is in #125, so best to switch discussion there from this one about libuv, @samwgoldman.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants