Hacker News new | ask | show | jobs
by otabdeveloper 3372 days ago
Re: your point 1 -- waiting on a mutex happens regardless of whether you're using blocking or non-blocking IO.

If your program only ever makes IO system calls and nothing else, then your point might make sense, but this isn't a realistic real-world assumption.

Re: your point 3 -- not using the complete timeslice is not a realistic assumption. If you're creating threads then you're presumably doing some little bit of CPU-intensive work and not just copying bytes from one file descriptor to another.

You're making terribly silly assumptions about what kind of work servers actually do, and ignoring the real benefit of async solutions.

The real benefit is being able to control how threads switch by yourself instead of using the kernel's builtin 'black box' scheduling algorithms. The problem with the 'black box' is that the kernel might decide to penalize your threads for inscrutable reasons of 'fairness' and then you suddenly get inexplicable latency spikes.

Of course rolling your own scheduling is an engineering boondoggle and most people just opt for a very primitive round-robin solution. (Which, incidentally, is what you want anyways if you want good latency.)

In which case you might as well create a bunch of threads and schedule them as 'real-time' (SCHED_RR in Linux) and get the same result.

(Seriously, try it -- benchmark an async server vs a SCHED_RR sync server and see for yourself.)