Using oneshot kqueue() on macOS
Oneshot kqueue() is disabled on macOS due to #7651 (closed)
Recall that the paper "Mio: A High-Performance Multicore IO Manager for GHC" says:
"Mio also uses kqueue on OS X, since Darwin, the foundation for Apple’s OS X, is a variant of BSD. However, we encountered problems running parallel builds of the GHC compiler using Mio as described above. We have been unable to uncover the underlying source of the problem to our satisfaction. However, several Internet discussions suggest that the implementation of kqueue and pipe on OS X are unstable. We were able to resolve the observed prob- lems on OS X by avoiding the use of one-shot mode on OS X, instead unregistering events after they are delivered, and by send- ing wakeup writes to a pipe monitored by the dispatcher threads’ kqueue instances on every event registration. With these changes, the behavior on OS X, including parallel builds of GHC, has been stable."
Now the serious bug on KQueue has been fixed:
So, I guess it's time to use oneshot on macOS. A patch is attached.