Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What IO activity does the GHC IO manager support?

Tags:

haskell

ghc

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?

like image 589
Bill Avatar asked Dec 15 '10 04:12

Bill


1 Answers

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

  • making file descriptors non-blocking, and
  • calling the 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.

like image 112
tibbe Avatar answered Oct 02 '22 12:10

tibbe