5 ms·
Anecdatum: I work with a guy who is pretty scary brilliant when it comes to programming; He programs on windows and his software is of a really good quality- I
by dijit 10y ago
Anecdatum: I work with a guy who is pretty scary brilliant when it comes to programming; He programs on windows and his software is of a really good quality- I asked him why he used Windows and he gave two reasons:
1) Windows is mandated by HQ as the only supported desktop. You're not getting anything else to run on your desktop so you either write Windows software locally or use a VM (which is cumbersome0
2) Epoll is trash.
I have successfully convinced him to make some software on freebsd because kqueue is fundamentally better. But it's shocking that epoll is so bad even compared to windows :(
- ReverseCold 10y ago> even compared to windows Windows is an expensive commercial OS, if anything it should be better, and it usually is better than the Linux desktop. Power use (no rip battery), "it just works", fast and efficient in most cases. CLI is a whole different story, but bash in ubuntu in windows is already pretty good, and there's no reason it can't be equal to bash on any other Linux distribution.
- Sacho 10y agoPowershell is pretty cool, but it's not as integrated into the "essence" of windows like sh is for linux. There's been a bunch of projects that make extensive use of it lately, like chocolatey - I hope it keeps getting better.
- ktRolster 10y agoWindows has no right to trash-talk: WaitForMultipleObjects() is one of the most depressing select-like APIs out there.
- GauntletWizard 10y agoNot being familiar, it looks pretty standard. What're it's negative attributes?
- ktRolster 10y agoConceptually, select() can wait on anything that's a file descriptor. WaitForMultipleObjects() can only work on things that were specifically added to its capability list. Practically, MAXIMUM_WAIT_OBJECTS is set to such a low number (64) that people resort to this kind of hack: https://msdn.microsoft.com/en-us/library/windows/desktop/ms687055(v=vs.85).aspx https://msdn.microsoft.com/en-us/library/windows/desktop/ms6...
- xorblurb 10y agoIIRC there are even advanced Win32 API that, so that you can go above MAXIMUM_WAIT_OBJECTS, ... automatically handle a thread poll! That kind of "solution" to such a problem is way more insane than epoll() eventually providing the correct flags to fix most of its own issues, even if we had to wait during a decade for it... So praising NT because epoll is "trash" is uninformed at best, malicious at worst.
- unscaled 10y agoWaitForMultipleObjects sucks, but that's because it got very little love since Windows 95. That's because Microsoft seems to have completely abandoned the Reactor (select/epoll wake-on-readiness) pattern in favor of the Proactor (IOCP-like wake-on-event/completion) pattern. With the proactor pattern, you register events you care about explicitly, and your event-loop gets the next event to handle and schedules the respective callback/coroutine/future to handle that event. With the reactor pattern you don't have explicit registration for completion status when you do an I/O operation, and you need to explicitly specify the file descriptors you want to select on in the point where you select on them. Many people (including the author of the OP article) think that proactor is superior, and this was what the Windows guy in the parent post was referring to. In Windows you're NEVER SUPPOSED to use any version of select (including WSAAsyncSelect or WaitForMultipleObjects) if you have a large number of events. They don't scale. Instead, Microsoft decided to put its scaling effort into the proactor approach, which they introduced in Windows NT 3.5 -almost a decade before Linux came out with epoll - and this was the right way to do async I/O on Windows ever since. Linux, on the other hand, chose to perfect the reactor model, and with epoll it gave a very powerful select-like reactor implementation[1]. So yes, if you specifically want to program a reactor, go with Linux. Reactor-centric software and libraries (like libev or nginx) just don't scale on Windows. But that doesn't mean async I/O on Windows sucks - it's just optimized for a different model. [1] kqueue could be better, but I don't know it well enough to make a call. And while it's I/O events are readiness based, as far as I understand it's general enough that it can be used to implement a proactor as well.
- trentnelson 10y agoThat is actually an excellent API; you can wait for up to 64 arbitrary events in a relatively efficient manner. You should never, ever use it for high performance I/O.
- ploxiln 10y agoBut even with IOCP, Windows IIS implements request handling as a kernel module to accelerate it, and yet still isn't faster than nginx on linux with many cpu cores. https://www.rootusers.com/wp-content/uploads/2017/01/iis-linux-webservers-8-cpu-cores.png https://www.rootusers.com/wp-content/uploads/2017/01/iis-lin... But can be noticeably faster on fewer cores: https://www.rootusers.com/linux-vs-windows-web-server-benchmarks/ https://www.rootusers.com/linux-vs-windows-web-server-benchm... But still in many cases has more performance pitfalls in practice: http://serverfault.com/questions/317199/linux-vs-windows-7-web-server-performance-differences http://serverfault.com/questions/317199/linux-vs-windows-7-w... So, sure, epoll() does not help for optimal distribution of accept() or read() of the same fds over multiple threads. But even with a single thread accepting, or with "thundering herd" problems of other strategies, linux is still usually more efficient in practice. Often dumb non-optimal designs are faster just due to subtle problems caused by overall system complexity. Side note: macOS has kqueue, but it's been buggy in enough releases that libevent and libev usually have to use select() on macOS to be safe. http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod#OS_X_AND_DARWIN_BUGS http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod#OS_X_AN... https://github.com/libevent/libevent/pull/377 https://github.com/libevent/libevent/pull/377 So for your "optimal socket handling" tasks you're really limited to choosing between Linux and FreeBSD, and there are other issues to consider there, like drivers.