Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Move erts IO Polling to dedicated threads #1552
This PR implements a solution to the problem described in https://bugs.erlang.org/browse/ERL-140.
The implementation moves all IO polling out from the main scheduler loops into separate dedicated thread(s). By default one thread is started to be the poller and all file descriptors (or waitable objects) are handled by it using a kernel-poll mechanism.
On operating systems that can do concurrent updates of the kernel poll-set (linux and bsd), the new implementation has no global locks that need to be taken when updating the poll-set. On operating systems that cannot do concurrent updates, there is still a lock per poll-set that has to be taken.
Linux and BSD
The basic flow of operation for handling a driver_select call is as follows:
Basically the same flow happens, the major difference is that the actual inserting into the poll-set is done by the poll-thread itself instead of by the scheduler threads.
I've done quite a bit of benchmarking, mainly to make sure that we don't get any regressions when using this approach. The throughput and latency figures look promising, through I don't really have access to any great benchmarks or hardware to run them on. So if you have any socket IO intensive benchmarks, please run them and report back with the good or bad results.
There are a few testcases that still fail on various platforms due to testcase timing issues, and some new testcases have to be written for the new erts options.