-
Notifications
You must be signed in to change notification settings - Fork 188
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
WIP : Basic WinIO support #509
base: master
Are you sure you want to change the base?
Conversation
@Mistuke When it gets ready, please let me know. |
@Mistuke I finally installed Windows 10 on VirtualBox in macOS. At this moment, my I'm now quite motivated to help you. Please tell me what I can do for the new async interface. |
@kazu-yamamoto ah great! We're trying to get it on by default for 9.4 so network was indeed on my list of high priority tasks.
Great, I have been looking how to best support this, I'll post some of the generic things that need changing and we can go from there. I'll post them friday. Thanks! |
@Mistuke I confirmed that such syscalls are I wonder why. |
Because in the old I/O manager as I mentioned the operations are performed on the same underlying OS thread. That the I/O operation operation is marked |
OK. I misunderstood the case of MIO on Windows. This code still hangs with |
The code should have crashed, network at the moment cannot work with WinIO because WinIO can't deal with fd based handles. I'm surprised that it didn't trigger the fail messages. GHC 9.0.2 also contains bugs that are fixed in later versions that are being back ported. So I'd recommend 9.2.2 for any experiments. But yes network doesn't work at all. GHC won't be able to do anything with the Handles returned by network. |
Thank you for explanation. I'm waiting for GHC 9.2.2! |
As I mentioned I'll write it up tomorrow in a bit more detail, but to give an idea the major difference between what network does now and what winio requires is that network should never issue a blocking call at all. any operation needs to be associated with the I/O manager by registering the handle to the completion port of the I/O manager (See e.g. https://github.com/ghc/ghc/blob/378c0bba7d132a89dd9c35374b7b4bb5a4730bf7/libraries/base/GHC/IO/Windows/Handle.hsc#L830 for how files are operations are associated), after that network must always use async operations. i.e. no more If a call is to be waited upon, e.g. a For instance see how blocking reads are handled for files https://github.com/ghc/ghc/blob/378c0bba7d132a89dd9c35374b7b4bb5a4730bf7/libraries/base/GHC/IO/Windows/Handle.hsc#L432 You have to register a callback to a special You also have to tell it how to start the I/O operation you want to perform, none of these calls are allowed to block on a foreign call. If you're interested in how the I/O manager deals with requests you can read the notes at which will give you the general overview. |
It's also important to note that the design of the I/O manager safely allows any package to implement their own result handling routine. So e.g. network is allowed to implement it's own https://github.com/ghc/ghc/blob/f115c382a0b0cc9299e73bcb8a11ad97c5fe7c57/libraries/base/GHC/Event/Windows.hsc#L520 which in the future might be required to support RIO (the high throughput DMA based networking stuff in Windows). For now though |
@kazu-yamamoto Did you get a chance to check out the links above? So essentially there are two big changes required in network:
i.e. there's an implicit assumption that the Socket handle fits in an As such I think we need something like
The problem is that you can switch between I guess there's no way around it and we need new helpers to deal with the HANDLE part. WinIO deals with which I/O manager is active by using a helper Do you agree with just adding the second constructor?
It looks like the we should either handle this internally with I think most changes are fairly straight forward aside from the datatype change. |
Yes!
This is exactly the same as my guess. :-)
Oh. I'm missing this point.
I don't have strong opinion on this. We might want to chose the appoarch of building flag. But let's try
If this refers to
I think so.
Sounds nice! |
This is a work in progress to add basic WinIO support to network.
Basic here means that we're not taking full advantage of the new I/O manager
but that we provide a compatibility layer between the current structures of network
and WinIO.
This will allow us to progress WinIO to the next stage in GHC and turn it on by default
while the discussions on an async network design are in progress.
See #364
/cc @eborden and @kazu-yamamoto , just so you know about it but it's not ready for review.