dice icon indicating copy to clipboard operation
dice copied to clipboard

Add support for IOCP

Open arpitbbhayani opened this issue 3 years ago • 5 comments

Is your feature request related to a problem? Please describe. Dice DB does not run on Windows natively.

Describe the solution you'd like Dice DB currently does not run on Windows because it does not support EPOLL, hence we need to add support for IOCP and do a conditional build.

arpitbbhayani avatar Oct 16 '22 16:10 arpitbbhayani

Reference Links: https://dave.cheney.net/2013/10/12/how-to-use-conditional-compilation-with-the-go-build-tool

arpitbbhayani avatar Oct 16 '22 16:10 arpitbbhayani

Along with IOCP addition, we have to introduce new system call invocations as defined in https://github.com/golang/go/blob/master/src/syscall/syscall_windows.go

This should happen in a new file, let say - eval_windows_amd64.go

rohanverma94 avatar Oct 17 '22 07:10 rohanverma94

Just got access to a windows server 2022, so I'll take this issue. Though I'm dealing with AOF currently, I'm willing to take this as well.

rohanverma94 avatar Oct 19 '22 16:10 rohanverma94

Great. Go for it @rohanverma94

arpitbbhayani avatar Oct 19 '22 17:10 arpitbbhayani

Turns out that IOCP behaves in contrast to Kqueue or Epoll. While Epoll waits for file descriptor to be available and then sends the message buffer, IO completion ports work in a bottom-up approach by sending the buffer to file handles and then waiting till who finishes first, then assigning the next worker thread to that handle.

The file Descriptor approach needs to be scraped for Windows. And a major part of async_tcp needs to be specialized for windows. Just need a couple of hours to set up the event loop with IOCP. IOCP in Windows Server 2022 can be compute-intensive, other features have to be designed accordingly. Also the straightforward goroutine spawn for RunAsyncTCPServer() needs to be removed for IOCP and should be moved to specialized Linux and darwin versions.

If we can pull this out, then Dice would be one of the few redis-compatible databases with Windows Support. Even redis can't be compiled on windows. This would definitely be an edge over Redis.

image

rohanverma94 avatar Oct 22 '22 11:10 rohanverma94