logoalt Hacker News

adrian_b • yesterday at 1:32 PM • 1 reply • view on HN

There is an extra step after "you ask the OS to do something on your behalf and ask it when it’s done".

That is "you ask the OS to do something on your behalf and you do not have to check when it is done", because you have a unique queue where you receive notifications about everything that is of interest for you, including the completions of I/O activities that you have requested previously.

"You ask the OS to do something on your behalf and ask it when it’s done" was an ancient method to perform asynchronous I/O, which survived in many operating systems much more years than it should. Continuing to use such a method today is a mistake.

The best method for asynchronous I/O is with a unique input queue, like in the Linux io_uring. The second best method, because it can be used to implement a unique input queue, is with what in DEC RSX-11M was called "Asynchronous System Trap Service Routine", i.e. a callback function to be invoked upon I/O completion, which was inherited from DEC RSX-11M into DEC VMS, from where it was inherited into Microsoft Windows NT, and then in 1994 MS Windows NT 3.5 introduced the "I/O Completion Ports", which was AFAIK the first improvement in asynchronous I/O handling after what DEC RSX-11M did 20 years earlier, in 1974 (which was again the first improvement over what IBM PL/I already had in 1964, when it had the equivalent of WaitForMultipleEvents, but in a more powerful variant than in Windows NT).


Replies

Asmod4n • yesterday at 3:12 PM

I/O uring is built upon this, with it i can serve 155 http responses per syscall, whereas with epoll i can serve 0,2.

Having your OS do the batching for you can make it twice as fast.

My new http implementation went from 3 million responses per second per thread to 6 million, just from replacing epoll and non blocking sockets with liburing and batching.