4 ms·
Agreed -- implementing epoll(7) for LX-branded zones on SmartOS[1] was a bit of a shock in terms of how unbelievably broken the abstraction is. I had assumed (
by bcantrill 11y ago
Agreed -- implementing epoll(7) for LX-branded zones on SmartOS[1] was a bit of a shock in terms of how unbelievably broken the abstraction is. I had assumed (ha!) that epoll(7) would have been inspired by the prior art: I/O completion ports on Windows, kqueue on the BSDs, and event ports on Solaris. Instead, despite being the last to the party, epoll(7) is but a more efficient variant of poll(2) -- retaining the broken-by-design aspects of poll(2) with respect to multi-threaded programs. (For details on these conditions, consult the strange Q&A in the epoll(7) man page[2] or the aborted attempt to rectify it with EPOLL_CTL_DISABLE[3].) I suppose that sd-event may represent an improvement in that it attempts to patch some of the leaks in the abstraction -- but I (certainly) agree that kqueue represents a much better design, and to the degree that libkqueue is able to provide that abstraction on Linux, a much better alternative.
[1] http://www.slideshare.net/bcantrill/illumos-lx http://www.slideshare.net/bcantrill/illumos-lx
[2] http://man7.org/linux/man-pages/man7/epoll.7.html http://man7.org/linux/man-pages/man7/epoll.7.html
[3] https://lwn.net/Articles/520198/ https://lwn.net/Articles/520198/
- protomyth 11y agoYour BSD Now interview[1] where you talk about epoll/kthread is informative and entertaining. The whole interview is worth watching. 1) http://www.bsdnow.tv/episodes/2015_08_19-ubuntu_slaughters_kittens http://www.bsdnow.tv/episodes/2015_08_19-ubuntu_slaughters_k... around 55:59
- twoodfin 11y agoThe story about restricting rm -rf / without violating the letter of the standard is also great stuff.
- protomyth 11y agoThat's probably a good question to ask about any piece of software or standard: "Be honest, Is there a way that your software or software written to the specification could render the computer unusable for someone not trying to render the computer unusable?"
- kbwt 11y agoA major problem with sd-event as an epoll replacement lies in how it handles multi-threading: It doesn't. The most error-prone part of using epoll in a multi-threaded environment is free-ing of the per-descriptor state. You never quite know when the last epoll_wait that still knew about that descriptor has fired. There are multiple approaches for dealing with this problem, including RCU-like waiting for each thread to pass epoll_wait once, recycling descriptor states by including an anti-race generation counter in the unused bits of the event user data, or garbage collection. In contrast, with IOCP or other completion-based programming models, you can reference count the active I/O operations and free once the count reaches zero.