-
Notifications
You must be signed in to change notification settings - Fork 37
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
Windows support #35
Comments
Solution 2.5:@piscisaureus alerted me to the undocumented |
On Thu, Mar 26, 2015 at 05:34:46PM -0700, daurnimator wrote:
Very cool. Looks like the work originated here
according to this thread
|
More information about what AFD is: http://mista.nu/blog/2012/02/17/cve-2012-0148-a-deep-dive-into-afd/ |
I had a play around with AFD today, check out this example: https://gist.github.com/daurnimator/63d2970aedc952f0beb3 |
One of the roadblocks I learnt about was that you can't have an IOCP listen for events on an IOCP.
Maybe we can have some arrangement where a worker thread polls |
For the |
My current opinion has tended back to Solution 1. |
I played around with adding a |
@katlogic suggested using https://github.com/richardhundt/upoll |
On Mon, Mar 07, 2016 at 06:31:51PM -0800, daurnimator wrote:
It's not doing anything that the existing code isn't already doing except I had an idea for supporting Windows overlapped I/O in a performant manner, But simply supporting select on Windows is probably the best interim |
In midipix there's an interesting approach: for sockets, use AFD; but for other handle types, do a 0 byte read/write using the NT API in a worker thread. These block until there is data available for read/write. At which point you can signal an event. This works out at scale because on NT, canceling io operations is cheap. |
On Thu, May 19, 2016 at 09:46:19PM -0700, daurnimator wrote:
Can you post a link? |
I suggest use Here has a https://github.com/dpull/skynet-mingw/blob/master/platform/epoll.c |
Somewhat tangential, but I was reading up on Linux's io_uring API and had the thought that adding support for it in cqueues might make it simpler to also support IOCP, given that there seem to be similarities. I'm oversimplifying and understand that this would likely be a lot of work. I suggest this because cqueues and Lua-HTTP are my favorite libraries for their purpose and a lack of Windows is a frequent issue. |
Looking in the comments, I see that @wahern isn't huge fan of this, so maybe it's not a great fit. :) |
I've been mulling over how hard adding windows support to cqueues would be.
Lower level windows programming is not something I'm familar with, so please correct any incorrect assumptions I've made.
I'd love to have cqueues be a library I can depend on everywhere: if I write a network client in cqueues, even windows developers should still be able to use it (though maybe not in a performant way, which is the approach many applications take, e.g. nginx).
Comments @wahern has made before:
Solution 1. Add
:pollset
One possible route is catering to the lowest common denominator (which helps with other platforms, such as AIX) and use
select()
. This can be accomplished by iterating over thefileno
LLRB and building a pollset; this could be done on demand in a:pollset()
function, or inside offileno_ctl
.Issues
select does not expose a file handle we can wait on itself, and makes things much harder to nest/stack, :pollsets will need to be propogated up to the parent controller.
On windows, select boils down to a WaitForMultipleObjectsEx call, this has a maximum of 64 handles; which could easily be exceeded by a regular application. To get around this, you can spawn extra threads that each wait for events, and wait for them, and now we've recreated stackable event waiting.
Solution 2. Use an IOCP and
RegisterWaitForSingleObject
RegisterWaitForSingleObject
where the callback usesPostQueuedCompletionStatus
kpoll_wait
usesGetQueuedCompletionStatusEx
:pollfd()
returns the IOCP handleIssues
Windows potentially has more than just
readable
andwritable
events; you need to use WSACreateEvent + WSAEventSelect to manage aHANDLE
that encapsulates the events being waited for.The text was updated successfully, but these errors were encountered: