I've been reading about the new IO manager in GHC, which uses asynchronous event notifications and eschews blocking I/O to achieve high throughput.
Which IO activities are eligible for management by the new asynchronous IO code? Reading and writing of files and network activity? Database access? Are there kinds of IO where the manager has to resort to blocking?
Any file descriptor that can be managed by epoll
/kqueue
is eligible. Libraries that want asynchronous treatment of I/O need to cooperate with the I/O manager by
threadWaitRead
and threadWaitWrite
functions in GHC.Conc
before retrying a system call that previously returned EWOULDBLOCK
.This has already been done for the Handle
and Socket
types. If you use e.g. a binding to a C database library you will get blocking behavior as that library won't cooperate with the I/O manager.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With