-
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
Socket #286
Comments
@kazu-yamamoto I wrote this up a while ago when @tfausak asked me for a compare and contrast: There are a few stark and interesting differences. data Socket
= MkSocket
CInt -- File Descriptor
Family
SocketType
ProtocolNumber -- Protocol Number
(MVar SocketStatus) -- Status Flag socket newtype Socket f t p
= Socket (MVar Fd) The
The other difference is that The design decision of pushing socket descriptions to the type level also has some other nice benefits. In Though it seems In general I like the look of this library. There was some experimentation with More would have to be done. I'm not really convinced that |
Thank you for your explanation. I knew you wrote this somewhere but I lost the reference. And I understand "faster" is my misunderstanding. In my opinion, the approach of the |
@kazu-yamamoto Yeah, I'd only really embark on this level of breakage in a epoch version, like 3.0.0.0. I'm also not sure if it is worth it 😄 I had started a branch to experiment with this, but the major changes in module structure would make that difficult to merge or compare. I'll likely open another branch to continue experimenting. That would at least give us a full view of the breakage. The new module structure should actually make this work more digestible! |
@eborden Do you know whether or not sockets (ie |
@kazu-yamamoto That is a valid concern. That would certainly exacerbate contention issues in a |
Hi there (@eborden, @kazu-yamamoto), I took the time to write a benchmark comparing Here's the result:
Yes, the concern is valid, but the penalty is still within the same order of magnitude. In general, I wonder whether
I also want to say something more general wrt to the I wrote The following things might be missing right now:
Finally, I honor and appreciate everyone's work taking place right now in refactoring the network library and cleaning up the pile of issues :-) |
Yeah. Do |
I agree. I guess that Also, the |
We can use |
I will spend to refactor @eborden What do you think? |
@kazu-yamamoto I'm not sure encouraging a transition to |
@eborden Probably we should consider a migration path from |
My idea:
If we make |
@eborden Please read https://github.com/haskell/network#milestones |
@eborden I made PoC in https://github.com/kazu-yamamoto/network/tree/epoch Not completed but you can see types of some APIs are relaxed. |
I would close this. |
My instinct is to strongly disagree with the above. It is not possible to track the sock handle open/close status just in the OS, because the OS representation of a socket (the file descriptor) is reused after close. For safety, just as with Whether hiding the FD inside an IORef is better than keeping a separate mutable status (checked only on close) depends on whether you want to also invalidate all other operations on close (read, write, ...) by invalidating the FD (on WIndows the magic value is Keeping the FD in an IORef (less contention than MVAR, safer than CInt) would be my starting point, and then change it only on evidence that there's a much better alternative that does not compromise too much safety. |
@eborden Would you explain why the
socket
package is fast? I have read the source but I don't understand the key idea.The text was updated successfully, but these errors were encountered: